// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/core/bitpackstringop32.c
// Function: gt_bsGetNonUniformUInt32Array
void
gt_bsGetNonUniformUInt32Array(
  constBitString str, BitOffset offset, size_t numValues,
  BitOffset numBitsTotal, unsigned numBitsList[], uint32_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;
  GtUword 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)
  {
    GtUword mask; /*< all of the bits we want to get from *p */
    unsigned bits2Read = GT_MIN(bitElemBits - bitTop, totalBitsLeft);
    unsigned unreadRightBits = (bitElemBits - bitTop - bits2Read);
    mask = (~((~(GtUword)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;
      GtUword mask;
      bits2Read = GT_MIN3(bitsFree, bitElemBits - bitsRead, totalBitsLeft);
      mask = (~((~(GtUword)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]))
      {
        GtUword valMask;
        gt_assert(numBits <= sizeof (val[0])*CHAR_BIT);
        valMask = ~(GtUword)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 %r8, (%rsp)
movq %rdx, 0x8(%rsp)
testq %rdi, %rdi
je 0xc7096
testq %r9, %r9
je 0xc7096
movq %rcx, %rax
movq %r9, 0x10(%rsp)
testq %rcx, %rcx
je 0xc704f
movq %rsi, %rcx
shrq $0x3, %rcx
andl $0x7, %esi
addq %rcx, %rdi
pushq $0x8
popq %rbx
pushq $-0x1
popq %rcx
testl %esi, %esi
je 0xc6f6a
movl %ebx, %r10d
subl %esi, %r10d
cmpq %rax, %r10
movq %rax, %rsi
cmovbq %r10, %rsi
subl %esi, %r10d
movl %ecx, %edx
movl %ecx, %r14d
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 0xc6f71
movl %ecx, %edx
xorl %r14d, %r14d
xorl %esi, %esi
pushq $0x40
popq %r15
pushq $-0x1
popq %r9
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpq 0x8(%rsp), %rbp
jae 0xc704f
movq (%rsp), %rcx
movl (%rcx,%rbp,4), %r11d
cmpl %r11d, %esi
jae 0xc7032
testq %rax, %rax
je 0xc7032
movl %r15d, %ecx
subl %esi, %ecx
movl %ebx, %r10d
subl %r13d, %r10d
cmpl %r10d, %ecx
cmovbl %ecx, %r10d
cmpq %r10, %rax
cmovbq %rax, %r10
movq %r9, %r12
movl %r10d, %ecx
shlq %cl, %r12
shlq %cl, %r14
movzbl (%rdi), %r8d
addl %r10d, %r13d
movb $0x8, %cl
subb %r13b, %cl
shrl %cl, %r8d
notl %r12d
andl %r12d, %r8d
orq %r8, %r14
addl %r10d, %esi
subq %r10, %rax
xorl %ecx, %ecx
cmpl $0x8, %r13d
sete %cl
movl $0x0, %r8d
cmovel %r8d, %r13d
addq %rcx, %rdi
jmp 0xc6f91
cmpl $0x21, %r10d
jae 0xc705e
movq %r9, %r8
movl %r10d, %ecx
shlq %cl, %r8
subl %r10d, %esi
movq %r14, %r11
movl %esi, %ecx
shrq %cl, %r11
cmpq $0x20, %r10
notl %r8d
cmovel %edx, %r8d
andl %r8d, %r11d
movq 0x10(%rsp), %rcx
movl %r11d, (%rcx,%rbp,4)
incq %rbp
cmpq 0x8(%rsp), %rbp
jae 0xc6f7e
movq (%rsp), %rcx
movl (%rcx,%rbp,4), %r10d
cmpl %r10d, %esi
jae 0xc6ffe
jmp 0xc6f7e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x66f53(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x2ff7(%rip), %rsi      # 0xca066
leaq 0x2e2d7(%rip), %rdx     # 0xf534d
leaq 0x2e2f4(%rip), %rcx     # 0xf5371
leaq 0x2e223(%rip), %r8      # 0xf52a7
movl $0x114, %r9d            # imm = 0x114
xorl %eax, %eax
callq 0xb8c0
callq 0xb300
movq 0x66f1b(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x2fbf(%rip), %rsi      # 0xca066
leaq 0x2e279(%rip), %rdx     # 0xf5327
leaq 0x2e2bc(%rip), %rcx     # 0xf5371
leaq 0x2e1eb(%rip), %r8      # 0xf52a7
movl $0xeb, %r9d
jmp 0xc708a