def readsleb128(buff):
    """
    Read a signed LEB128 at the current position of the buffer.

    :param buff: a file like object
    :return: decoded sLEB128
    """
    result = 0
    shift = 0

    for x in range(0, 5):
        cur = get_byte(buff)
        result |= (cur & 0x7f) << shift
        shift += 7

        if not cur & 0x80:
            bit_left = max(32 - shift, 0)
            result = result << bit_left
            if result > 0x7fffffff:
                result = (0x7fffffff & result) - 0x80000000
            result = result >> bit_left
            break

    return result
def readsleb128 ( buff ) : result = 0 shift = 0 for x in range ( 0 , 5 ) : cur = get_byte ( buff ) result |= ( cur & 0x7f ) << shift shift += 7 if not cur & 0x80 : bit_left = max ( 32 - shift , 0 ) result = result << bit_left if result > 0x7fffffff : result = ( 0x7fffffff & result ) - 0x80000000 result = result >> bit_left break return result
Read a signed LEB128 at the current position of the buffer.

    :param buff: a file like object
    :return: decoded sLEB128