// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq %rdx, 0x10(%rsp)
testq %rdi, %rdi
je 0x28e425
testq %r9, %r9
je 0x28e425
movq %rcx, %rax
testq %rcx, %rcx
je 0x28e3de
movq %rsi, %rcx
shrq $0x3, %rcx
andl $0x7, %esi
addq %rcx, %rdi
pushq $0x8
popq %rbp
testl %esi, %esi
je 0x28e311
movl %ebp, %r10d
subl %esi, %r10d
cmpq %rax, %r10
movq %rax, %rsi
cmovbq %r10, %rsi
subl %esi, %r10d
pushq $-0x1
popq %r14
movl %esi, %ecx
shll %cl, %r14d
notl %r14d
movl %r10d, %ecx
shlq %cl, %r14
movzbl (%rdi), %ecx
incq %rdi
andl %ecx, %r14d
movl %r10d, %ecx
shrq %cl, %r14
subq %rsi, %rax
jmp 0x28e316
xorl %r14d, %r14d
xorl %esi, %esi
pushq $0x40
popq %rdx
pushq $-0x1
popq %rbx
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r8, 0x8(%rsp)
cmpq 0x10(%rsp), %r13
jae 0x28e3de
movl (%r8,%r13,4), %r11d
cmpl %r11d, %esi
jae 0x28e39a
testq %rax, %rax
je 0x28e39a
movl %edx, %ecx
subl %esi, %ecx
movl %ebp, %r10d
subl %r12d, %r10d
cmpl %r10d, %ecx
cmovbl %ecx, %r10d
cmpq %r10, %rax
cmovbq %rax, %r10
movq %rbx, %r15
movl %r10d, %ecx
shlq %cl, %r15
shlq %cl, %r14
movzbl (%rdi), %r8d
addl %r10d, %r12d
movb $0x8, %cl
subb %r12b, %cl
shrl %cl, %r8d
notl %r15d
andl %r15d, %r8d
orq %r8, %r14
addl %r10d, %esi
subq %r10, %rax
xorl %ecx, %ecx
cmpl $0x8, %r12d
sete %cl
movl $0x0, %r8d
cmovel %r8d, %r12d
addq %rcx, %rdi
jmp 0x28e336
movq 0x8(%rsp), %r8
cmpq 0x10(%rsp), %r13
jae 0x28e327
movl (%r8,%r13,4), %ecx
cmpl %ecx, %esi
jb 0x28e327
cmpl $0x41, %ecx
jae 0x28e3ed
movq %rbx, %r11
shlq %cl, %r11
cmpq $0x40, %rcx
notq %r11
cmoveq %rbx, %r11
subl %ecx, %esi
movq %r14, %r10
movl %esi, %ecx
shrq %cl, %r10
andq %r11, %r10
movq %r10, (%r9,%r13,8)
incq %r13
jmp 0x28e39f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a9b74(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x56c15(%rip), %rsi     # 0x2e5013
leaq 0xec994(%rip), %rdx     # 0x37ad99
leaq 0xecc5d(%rip), %rcx     # 0x37b069
leaq 0xecc0d(%rip), %r8      # 0x37b020
movl $0x114, %r9d            # imm = 0x114
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x1a9b3c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x56bdd(%rip), %rsi     # 0x2e5013
leaq 0xec936(%rip), %rdx     # 0x37ad73
leaq 0xecc25(%rip), %rcx     # 0x37b069
leaq 0xecbd5(%rip), %r8      # 0x37b020
movl $0xeb, %r9d
jmp 0x28e419