// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rax
testq %rdi, %rdi
je 0x28b28b
movl %esi, %ecx
andl $0x7, %ecx
shrq $0x3, %rsi
addq %rsi, %rdi
testl %ecx, %ecx
je 0x28b1d1
pushq $0x8
popq %rax
subl %ecx, %eax
cmpq %rdx, %rax
movq %rdx, %rsi
cmovbq %rax, %rsi
pushq $-0x1
popq %r8
movl %esi, %ecx
shll %cl, %r8d
subl %esi, %eax
notl %r8d
movzbl (%rdi), %r9d
movl %eax, %ecx
shrl %cl, %r9d
incq %rdi
andl %r8d, %r9d
imull $0x8040201, %r9d, %eax  # imm = 0x8040201
shrl $0x3, %eax
andl $0x11111111, %eax       # imm = 0x11111111
imull $0x11111111, %eax, %eax # imm = 0x11111111
shrl $0x1c, %eax
subq %rsi, %rdx
jmp 0x28b1d3
xorl %eax, %eax
movl $0x33333333, %ecx       # imm = 0x33333333
cmpq $0x8, %rdx
jb 0x28b244
xorl %r8d, %r8d
xorl %esi, %esi
cmpq $0x8, %rdx
jb 0x28b206
cmpl $0x18, %r8d
ja 0x28b206
shll $0x8, %esi
movzbl (%rdi), %r9d
incq %rdi
orl %r9d, %esi
addq $-0x8, %rdx
addl $0x8, %r8d
jmp 0x28b1e3
movl %esi, %r8d
shrl %r8d
andl $0x55555555, %r8d       # imm = 0x55555555
subl %r8d, %esi
movl %esi, %r8d
andl %ecx, %r8d
shrl $0x2, %esi
andl %ecx, %esi
addl %r8d, %esi
movl %esi, %r8d
shrl $0x4, %r8d
addl %esi, %r8d
andl $0xf0f0f0f, %r8d        # imm = 0xF0F0F0F
imull $0x1010101, %r8d, %esi  # imm = 0x1010101
shrl $0x18, %esi
addq %rsi, %rax
jmp 0x28b1d8
testq %rdx, %rdx
je 0x28b289
movzbl (%rdi), %esi
movb $0x8, %cl
subb %dl, %cl
shrl %cl, %esi
shll %cl, %esi
movl %esi, %ecx
shrl %ecx
andl $0x55555555, %ecx       # imm = 0x55555555
subl %ecx, %esi
movl $0x33333333, %ecx       # imm = 0x33333333
movl %esi, %edx
andl %ecx, %edx
shrl $0x2, %esi
andl %ecx, %esi
addl %edx, %esi
movl %esi, %ecx
shrl $0x4, %ecx
addl %esi, %ecx
andl $0xf0f0f0f, %ecx        # imm = 0xF0F0F0F
imull $0x1010101, %ecx, %ecx  # imm = 0x1010101
shrl $0x18, %ecx
addq %rcx, %rax
popq %rcx
retq
movq 0x1accd6(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x59d77(%rip), %rsi     # 0x2e5013
leaq 0x86d81(%rip), %rdx     # 0x312024
leaq 0xefa1f(%rip), %rcx     # 0x37acc9
leaq 0xef9dc(%rip), %r8      # 0x37ac8d
movl $0x1c4, %r9d            # imm = 0x1C4
xorl %eax, %eax
callq 0x17a50
callq 0x17390