Unpack 32 integers

@param in
source array
@param inpos
position in source array
@param out
output array
@param outpos
position in output array
@param bit
number of bits to use per integer
431993
public static void fastpackwithoutmask(final int[] in, final int inpos,
                final int[] out, final int outpos, final int bit) {
                switch (bit) {
                case 0:
                        fastpackwithoutmask0(in, inpos, out, outpos);
                        break;
                case 1:
                        fastpackwithoutmask1(in, inpos, out, outpos);
                        break;
                case 2:
                        fastpackwithoutmask2(in, inpos, out, outpos);
                        break;
                case 3:
                        fastpackwithoutmask3(in, inpos, out, outpos);
                        break;
                case 4:
                        fastpackwithoutmask4(in, inpos, out, outpos);
                        break;
                case 5:
                        fastpackwithoutmask5(in, inpos, out, outpos);
                        break;
                case 6:
                        fastpackwithoutmask6(in, inpos, out, outpos);
                        break;
                case 7:
                        fastpackwithoutmask7(in, inpos, out, outpos);
                        break;
                case 8:
                        fastpackwithoutmask8(in, inpos, out, outpos);
                        break;
                case 9:
                        fastpackwithoutmask9(in, inpos, out, outpos);
                        break;
                case 10:
                        fastpackwithoutmask10(in, inpos, out, outpos);
                        break;
                case 11:
                        fastpackwithoutmask11(in, inpos, out, outpos);
                        break;
                case 12:
                        fastpackwithoutmask12(in, inpos, out, outpos);
                        break;
                case 13:
                        fastpackwithoutmask13(in, inpos, out, outpos);
                        break;
                case 14:
                        fastpackwithoutmask14(in, inpos, out, outpos);
                        break;
                case 15:
                        fastpackwithoutmask15(in, inpos, out, outpos);
                        break;
                case 16:
                        fastpackwithoutmask16(in, inpos, out, outpos);
                        break;
                case 17:
                        fastpackwithoutmask17(in, inpos, out, outpos);
                        break;
                case 18:
                        fastpackwithoutmask18(in, inpos, out, outpos);
                        break;
                case 19:
                        fastpackwithoutmask19(in, inpos, out, outpos);
                        break;
                case 20:
                        fastpackwithoutmask20(in, inpos, out, outpos);
                        break;
                case 21:
                        fastpackwithoutmask21(in, inpos, out, outpos);
                        break;
                case 22:
                        fastpackwithoutmask22(in, inpos, out, outpos);
                        break;
                case 23:
                        fastpackwithoutmask23(in, inpos, out, outpos);
                        break;
                case 24:
                        fastpackwithoutmask24(in, inpos, out, outpos);
                        break;
                case 25:
                        fastpackwithoutmask25(in, inpos, out, outpos);
                        break;
                case 26:
                        fastpackwithoutmask26(in, inpos, out, outpos);
                        break;
                case 27:
                        fastpackwithoutmask27(in, inpos, out, outpos);
                        break;
                case 28:
                        fastpackwithoutmask28(in, inpos, out, outpos);
                        break;
                case 29:
                        fastpackwithoutmask29(in, inpos, out, outpos);
                        break;
                case 30:
                        fastpackwithoutmask30(in, inpos, out, outpos);
                        break;
                case 31:
                        fastpackwithoutmask31(in, inpos, out, outpos);
                        break;
                case 32:
                        fastpackwithoutmask32(in, inpos, out, outpos);
                        break;
                default:
                        throw new IllegalArgumentException(
                                "Unsupported bit width.");
                }
        }
897147
public static void convertSixBitToBits(String str, int padBits, boolean bitSet[],
	        boolean[] calculated, int from, int to) {
		if (str.length() == 0)
			return;
		int index = from - from % 6;
		int strFrom = from / 6;
		int slen = str.length() - 1;
		int strTo = to / 6 + 1;
		for (int i = strFrom; i < Math.min(strTo, slen); i++) {
			if (!calculated[i]) {
				char chr = str.charAt(i);
				int binVal = INT_TO_SIX_BIT[chr];
				if (binVal == -1) {
					throw new SixBitException("Illegal sixbit ascii char: " + chr);
				}
				bitSet[index] = (binVal & 32) > 0;
				bitSet[index + 1] = (binVal & 16) > 0;
				bitSet[index + 2] = (binVal & 8) > 0;
				bitSet[index + 3] = (binVal & 4) > 0;
				bitSet[index + 4] = (binVal & 2) > 0;
				bitSet[index + 5] = (binVal & 1) > 0;

				calculated[i] = true;
			}

			index += 6;
		}
		if (strTo > slen) {
			// Process the last char which might be padded
			char chr = str.charAt(slen);
			int binVal = INT_TO_SIX_BIT[chr];
			if (binVal == -1) {
				throw new SixBitException("Illegal sixbit ascii char: " + chr);
			}
			int bits = 6 - padBits;

			switch (bits) {
			case 6:
				bitSet[index + 5] = (binVal & 1) > 0;
			case 5:
				bitSet[index + 4] = (binVal & 2) > 0;
			case 4:
				bitSet[index + 3] = (binVal & 4) > 0;
			case 3:
				bitSet[index + 2] = (binVal & 8) > 0;
			case 2:
				bitSet[index + 1] = (binVal & 16) > 0;
			case 1:
				bitSet[index] = (binVal & 32) > 0;
			}

			calculated[slen] = true;
		}
	}
