code: public static final void writeBits(int[] out, int val, int outOffset,
                  int bits) {
                  if (bits == 0)
                          return;
                  final int index = outOffset >>> 5;
                  final int skip = outOffset & 0x1f;
                  val &= (0xffffffff >>> (32 - bits));
                  out[index] |= (val << skip);
                  if (32 - skip < bits) {
                          out[index + 1] |= (val >>> (32 - skip));
                  }
          }
docs: Write a certain number of bits of an integer into an integer array
  starting from the given start offset
  
  @param out
  the output array
  @param val
  the integer to be written
  @param outOffset
  the start offset in bits in the output array
  @param bits
  the number of bits to be written (bits greater or equal to 0)