code: public int readVarIntFlag (boolean optimizePositive) {
  		if (require(1) < 5) return readVarIntFlag_slow(optimizePositive);
  		int b = buffer[position++];
  		int result = b & 0x3F; // Mask first 6 bits.
  		if ((b & 0x40) != 0) { // Bit 7 means another byte, bit 8 means UTF8.
  			byte[] buffer = this.buffer;
  			int p = position;
  			b = buffer[p++];
  			result |= (b & 0x7F) << 6;
  			if ((b & 0x80) != 0) {
  				b = buffer[p++];
  				result |= (b & 0x7F) << 13;
  				if ((b & 0x80) != 0) {
  					b = buffer[p++];
  					result |= (b & 0x7F) << 20;
  					if ((b & 0x80) != 0) {
  						b = buffer[p++];
  						result |= (b & 0x7F) << 27;
  					}
  				}
  			}
  			position = p;
  		}
  		return optimizePositive ? result : ((result >>> 1) ^ -(result & 1));
  	}
docs: Reads the 1-5 byte int part of a varint flag. The position is advanced so if the boolean part is needed it should be read
  first with {@link #readVarIntFlag()}.