/*
Unpacks an unsigned multi-precision integer, stored as an array of 31-bit
limbs in little-endian order (least significant limb first), into an array
of 32-bit words (a Uint32Array) in big-endian order (most significant word
first).
348216
function mpn_unpack(n) {
	var k = n.length, words = new Uint32Array(Math.floor(k * 31 / 32)), l, lr = 0, w = 0, wr = 32;
	for (var i = 0, j = 0;;) {
		if (lr == 0) {
			if (i >= k) {
				if (w != 0) {
					words[words.length - ++j] = w >>> wr;
				}
				return words;
			}
			l = n[i++], lr = 31;
		}
		var s = Math.min(lr, wr);
		w = w >>> s | (l & (1 << s) - 1) << 32 - s, l >>>= s;
		if ((wr -= s) == 0) {
			words[words.length - ++j] = w;
			w = 0, wr = 32;
		}
		lr -= s;
	}
}
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
360997
def _unpack_int_base128(varint, offset):
        """"""
        res = ord(varint[offset])
        if ord(varint[offset]) >= 0x80:
            offset += 1
            res = ((res - 0x80) << 7) + ord(varint[offset])
            if ord(varint[offset]) >= 0x80:
                offset += 1
                res = ((res - 0x80) << 7) + ord(varint[offset])
                if ord(varint[offset]) >= 0x80:
                    offset += 1
                    res = ((res - 0x80) << 7) + ord(varint[offset])
                    if ord(varint[offset]) >= 0x80:
                        offset += 1
                        res = ((res - 0x80) << 7) + ord(varint[offset])
        return res, offset + 1
951249
function cpy32 (d, s) {
        for (var i = 0; i < 32; i++)
            d[i] = s[i];
    }
925922
def unpack(str)
      str.bytes.reverse.reduce(0) { |s, c| s * 256 + c }
    end
794511
public static boolean[] unpack(int[] packed, int length) {
    boolean[] bools = new boolean[length];
    for (int i = 0; i < length; ++i) {
      bools[i] = (packed[i >> 5] & (1 << (i & 0x1f))) != 0;
    }
    return bools;
  }
345393
function __deserializeUInt32(buffer, start, options) {
	let end = start + 4;
	let dataView = new DataView(buffer);
	let data = dataView.getUint32(start, true);
	return { anchor: end, value:options.use_native_types ? data : UInt32.from(data) };
}
650208
function unpack(multibuffer) {
  var buffs = []
  var offset = 0
  var length

  while (offset < multibuffer.length) {
    length = vdecode(multibuffer.slice(offset))
    offset += vdecode.bytes
    buffs.push(multibuffer.slice(offset, offset + length))
    offset += length
  }

  return buffs
}
1123405
function bytes_to_int32(arr, off) {
        return (arr[off + 3] << 24) | (arr[off + 2] << 16) | (arr[off + 1] << 8) | (arr[off])
    }
217434
function(encoded) {
      if (encoded instanceof Array) {
        encoded = encoded.map(function(chunk) {return chunk.replace(/^0x/g, '')}).join('');
      }

      // Each symbol is 4 bits
      var result = [];
      var nextIndex = 0;
      while (nextIndex < encoded.length) {
        var schemaLength = parseInt(encoded.slice(nextIndex, nextIndex + 1 * 2), 16);
        var idLength = parseInt(encoded.slice(nextIndex + (1 + schemaLength) * 2, nextIndex + (1 + schemaLength + 2) * 2), 16);

        var schema = encoded.slice(nextIndex + 1 * 2, nextIndex + (1 + schemaLength) * 2);
        // Convert to string
        schema = hexToString(schema);
        var idHex = encoded.slice(nextIndex + (1 + schemaLength + 2) * 2, nextIndex + (1 + schemaLength + 2 + idLength) * 2);
        var id = schema.match(allowedProtocolsRegExp) ? idHex : hexToString(idHex);
        result.push(schema + ':' + id);

        // Get full cells
        var cellsPerId = Math.ceil((1 + schemaLength + 2 + idLength) / 32);
        nextIndex += cellsPerId * 32 * 2;
      }

      return result;
    }
470166
public BigInteger unpackBigInteger()
            throws IOException
    {
        byte b = readByte();
        if (Code.isFixInt(b)) {
            return BigInteger.valueOf((long) b);
        }
        switch (b) {
            case Code.UINT8: // unsigned int 8
                byte u8 = readByte();
                return BigInteger.valueOf((long) (u8 & 0xff));
            case Code.UINT16: // unsigned int 16
                short u16 = readShort();
                return BigInteger.valueOf((long) (u16 & 0xffff));
            case Code.UINT32: // unsigned int 32
                int u32 = readInt();
                if (u32 < 0) {
                    return BigInteger.valueOf((long) (u32 & 0x7fffffff) + 0x80000000L);
                }
                else {
                    return BigInteger.valueOf((long) u32);
                }
            case Code.UINT64: // unsigned int 64
                long u64 = readLong();
                if (u64 < 0L) {
                    BigInteger bi = BigInteger.valueOf(u64 + Long.MAX_VALUE + 1L).setBit(63);
                    return bi;
                }
                else {
                    return BigInteger.valueOf(u64);
                }
            case Code.INT8: // signed int 8
                byte i8 = readByte();
                return BigInteger.valueOf((long) i8);
            case Code.INT16: // signed int 16
                short i16 = readShort();
                return BigInteger.valueOf((long) i16);
            case Code.INT32: // signed int 32
                int i32 = readInt();
                return BigInteger.valueOf((long) i32);
            case Code.INT64: // signed int 64
                long i64 = readLong();
                return BigInteger.valueOf(i64);
        }
        throw unexpected("Integer", b);
    }
193864
function uint16BEtoNumber(bytes) {
  var n = 0;
  for (var i = 0; i < 1; i++) {
    n |= bytes[i];
    n <<= 8;
  }
  n |= bytes[1];
  return n;
}
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.");
  }
910919
int unpack(Buffer opb) {
        int i;
    //memset(s,0,sizeof(static_codebook));

        // make sure alignment is correct
        if (opb.read(24) != 0x564342) {
            //    goto _eofout;
            clear();
            return (-1);
        }

        // first the basic parameters
        dim = opb.read(16);
        entries = opb.read(24);
        if (entries == -1) {
            //    goto _eofout;
            clear();
            return (-1);
        }

        // codeword ordering.... length ordered or unordered?
        switch (opb.read(1)) {
            case 0:
                // unordered
                lengthlist = new int[entries];

                // allocated but unused entries?
                if (opb.read(1) != 0) {
                    // yes, unused entries

                    for (i = 0; i < entries; i++) {
                        if (opb.read(1) != 0) {
                            int num = opb.read(5);
                            if (num == -1) {
                                //            goto _eofout;
                                clear();
                                return (-1);
                            }
                            lengthlist[i] = num + 1;
                        } else {
                            lengthlist[i] = 0;
                        }
                    }
                } else {
                    // all entries used; no tagging
                    for (i = 0; i < entries; i++) {
                        int num = opb.read(5);
                        if (num == -1) {
                            //          goto _eofout;
                            clear();
                            return (-1);
                        }
                        lengthlist[i] = num + 1;
                    }
                }
                break;
            case 1: // ordered
            {
                int length = opb.read(5) + 1;
                lengthlist = new int[entries];

                for (i = 0; i < entries;) {
                    int num = opb.read(Util.ilog(entries - i));
                    if (num == -1) {
                        //          goto _eofout;
                        clear();
                        return (-1);
                    }
                    for (int j = 0; j < num; j++, i++) {
                        lengthlist[i] = length;
                    }
                    length++;
                }
            }
            break;
            default:
                // EOF
                return (-1);
        }

        // Do we have a mapping to unpack?
        switch ((maptype = opb.read(4))) {
            case 0:
                // no mapping
                break;
            case 1:
            case 2:
                // implicitly populated value mapping
                // explicitly populated value mapping
                q_min = opb.read(32);
                q_delta = opb.read(32);
                q_quant = opb.read(4) + 1;
                q_sequencep = opb.read(1);

                 {
                    int quantvals = 0;
                    switch (maptype) {
                        case 1:
                            quantvals = maptype1_quantvals();
                            break;
                        case 2:
                            quantvals = entries * dim;
                            break;
                    }

                    // quantized values
                    quantlist = new int[quantvals];
                    for (i = 0; i < quantvals; i++) {
                        quantlist[i] = opb.read(q_quant);
                    }
                    if (quantlist[quantvals - 1] == -1) {
                        //        goto _eofout;
                        clear();
                        return (-1);
                    }
                }
                break;
            default:
                //    goto _eofout;
                clear();
                return (-1);
        }
        // all set
        return (0);
        //    _errout:
        //    _eofout:
        //    vorbis_staticbook_clear(s);
        //    return(-1); 
    }
505187
function intToBytes(num) {
	var bytes = [];

	for(var i=7 ; i>=0 ; --i) {
		bytes[i] = num & (255);
		num = num >> 8;
	}

	return bytes;
}
630962
function getUint32(buffer, offset, littleEndian) {
    var a;
    var b;
    var c;
    var d;
    if (littleEndian) {
        a = buffer[offset];
        b = buffer[offset + 1];
        c = buffer[offset + 2];
        d = buffer[offset + 3];
    }
    else {
        a = buffer[offset + 3];
        b = buffer[offset + 2];
        c = buffer[offset + 1];
        d = buffer[offset];
    }
    return ((d << 24) >>> 0) + ((c << 16) | (b << 8) | a);
}
229242
private static int intFromSubArray(final byte[] bytes, final int from, final int to) {
    final byte[] subBytes = Arrays.copyOfRange(bytes, from, to);
    final ByteBuffer wrap = ByteBuffer.wrap(subBytes);
    return wrap.getInt();
  }