// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
testq %rdi, %rdi
je 0xde61c
testq %r9, %r9
je 0xde61c
movq %rcx, %rax
testq %rcx, %rcx
je 0xde608
movq %rsi, %rcx
shrq $0x3, %rcx
andl $0x7, %esi
addq %rcx, %rdi
testl %esi, %esi
je 0xde52e
movl $0x8, %r10d
subl %esi, %r10d
cmpq %rax, %r10
movq %rax, %rsi
cmovbq %r10, %rsi
subl %esi, %r10d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %esi, %ecx
shll %cl, %ebp
notl %ebp
movl %r10d, %ecx
shlq %cl, %rbp
movzbl (%rdi), %ecx
incq %rdi
andl %ecx, %ebp
movl %r10d, %ecx
shrq %cl, %rbp
subq %rsi, %rax
jmp 0xde532
xorl %ebp, %ebp
xorl %esi, %esi
testq %rdx, %rdx
je 0xde608
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
movl (%r8,%r14,4), %r10d
cmpl %r10d, %esi
jae 0xde5b1
testq %rax, %rax
je 0xde5b1
movq %rdi, %r12
movl $0x40, %ecx
subl %esi, %ecx
movl $0x8, %edi
subl %r15d, %edi
cmpl %edi, %ecx
cmovbl %ecx, %edi
cmpq %rdi, %rax
cmovbq %rax, %rdi
movq $-0x1, %r13
movl %edi, %ecx
shlq %cl, %r13
movq %rbp, %r11
shlq %cl, %r11
movzbl (%r12), %ebp
addl %edi, %r15d
movb $0x8, %cl
subb %r15b, %cl
shrl %cl, %ebp
notl %r13d
andl %r13d, %ebp
orq %r11, %rbp
addl %edi, %esi
subq %rdi, %rax
xorl %edi, %edi
cmpl $0x8, %r15d
sete %dil
cmovel %ebx, %r15d
addq %r12, %rdi
jmp 0xde547
cmpq %rdx, %r14
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jae 0xde5ff
movl (%r8,%r14,4), %r10d
cmpl %r10d, %esi
jb 0xde5ff
cmpl $0x21, %r10d
jae 0xde617
movq $-0x1, %r11
movl %r10d, %ecx
shlq %cl, %r11
subl %r10d, %esi
movq %rbp, %r12
movl %esi, %ecx
shrq %cl, %r12
cmpq $0x20, %r10
notl %r11d
cmovel %r13d, %r11d
andl %r11d, %r12d
movl %r12d, (%r9,%r14,4)
incq %r14
cmpq %r14, %rdx
jne 0xde5bc
jmp 0xde608
cmpq %rdx, %r14
jb 0xde543
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x33e40
callq 0x33e07