reads a varInt after the first byte was read. The first byte is used to specify the sign and -0 has different
representation on the protected API that was called

@param firstByte last varInt octet
502407
private int readVarInt(int firstByte) throws IOException {
        // VarInt uses the high-order bit of the last octet as a marker; some (but not all) 5-byte VarInts can fit
        // into a Java int.
        // To validate overflows we accumulate the VarInt in a long and then check if it can be represented by an int
        //
        // see http://amzn.github.io/ion-docs/docs/binary.html#varuint-and-varint-fields

        long retValue = 0;
        int b = firstByte;
        boolean isNegative = false;

        for (;;) {
            if (b < 0) throwUnexpectedEOFException();
            if ((b & 0x40) != 0) {
                isNegative = true;
            }

            retValue = (b & 0x3F);
            if ((b & 0x80) != 0) break;

            if ((b = read()) < 0) throwUnexpectedEOFException();
            retValue = (retValue << 7) | (b & 0x7F);
            if ((b & 0x80) != 0) break;
            // for the rest, they're all the same


            if ((b = read()) < 0) throwUnexpectedEOFException();
            retValue = (retValue << 7) | (b & 0x7F);
            if ((b & 0x80) != 0) break;
            // for the rest, they're all the same

            if ((b = read()) < 0) throwUnexpectedEOFException();
            retValue = (retValue << 7) | (b & 0x7F);
            if ((b & 0x80) != 0) break;
            // for the rest, they're all the same

            if ((b = read()) < 0) throwUnexpectedEOFException();
            retValue = (retValue << 7) | (b & 0x7F);
            if ((b & 0x80) != 0) break;

            // Don't support anything above a 5-byte VarInt for now, see https://github.com/amzn/ion-java/issues/146
            throwVarIntOverflowException();
        }

        if (isNegative) {
            retValue = -retValue;
        }

        int retValueAsInt = (int) retValue;
        if (retValue != ((long) retValueAsInt)) {
            throwVarIntOverflowException();
        }

        return retValueAsInt;
    }
870249
def read_var_int(file_obj):
    
    # Read all bytes from here, stopping with the first one that does not have
    # the MSB set. Save the lower 7 bits, and keep stacking to the *left*.
    val = 0
    shift = 0
    while True:
        # Read next byte
        next_val = ord(file_obj.read(1))
        val |= ((next_val & 0x7F) << shift)
        shift += 7
        if not next_val & 0x80:
            break

    return val
256592
public int readVarInt (boolean optimizePositive) throws KryoException {
		if (require(1) < 5) return readVarInt_slow(optimizePositive);
		int b = buffer[position++];
		int result = b & 0x7F;
		if ((b & 0x80) != 0) {
			byte[] buffer = this.buffer;
			int p = position;
			b = buffer[p++];
			result |= (b & 0x7F) << 7;
			if ((b & 0x80) != 0) {
				b = buffer[p++];
				result |= (b & 0x7F) << 14;
				if ((b & 0x80) != 0) {
					b = buffer[p++];
					result |= (b & 0x7F) << 21;
					if ((b & 0x80) != 0) {
						b = buffer[p++];
						result |= (b & 0x7F) << 28;
					}
				}
			}
			position = p;
		}
		return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
	}
1055961
@Override
  public int read(byte[] b, int off, int len) throws IOException {
    if (b == null) {
      throw new NullPointerException();
    } else if (off < 0 || len < 0 || len > b.length - off) {
      throw new IndexOutOfBoundsException();
    } else if (len == 0) {
      return 0;
    }
    if (endOfInput && !bbuf.hasRemaining()) {
      return -1;
    }

    int totalRead = 0;
    while (len > 0 && !endOfInput) {
      if (bbuf.hasRemaining()) {
        int remaining = Math.min(len, bbuf.remaining());
        bbuf.get(b, off, remaining);
        totalRead += remaining;
        off += remaining;
        len -= remaining;
        if (len == 0) {
          return totalRead;
        }
      }
      advance();
    }
    if (endOfInput && !bbuf.hasRemaining() && totalRead == 0) {
      return -1;
    }
    return totalRead;
  }
470249
public static void writeUnsignedVarint(ByteBuffer buffer, int val) {
    // Extra bytes have the high bit set
    while((val & 0x7F) != val) {
      buffer.put((byte) ((val & 0x7F) | 0x80));
      val >>>= 7;
    }
    // Last byte doesn't have high bit set
    buffer.put((byte) (val & 0x7F));
  }
118916
public static int readVByte(final InputStream is) throws IOException {
		for(int x = 0; ;) {
			final int b = is.read();
			x |= b & 0x7F;
			if ((b & 0x80) == 0) return x;
			x <<= 7;
		}
	}
