// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/core/bitpackstringop.c
// Function: gt_bs1BitsCount
BitOffset gt_bs1BitsCount(constBitString str, BitOffset offset,
                          BitOffset numBits)
{
  uint32_t accum = 0;
  BitOffset weight = 0, bitsLeft = numBits;
  unsigned bitTop = offset%bitElemBits, bitsInAccum = 0;
  size_t elemStart = offset/bitElemBits;
  const BitElem *p = str + elemStart;
  gt_assert(str);
  if (bitTop)
  {
    uint32_t mask;
    unsigned bits2Read = GT_MIN(bitElemBits - bitTop, bitsLeft);
    unsigned unreadRightBits = (bitElemBits - bitTop - bits2Read);
    mask = (~((~(uint32_t)0) << bits2Read)) << unreadRightBits;
    weight += bitCountUInt32(((*p++) & mask) >> unreadRightBits);
    bitsLeft -= bits2Read;
  }
  /* get bits from intervening elems */
  while (bitsLeft >= bitElemBits)
  {
    while (bitsLeft >= bitElemBits
           && sizeof (accum) * CHAR_BIT - bitElemBits >= bitsInAccum)
    {
      accum = accum << bitElemBits | (*p++);
      bitsLeft -= bitElemBits;
      bitsInAccum += bitElemBits;
    }
    weight += bitCountUInt32(accum);
    accum = 0; bitsInAccum = 0;
  }
  /* get bits from last elem */
  if (bitsLeft)
  {
    accum = ((*p) & ((~(uint32_t)0)<<(bitElemBits - bitsLeft)));
    weight += bitCountUInt32(accum);
  }
  return weight;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rax
andq $0x7, %rax
movl %eax, 0x34(%rsp)
movl $0x0, 0x30(%rsp)
movq 0x58(%rsp), %rax
shrq $0x3, %rax
movq %rax, 0x28(%rsp)
movq 0x60(%rsp), %rax
addq 0x28(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x470850
movq 0x1cb781(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0xa57ea(%rip), %rsi     # 0x516013
leaq 0xd382d(%rip), %rdx     # 0x54405d
leaq 0x13f482(%rip), %rcx    # 0x5afcb9
leaq 0x13f43f(%rip), %r8     # 0x5afc7d
movl $0x1c4, %r9d            # imm = 0x1C4
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x470852
cmpl $0x0, 0x34(%rsp)
je 0x4708ff
movl $0x8, %eax
subl 0x34(%rsp), %eax
movl %eax, %eax
cmpq 0x38(%rsp), %rax
jae 0x470881
movl $0x8, %eax
subl 0x34(%rsp), %eax
movl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x47088b
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl %eax, 0x18(%rsp)
movl $0x8, %eax
subl 0x34(%rsp), %eax
subl 0x18(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x18(%rsp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
xorl $-0x1, %eax
movl 0x14(%rsp), %ecx
shll %cl, %eax
movl %eax, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rsp)
movzbl (%rax), %edi
andl 0x1c(%rsp), %edi
movl 0x14(%rsp), %ecx
shrl %cl, %edi
callq 0x4709f0
movl %eax, %eax
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0x18(%rsp), %eax
movl %eax, %ecx
movq 0x38(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x38(%rsp)
jmp 0x470901
cmpq $0x8, 0x38(%rsp)
jb 0x4709a2
jmp 0x47090f
xorl %eax, %eax
cmpq $0x8, 0x38(%rsp)
movb %al, 0x7(%rsp)
jb 0x470932
movl 0x30(%rsp), %eax
movl %eax, %ecx
movl $0x18, %eax
cmpq %rcx, %rax
setae %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x47093c
jmp 0x470978
movl 0x4c(%rsp), %eax
shll $0x8, %eax
movq 0x20(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x20(%rsp)
movzbl (%rcx), %ecx
orl %ecx, %eax
movl %eax, 0x4c(%rsp)
movq 0x38(%rsp), %rax
subq $0x8, %rax
movq %rax, 0x38(%rsp)
movl 0x30(%rsp), %eax
addl $0x8, %eax
movl %eax, 0x30(%rsp)
jmp 0x47090f
movl 0x4c(%rsp), %edi
callq 0x4709f0
movl %eax, %eax
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x0, 0x4c(%rsp)
movl $0x0, 0x30(%rsp)
jmp 0x470901
cmpq $0x0, 0x38(%rsp)
je 0x4709e0
movq 0x20(%rsp), %rax
movzbl (%rax), %eax
movl $0x8, %ecx
subq 0x38(%rsp), %rcx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %edi
callq 0x4709f0
movl %eax, %eax
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x68, %rsp
retq
nopw (%rax,%rax)