723651
def unpack_bits( byte ):
    """"""
    longbits = byte & (0x00000000000000ff)
    longbits = (longbits | (longbits<<28)) & (0x0000000f0000000f)
    longbits = (longbits | (longbits<<14)) & (0x0003000300030003)
    longbits = (longbits | (longbits<<7)) & (0x0101010101010101)
    return longbits
1029194
static public int unpackInt(DataInput is)
      throws IOException {
    for (int offset = 0, result = 0; offset < 32; offset += 7) {
      int b = is.readUnsignedByte();
      result |= (b & 0x7F) << offset;
      if ((b & 0x80) == 0) {
        return result;
      }
    }
    throw new Error("Malformed integer.");
  }
228983
private void writeUShort(int pos, int s) {
        byte b1 = (byte)((s >> 8) & 0xff);
        byte b2 = (byte)(s & 0xff);
        output[pos] = b1;
        output[pos + 1] = b2;
    }
261208
public final static void writeMediumInt(ByteBuffer out, int value) {
        out.put((byte) ((value >>> 16) & 0xff));
        out.put((byte) ((value >>> 8) & 0xff));
        out.put((byte) (value & 0xff));
    }
1367136
public static int decodeTo(final byte[] output, int outOffset,
            final byte[] input, int inOffset, final int inLen)
    {
        if (inLen == 0)
            return 0;

        if (inLen % 4 != 0)
            throw new IllegalArgumentException("Input block size is not 4");

        int withoutPaddingLen = inLen, limit = inOffset + inLen;
        while (input[--limit] == pad)
            withoutPaddingLen--;

        // Create result array of exact required size.
        final int outLen = ((withoutPaddingLen) * 3) / 4;
        assert (output.length - outOffset) >= outLen;

        decode(input, inOffset, inLen, output, outOffset, outLen);

        return outLen;
    }
915331
static public int unpackInt(InputStream in) throws IOException {
        int ret = 0;
        int v;
        do{
            v = in.read();
            if(v==-1)
                throw new EOFException();
            ret = (ret<<7 ) | (v & 0x7F);
        }while((v&0x80)==0);

        return ret;
    }
272834
@Override
    public long convert(int[] input, int inPos) {
        int Y = input[inPos++] & 0xFF;
        int Cb = input[inPos++] & 0xFF;
        int Cr = input[inPos] & 0xFF;

        byte r = (byte) sampleRangeLimitTable[sampleRangeLimitOffset + Y + Cr2R[Cr]];
        byte g = (byte) sampleRangeLimitTable[sampleRangeLimitOffset + Y + ((Cb2G[Cb] + Cr2G[Cr]) >> 16)];

        byte b = (byte) sampleRangeLimitTable[sampleRangeLimitOffset + Y + Cb2B[Cb]];

        return (0xFF000000L | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF));
    }
375538
static public int unpackInt(ByteBuffer bb)
      throws IOException {
    for (int offset = 0, result = 0; offset < 32; offset += 7) {
      int b = bb.get() & 0xffff;
      result |= (b & 0x7F) << offset;
      if ((b & 0x80) == 0) {
        return result;
      }
    }
    throw new Error("Malformed integer.");
  }
781454
def _in(ins):
    
    output = _16bit_oper(ins.quad[1])
    output.append('ld b, h')
    output.append('ld c, l')
    output.append('in a, (c)')
    output.append('push af')

    return output
92451
private static void encode(final byte[] input, int inOffset, final int inLen,
            final byte[] output, int outOffset)
    {
        byte b0, b1, b2;
        final int remaining = inLen % 3, stop = inOffset + (inLen - remaining);
        while (inOffset < stop)
        {
            b0 = input[inOffset++];
            b1 = input[inOffset++];
            b2 = input[inOffset++];
            output[outOffset++] = nibble2code[(b0 >>> 2) & 0x3f];
            output[outOffset++] = nibble2code[(b0 << 4) & 0x3f | (b1 >>> 4) & 0x0f];
            output[outOffset++] = nibble2code[(b1 << 2) & 0x3f | (b2 >>> 6) & 0x03];
            output[outOffset++] = nibble2code[b2 & 077];
        }

        switch (remaining)
        {
            case 0:
                break;
            case 1:
                b0 = input[inOffset++];
                output[outOffset++] = nibble2code[(b0 >>> 2) & 0x3f];
                output[outOffset++] = nibble2code[(b0 << 4) & 0x3f];
                output[outOffset++] = pad;
                output[outOffset++] = pad;
                break;
            case 2:
                b0 = input[inOffset++];
                b1 = input[inOffset++];
                output[outOffset++] = nibble2code[(b0 >>> 2) & 0x3f];
                output[outOffset++] = nibble2code[(b0 << 4) & 0x3f | (b1 >>> 4) & 0x0f];
                output[outOffset++] = nibble2code[(b1 << 2) & 0x3f];
                output[outOffset++] = pad;
                break;

            default:
                throw new IllegalStateException("should not happen");
        }
    }
