public static int readSignedLeb128(ByteInput in) {
    int result = 0;
    int cur;
    int count = 0;
    int signBits = -1;

    do {
      cur = in.readByte() & 0xff;
      result |= (cur & 0x7f) << (count * 7);
      signBits <<= 7;
      count++;
    } while (((cur & 0x80) == 0x80) && count < 5);

    if ((cur & 0x80) == 0x80) {
      throw new DexException("invalid LEB128 sequence");
    }

    // Sign extend if appropriate
    if (((signBits >> 1) & result) != 0) {
      result |= signBits;
    }

    return result;
  }
Reads an signed integer from {@code in}.
android/android_framework/dex-maker/src/main/java/com/android/dex/Leb128.java