human
Complete this python program:
def _SignedVarintDecoder(mask):
assistant
#Here is the Python program you requested.

    """Like _VarintDecoder() but decodes signed values.
    """
    local_ord = ord
    def DecodeVarint(buffer, pos):
        result = 0
        shift = 0
        while 1:
            b = local_ord(buffer[pos])
            result |= ((b & 127) << shift)
            pos += 1
            if (not (b & 128)):
                if (result > 9223372036854775807):
                    result -= (1 << 64)
                    result |= (~ mask)
                else:
                    result &= mask
                return (result, pos)
            shift += 7
            if (shift >= 64):
                raise _DecodeError('Too    many    bytes    when    decoding    varint.')
    return DecodeVarint