642697
static private byte[] toBytes(
        Vector  octs)
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();

        for (int i = 0; i != octs.size(); i++)
        {
            DEROctetString  o = (DEROctetString)octs.elementAt(i);

            try
            {
                bOut.write(o.getOctets());
            }
            catch (IOException e)
            {
                throw new RuntimeException("exception converting octets " + e.toString());
            }
        }

        return bOut.toByteArray();
    }
922409
public final byte[] decode(String in) {

        // sanitize the parameters
        if (in == null) {
            throw new NullPointerException();
        }

        // create the result buffer
        byte[] out = new byte[in.length() * bits / 8];

        // decode
        int outCount = 0; // number of output bytes produced
        int inCount = 0; // number of input characters consumed
        int buf = 0; // buffer of input bits not yet sent to output
        int bufBits = 0; // number of bits in the bit buffer
        while (inCount < in.length()) {
            int next = in.codePointAt(inCount);
            inCount++;
            if (next < min || next > max) {
                continue;
            }
            next = values[next - min];
            if (next == -1) {
                continue;
            }
            buf = (buf << bits) | next;
            bufBits += bits;
            while (bufBits >= 8) {
                out[outCount] = (byte) ((buf >>> (bufBits - 8)) & 0xff);
                bufBits -= 8;
                outCount++;
            }
        }

        // trim the result if there were any skipped characters
        if (outCount < out.length) {
            byte[] tmp = out;
            out = new byte[outCount];
            System.arraycopy(tmp, 0, out, 0, outCount);
        }
        return out;
    }
422998
public final long getUlong48(final int pos) {
        final int position = origin + pos;

        if (pos + 5 >= limit || pos < 0) throw new IllegalArgumentException("limit excceed: "
                                                                            + (pos < 0 ? pos : (pos + 5)));

        byte[] buf = buffer;
        return ((long) (0xff & buf[position])) | ((long) (0xff & buf[position + 1]) << 8)
               | ((long) (0xff & buf[position + 2]) << 16) | ((long) (0xff & buf[position + 3]) << 24)
               | ((long) (0xff & buf[position + 4]) << 32) | ((long) (0xff & buf[position + 5]) << 40);
    }
815825
private static void encodeInteger(ByteBuf out, int mask, int n, long i) {
        assert n >= 0 && n <= 8 : "N: " + n;
        int nbits = 0xFF >>> (8 - n);
        if (i < nbits) {
            out.writeByte((int) (mask | i));
        } else {
            out.writeByte(mask | nbits);
            long length = i - nbits;
            for (; (length & ~0x7F) != 0; length >>>= 7) {
                out.writeByte((int) ((length & 0x7F) | 0x80));
            }
            out.writeByte((int) length);
        }
    }
983460
private List<File> unzipCorpus(File outDir, ZipFile zip)
  {
    List<File> rootDirs = new ArrayList<>();

    Enumeration<? extends ZipEntry> zipEnum = zip.entries();
    while (zipEnum.hasMoreElements())
    {
      ZipEntry e = zipEnum.nextElement();
      File outFile = new File(outDir, e.getName().replaceAll("\\/", "/"));

      if (e.isDirectory())
      {
        if (!outFile.mkdirs())
        {
          log.warn("Could not create output directory " + outFile.
            getAbsolutePath());
        }
      } // end if directory
      else
      {
        if ("corpus.tab".equals(outFile.getName()) || "corpus.annis".equals(
          outFile.getName()))
        {
          rootDirs.add(outFile.getParentFile());
        }

        if (!outFile.getParentFile().isDirectory())
        {
          if (!outFile.getParentFile().mkdirs())
          {
            {
              log.warn(
                "Could not create output directory for file " + outFile.
                getAbsolutePath());
            }
          }
        }
        try (FileOutputStream outStream = new FileOutputStream(outFile);)
        {

          ByteStreams.copy(zip.getInputStream(e), outStream);
        }
        catch (FileNotFoundException ex)
        {
          log.error(null, ex);
        }
        catch (IOException ex)
        {
          log.error(null, ex);
        }
      } // end else is file
    } // end for each entry in zip file

    return rootDirs;
  }