code: private static long getLong(final byte[] bArr, final int index, final int rem) {
      long out = 0L;
      for (int i = rem; i-- > 0;) { //i= 7,6,5,4,3,2,1,0
        final byte b = bArr[index + i];
        out ^= (b & 0xFFL) << (i * 8); //equivalent to |=
      }
      return out;
    }
docs: Gets a long from the given byte array starting at the given byte array index and continuing for
  remainder (rem) bytes. The bytes are extracted in little-endian order. There is no limit
  checking.
  
  @param bArr The given input byte array.
  @param index Zero-based index from the start of the byte array.
  @param rem Remainder bytes. An integer in the range [1,8].
  @return long