// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/compressed_bitsequence.c
// Function: gt_compressed_bitsequence_calc_block_info
static inline void
gt_compressed_bitsequence_calc_block_info(GtCompressedBitsequence *cbs,
                                          GtUword position)
{
  GtUword idx;
  GtCompressedBitsequenceBlockInfo *bi = cbs->cbs_bi;

  idx = position / cbs->blocksize;

  if (cbs->cbs_bi == NULL) {
    cbs->cbs_bi = gt_malloc(sizeof (*cbs->cbs_bi));
    bi = cbs->cbs_bi;
    bi->idx = idx + 1;
  }

  if (idx != bi->idx) {
    unsigned int offset_bits;
    GtUword jdx, sample, offsets_bitpos;

    bi->idx = idx;
    bi->block_len = cbs->blocksize;
    if (idx == cbs->num_of_blocks -1)
      bi->block_len = cbs->last_block_len;

    sample = idx / cbs->superblocksize;
    if (sample==0) {
      offsets_bitpos = 0;
      bi->rank_sum = 0;
    }
    else {
      offsets_bitpos = (GtUword)
        gt_compressed_bitsequence_get_variable_field(
                                     cbs->superblockoffsets,
                                     (sample - 1) * cbs->superblockoffsets_bits,
                                     cbs->superblockoffsets_bits);
      bi->rank_sum = (GtUword)
        gt_compressed_bitsequence_get_variable_field(
                                       cbs->superblockranks,
                                       (sample - 1) * cbs->superblockranks_bits,
                                       cbs->superblockranks_bits);
    }
    for (jdx = sample * cbs->superblocksize; jdx < idx; jdx++) {
      bi->class = gt_compressed_bitsequence_get_class(cbs, jdx);
      bi->rank_sum += bi->class;
      offsets_bitpos += gt_popcount_tab_offset_bits(cbs->popcount_tab,
                                                    bi->class);
    }
    bi->class = gt_compressed_bitsequence_get_class(cbs, idx);
    offset_bits = gt_popcount_tab_offset_bits(cbs->popcount_tab, bi->class);
    bi->block_offset = (GtUword)
      gt_compressed_bitsequence_get_variable_field(cbs->c_offsets,
                                                   offsets_bitpos,
                                                   offset_bits);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rax
movq %rdi, %rbx
movq 0x90(%rdi), %r14
movl 0xd8(%rdi), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, %r15
testq %r14, %r14
je 0xbf4fd
cmpq 0x8(%r14), %r15
jne 0xbf523
jmp 0xbf60a
leaq 0x259332(%rip), %rsi    # 0x318836
pushq $0x20
popq %rdi
movl $0x1cf, %edx            # imm = 0x1CF
callq 0x93160
movq %rax, %r14
movq %rax, 0x90(%rbx)
leaq 0x1(%r15), %rax
movq %rax, 0x8(%r14)
movq %r15, 0x8(%r14)
movl 0xd8(%rbx), %eax
movl %eax, 0x1c(%r14)
movq 0xb8(%rbx), %rax
decq %rax
cmpq %rax, %r15
jne 0xbf54a
movl 0xe0(%rbx), %eax
movl %eax, 0x1c(%r14)
movl 0xec(%rbx), %esi
xorl %ecx, %ecx
movq %r15, %rax
xorl %edx, %edx
divq %rsi
movq %rax, %r12
movl $0x0, %r13d
cmpq %rsi, %r15
jb 0xbf5ab
movq 0x80(%rbx), %rdi
leaq -0x1(%r12), %rbp
movl 0xe4(%rbx), %edx
movq %rdx, %rsi
imulq %rbp, %rsi
callq 0xbfacc
movq %rax, %r13
movq 0x88(%rbx), %rdi
movl 0xe8(%rbx), %edx
imulq %rdx, %rbp
movq %rbp, %rsi
callq 0xbfacc
movq %rax, %rcx
movl 0xec(%rbx), %esi
movq %rcx, 0x10(%r14)
imulq %rsi, %r12
movq %rbx, %rdi
cmpq %r15, %r12
jae 0xbf5e2
movq %r12, %rsi
callq 0xbfb43
movl %eax, 0x18(%r14)
movl %eax, %ecx
addq %rcx, 0x10(%r14)
movq 0x68(%rbx), %rdi
movl %eax, %esi
callq 0x1047ab
movl %eax, %eax
addq %rax, %r13
incq %r12
jmp 0xbf5b3
movq %r15, %rsi
callq 0xbfb43
movl %eax, 0x18(%r14)
movq 0x68(%rbx), %rdi
movl %eax, %esi
callq 0x1047ab
movq 0x70(%rbx), %rdi
movq %r13, %rsi
movl %eax, %edx
callq 0xbfacc
movq %rax, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq