code: public static int unshuffle(ByteBuffer shuffled, BitShuffleType type, ByteBuffer output) throws IOException {
          if (!shuffled.isDirect()) {
              throw new SnappyError(SnappyErrorCode.NOT_A_DIRECT_BUFFER, "input is not a direct buffer");
          }
          if (!output.isDirect()) {
              throw new SnappyError(SnappyErrorCode.NOT_A_DIRECT_BUFFER, "destination is not a direct buffer");
          }
  
          // input: input[pos(), limit())
          // output: shuffled
          int uPos = shuffled.position();
          int uLen = shuffled.remaining();
          int typeSize = type.getTypeSize();
          if (uLen % typeSize != 0) {
              throw new IllegalArgumentException("length of input shuffled data must be a multiple of the given type size: " + typeSize);
          }
          if (output.remaining() < uLen) {
              throw new IllegalArgumentException("not enough space for output");
          }
          int numProcessed = impl.unshuffleDirectBuffer(shuffled, uPos, typeSize, uLen, output, shuffled.position());
          assert(numProcessed == uLen);
  
          //         pos   limit
          // [ ......BBBBBBB.........]
          shuffled.limit(shuffled.position() + numProcessed);
          return numProcessed;
      }
docs: Convert the input bit-shuffled byte array into an original array. The result is dumped
  to the specified output buffer.
  
  @param shuffled buffer[pos() ... limit()) containing the input shuffled data
  @param type element type of the input data
  @param output output of the the original data. It uses buffer[pos()..]
  @return byte size of the unshuffled data.
  @throws IOException when failed to unshuffle the given input
  @throws SnappyError when the input is not a direct buffer
  @throws IllegalArgumentException when the length of input shuffled data is not a multiple of the given type size