// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/core/bitpackstringop64.c
// Function: gt_bsGetNonUniformInt64Array
void
gt_bsGetNonUniformInt64Array(
  constBitString str, BitOffset offset, size_t numValues,
  BitOffset numBitsTotal, unsigned numBitsList[], int64_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 = (numBits < 64)
          ? ~((~(GtUint64)0) << numBits) : ~(GtUint64)0;
        int64_t m = (int64_t)1 << (numBits - 1);
        gt_assert(numBits <= sizeof (val[0])*CHAR_BIT);
        val[j++] = ((((accum >> (bitsInAccum - numBits)) & valMask)
                              ^ m) - m);
        bitsInAccum -= numBits;
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2fd254
testq %r9, %r9
je 0x2fd254
movq %rcx, %rax
testq %rcx, %rcx
je 0x2fd240
movq %rsi, %rcx
shrq $0x3, %rcx
andl $0x7, %esi
addq %rcx, %rdi
testl %esi, %esi
je 0x2fd150
movl $0x8, %r10d
subl %esi, %r10d
cmpq %rax, %r10
movq %rax, %rsi
cmovbq %r10, %rsi
subl %esi, %r10d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %esi, %ecx
shll %cl, %r15d
notl %r15d
movl %r10d, %ecx
shlq %cl, %r15
movzbl (%rdi), %ecx
incq %rdi
andl %ecx, %r15d
movl %r10d, %ecx
shrq %cl, %r15
subq %rsi, %rax
jmp 0x2fd155
xorl %r15d, %r15d
xorl %esi, %esi
testq %rdx, %rdx
je 0x2fd240
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %ebp, %ebp
movl (%r8,%r12,4), %r10d
cmpl %r10d, %esi
jae 0x2fd1d1
testq %rax, %rax
je 0x2fd1d1
movq %rdi, %r11
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 %r15, %rbx
shlq %cl, %rbx
movzbl (%r11), %r15d
addl %edi, %ebp
movb $0x8, %cl
subb %bpl, %cl
shrl %cl, %r15d
notl %r13d
andl %r13d, %r15d
orq %rbx, %r15
addl %edi, %esi
subq %rdi, %rax
xorl %edi, %edi
cmpl $0x8, %ebp
sete %dil
cmovel %r14d, %ebp
addq %r11, %rdi
jmp 0x2fd16a
cmpq %rdx, %r12
jae 0x2fd237
movl (%r8,%r12,4), %r10d
cmpl %r10d, %esi
jb 0x2fd237
cmpl $0x41, %r10d
jae 0x2fd24f
leal -0x1(%r10), %r11d
movl $0x1, %ebx
movl %r11d, %ecx
shlq %cl, %rbx
movq $-0x1, %r13
movl %r10d, %ecx
shlq %cl, %r13
cmpq $0x40, %r10
notq %r13
movq $-0x1, %rcx
cmoveq %rcx, %r13
subl %r10d, %esi
movq %r15, %r10
movl %esi, %ecx
shrq %cl, %r10
andq %r13, %r10
btcq %r11, %r10
subq %rbx, %r10
movq %r10, (%r9,%r12,8)
incq %r12
cmpq %r12, %rdx
jne 0x2fd1d6
movq %rdx, %r12
cmpq %rdx, %r12
jb 0x2fd166
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x89c9e
callq 0x89c65