// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/core/bitpackstringop64.c
// Function: gt_bsGetNonUniformUInt64Array
void
gt_bsGetNonUniformUInt64Array(
  constBitString str, BitOffset offset, size_t numValues,
  BitOffset numBitsTotal, unsigned numBitsList[], uint64_t val[])
{
  /* idea: read as much as possible from str in each iteration,
   * accumulate if bitsLeft < numBits */
  size_t j = 0;
  BitOffset totalBitsLeft = numBitsTotal;
  size_t elemStart = offset/bitElemBits;
  unsigned bitTop = offset%bitElemBits,
    bitsRead = 0; /*< how many bits in current *p are read */
  const BitElem *p = str + elemStart;
  unsigned bitsInAccum = 0;
  GtUint64 accum = 0;
  gt_assert(str && val);
  /* user requested zero values, ugly but must be handled, since legal */
  if (!totalBitsLeft)
  {
    return;
  }
  /* get bits of first element if not aligned */
  if (bitTop)
  {
    GtUint64 mask; /*< all of the bits we want to get from *p */
    unsigned bits2Read = GT_MIN(bitElemBits - bitTop, totalBitsLeft);
    unsigned unreadRightBits = (bitElemBits - bitTop - bits2Read);
    mask = (~((~(GtUint64)0) << bits2Read)) << unreadRightBits;
    accum = ((*p++) & mask) >> unreadRightBits;
    bitsInAccum += bits2Read;
    totalBitsLeft -= bits2Read;
  }
  while (j < numValues)
  {
    while (bitsInAccum < numBitsList[j] && totalBitsLeft)
    {
      unsigned bits2Read, bitsFree = sizeof (accum)*CHAR_BIT - bitsInAccum;
      GtUint64 mask;
      bits2Read = GT_MIN3(bitsFree, bitElemBits - bitsRead, totalBitsLeft);
      mask = (~((~(GtUint64)0) << bits2Read));
      accum = accum << bits2Read | (((*p) >> (bitElemBits
                                              - bits2Read - bitsRead)) & mask);
      bitsInAccum += bits2Read;
      totalBitsLeft -= bits2Read;
      /* all of *p consumed? */
      if ((bitsRead += bits2Read) == bitElemBits)
      {
        ++p, bitsRead = 0;
      }
    }
    {
      unsigned numBits;
      /* now we have enough bits in accum */
      while (j < numValues && bitsInAccum >= (numBits = numBitsList[j]))
      {
        GtUint64 valMask;
        gt_assert(numBits <= sizeof (val[0])*CHAR_BIT);
        valMask = ~(GtUint64)0;
        if (numBits < (sizeof (val[0])*CHAR_BIT))
          valMask = ~(valMask << numBits);
        val[j++] = ((accum >> (bitsInAccum - numBits)) & valMask );
        bitsInAccum -= numBits;
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2fd0d3
testq %r9, %r9
je 0x2fd0d3
movq %rcx, %rax
testq %rcx, %rcx
je 0x2fd0bf
movq %rsi, %rcx
shrq $0x3, %rcx
andl $0x7, %esi
addq %rcx, %rdi
testl %esi, %esi
je 0x2fcfec
movl $0x8, %r10d
subl %esi, %r10d
cmpq %rax, %r10
movq %rax, %rsi
cmovbq %r10, %rsi
subl %esi, %r10d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %esi, %ecx
shll %cl, %ebx
notl %ebx
movl %r10d, %ecx
shlq %cl, %rbx
movzbl (%rdi), %ecx
incq %rdi
andl %ecx, %ebx
movl %r10d, %ecx
shrq %cl, %rbx
subq %rsi, %rax
jmp 0x2fcff0
xorl %ebx, %ebx
xorl %esi, %esi
testq %rdx, %rdx
je 0x2fd0bf
xorl %r10d, %r10d
xorl %r14d, %r14d
xorl %ebp, %ebp
movl (%r8,%r14,4), %r15d
cmpl %r15d, %esi
jae 0x2fd06c
testq %rax, %rax
je 0x2fd06c
movq %rdi, %r12
movl $0x40, %ecx
subl %esi, %ecx
movl $0x8, %edi
subl %ebp, %edi
cmpl %edi, %ecx
cmovbl %ecx, %edi
cmpq %rdi, %rax
cmovbq %rax, %rdi
movq $-0x1, %r13
movl %edi, %ecx
shlq %cl, %r13
movq %rbx, %r11
shlq %cl, %r11
movzbl (%r12), %ebx
addl %edi, %ebp
movb $0x8, %cl
subb %bpl, %cl
shrl %cl, %ebx
notl %r13d
andl %r13d, %ebx
orq %r11, %rbx
addl %edi, %esi
subq %rdi, %rax
xorl %edi, %edi
cmpl $0x8, %ebp
sete %dil
cmovel %r10d, %ebp
addq %r12, %rdi
jmp 0x2fd005
cmpq %rdx, %r14
movq $-0x1, %r12
jae 0x2fd0b6
movl (%r8,%r14,4), %ecx
cmpl %ecx, %esi
jb 0x2fd0b6
cmpl $0x41, %ecx
jae 0x2fd0ce
movq $-0x1, %r11
shlq %cl, %r11
cmpq $0x40, %rcx
notq %r11
cmoveq %r12, %r11
subl %ecx, %esi
movq %rbx, %r15
movl %esi, %ecx
shrq %cl, %r15
andq %r11, %r15
movq %r15, (%r9,%r14,8)
incq %r14
cmpq %r14, %rdx
jne 0x2fd078
movq %rdx, %r14
cmpq %rdx, %r14
jb 0x2fd001
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x89c2c
callq 0x89bf3