// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/compressed_bitsequence.c
// Function: gt_compressed_bitsequence_rank_0
GtUword gt_compressed_bitsequence_rank_0(GtCompressedBitsequence *cbs,
                                         GtUword position)
{
  unsigned int pos_in_block;
  GtUword rank_sum0;
  GtCompressedBitsequenceBlockInfo *cbs_bi;

  gt_assert(cbs != NULL);
  gt_assert(position < cbs->num_of_bits);

  pos_in_block = (unsigned int) position % cbs->blocksize;

  gt_compressed_bitsequence_calc_block_info(cbs, position);
  cbs_bi = cbs->cbs_bi;

  pos_in_block += cbs->blocksize - cbs_bi->block_len;
  rank_sum0 = ((cbs_bi->idx) * cbs->blocksize) - cbs_bi->rank_sum;
  rank_sum0 -= cbs->blocksize - cbs_bi->block_len;
  if (cbs_bi->class == 0)
    return rank_sum0 + pos_in_block + 1;
  if (cbs_bi->class == cbs->blocksize)
    return rank_sum0;
  return rank_sum0 + gt_popcount_tab_rank_0(cbs->popcount_tab,
                                            cbs_bi->class,
                                            cbs_bi->block_offset,
                                            pos_in_block);
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x13b30e
movq 0x500cc3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3dad2c(%rip), %rsi    # 0x516013
leaq 0x40f582(%rip), %rdx    # 0x54a870
leaq 0x40f5e5(%rip), %rcx    # 0x54a8da
leaq 0x40f50a(%rip), %r8     # 0x54a806
movl $0x23b, %r9d            # imm = 0x23B
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x13b310
jmp 0x13b312
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0xb0(%rcx), %rax
jb 0x13b35d
movq 0x500c74(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3dacdd(%rip), %rsi    # 0x516013
leaq 0x40f560(%rip), %rdx    # 0x54a89d
leaq 0x40f596(%rip), %rcx    # 0x54a8da
leaq 0x40f4bb(%rip), %r8     # 0x54a806
movl $0x23c, %r9d            # imm = 0x23C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x13b35f
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
xorl %edx, %edx
divl 0xd8(%rcx)
movl %edx, 0x1c(%rsp)
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x13aea0
movq 0x28(%rsp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rax
movl 0xd8(%rax), %eax
movq 0x8(%rsp), %rcx
subl 0x1c(%rcx), %eax
addl 0x1c(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rsp), %rcx
movl 0xd8(%rcx), %ecx
imulq %rcx, %rax
movq 0x8(%rsp), %rcx
subq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %rax
movl 0xd8(%rax), %eax
movq 0x8(%rsp), %rcx
subl 0x1c(%rcx), %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x10(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x13b41c
movq 0x10(%rsp), %rax
movl 0x1c(%rsp), %ecx
addq %rcx, %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
jmp 0x13b478
movq 0x8(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x28(%rsp), %rcx
cmpl 0xd8(%rcx), %eax
jne 0x13b43d
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x13b478
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x28(%rsp), %rax
movq 0x68(%rax), %rdi
movq 0x8(%rsp), %rax
movl 0x18(%rax), %esi
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movl 0x1c(%rsp), %ecx
callq 0x1b4f40
movl %eax, %ecx
movq (%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)