201662
static private int readBytes(int c[], int len, InputStream is)
                throws IOException {

        byte buf[] = new byte[len];
        if (is.read(buf, 0, len) < len) {
            return -1;
        }

        // fill the passed in int array
        for (int i = 0; i < len; i++) {
             c[i] = buf[i] & 0xff;
        }
        return 0;
    }
242081
private static long readVLong(DataInput stream) throws IOException {
    byte firstByte = stream.readByte();
    int len = decodeVIntSize(firstByte);
    if (len == 1) {
      return firstByte;
    }
    long i = 0;
    for (int idx = 0; idx < len-1; idx++) {
      byte b = stream.readByte();
      i = i << 8;
      i = i | (b & 0xFF);
    }
    return (isNegativeVInt(firstByte) ? (i ^ -1L) : i);
  }
1208175
public void readBytes (byte[] bytes, int offset, int count) throws KryoException {
		if (bytes == null) throw new IllegalArgumentException("bytes cannot be null.");
		int copyCount = Math.min(limit - position, count);
		while (true) {
			System.arraycopy(buffer, position, bytes, offset, copyCount);
			position += copyCount;
			count -= copyCount;
			if (count == 0) break;
			offset += copyCount;
			copyCount = Math.min(count, capacity);
			require(copyCount);
		}
	}
354910
public int readRawVarint32() throws IOException {
    byte tmp = readRawByte();
    if (tmp >= 0) {
      return tmp;
    }
    int result = tmp & 0x7f;
    if ((tmp = readRawByte()) >= 0) {
      result |= tmp << 7;
    } else {
      result |= (tmp & 0x7f) << 7;
      if ((tmp = readRawByte()) >= 0) {
        result |= tmp << 14;
      } else {
        result |= (tmp & 0x7f) << 14;
        if ((tmp = readRawByte()) >= 0) {
          result |= tmp << 21;
        } else {
          result |= (tmp & 0x7f) << 21;
          result |= (tmp = readRawByte()) << 28;
          if (tmp < 0) {
            // Discard upper 32 bits.
            for (int i = 0; i < 5; i++) {
              if (readRawByte() >= 0) {
                return result;
              }
            }
            throw InvalidProtocolBufferException.malformedVarint();
          }
        }
      }
    }
    return result;
  }
536389
@Override
  public int read(byte[] b, int start, int length) throws IOException {
    if (!readMetaDataIfNeeded()) {
      return -1;
    }
    int toRead = (int)Math.min(length, getCompleteBlockSize() - rawBlockOffset);
    int read = in.read(b, start, toRead);
    if (read >= 0) {
      moveForward(read);
    } else {
      eofReached = true;
    }
    return read;
  }
1164883
private int readUnsignedVarInt() throws IOException {
    int value = 0;
    int shift = 0;
    int b;
    do {
      b = in.read();
      value |= (b & 0x7F) << shift;
      shift += 7;
    } while ((b & 0x80) != 0);
    return value;
  }
458429
private int readNext(byte[] dest, int offset, int len)
            throws IOException
    {
        int readBytes = 0;
        while (readBytes < len) {
            int ret = in.read(dest, readBytes + offset, len - readBytes);
            if (ret == -1) {
                finishedReading = true;
                return readBytes;
            }
            readBytes += ret;
        }
        return readBytes;
    }
330337
function readVarInt (buffer, offset) {
  const result = varuint.decode(buffer, offset);

  return {
    number: result,
    size: varuint.decode.bytes
  };
}
1015733
private void readShortRepeatValues(int firstByte)
            throws IOException
    {
        // read the number of bytes occupied by the value
        int size = (firstByte >>> 3) & 0b0111;
        // #bytes are one off
        size += 1;

        // read the run length
        int length = firstByte & 0x07;
        // run lengths values are stored only after MIN_REPEAT value is met
        length += MIN_REPEAT_SIZE;

        // read the repeated value which is store using fixed bytes
        long val = bytesToLongBE(input, size);

        if (signed) {
            val = LongDecode.zigzagDecode(val);
        }

        // repeat the value for length times
        for (int i = 0; i < length; i++) {
            literals[numLiterals++] = val;
        }
    }
716174
@Override
    public byte readByte(final boolean unsigned, final int size) throws IOException {
        return (byte) readInt(unsigned, requireValidSizeByte(unsigned, size));
    }
1319937
protected final int readBytes()
        throws IOException
    {
        _inputPtr = 0;
        _inputEnd = 0;
        if (_inputSource != null) {
            int count = _inputSource.read(_inputBuffer, 0, _inputBuffer.length);
            if (count > 0) {
                _inputEnd = count;
            }
            return count;
        }
        return -1;
    }