public static long read(InputStream is, boolean isSigned) throws IOException {
		int nextByte = 0;
		int shift = 0;
		long value = 0;
		while (true) {
			nextByte = is.read();
			if (nextByte < 0) {
				throw new EOFException();
			}
			if (shift == 70 || (isSigned == false && shift == 63 && nextByte > 1)) {
				throw new IOException(
					"Unsupported LEB128 value, too large to fit in 64bit java long variable");
			}

			// must cast to long before shifting otherwise shift values greater than 32 cause problems
			value |= ((long) (nextByte & 0x7F)) << shift;
			shift += 7;

			if ((nextByte & 0x80) == 0) {
				break;
			}
		}
		if ((isSigned) && (shift < Long.SIZE) && ((nextByte & 0x40) != 0)) {
			// 0x40 is the new 'high' sign bit since 0x80 is the continuation flag.
			// bitwise-or in all the sign-extension bits we need for the value
			value |= (-1L << shift);
		}

		return value;
	}
Reads a LEB128 number from the stream and returns it as a java 64 bit long int.
<p>
Large unsigned integers that use all 64 bits are returned in a java native
'long' type, which is signed.  It is up to the caller to treat the value as unsigned.
<p>
Large integers that use more than 64 bits will cause an IOException to be thrown.

@param is {@link InputStream} to get bytes from
@param isSigned true if the value is signed
@return long integer value.  Caller must treat it as unsigned if isSigned parameter was
set to false
@throws IOException if an I/O error occurs or decoded value is outside the range of a java
64 bit int (or it used more than {@value #MAX_SUPPORTED_LENGTH} bytes to be encoded), or 
there is an error or EOF getting a byte from the InputStream before reaching the end of the
encoded value
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/LEB128.java