// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
movl 0xd8(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, 0x90(%rax)
jne 0x13af30
movl $0x20, %edi
leaq 0x40f912(%rip), %rsi    # 0x54a806
movl $0x1cf, %edx            # imm = 0x1CF
callq 0xe80f0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x90(%rax)
movq 0x40(%rsp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rcx
addq $0x1, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq 0x8(%rcx), %rax
je 0x13b121
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rax
movl 0xd8(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
movq 0xb8(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x13af92
movq 0x40(%rsp), %rax
movl 0xe0(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
movl 0xec(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x13afcc
movq $0x0, 0x8(%rsp)
movq 0x28(%rsp), %rax
movq $0x0, 0x10(%rax)
jmp 0x13b045
movq 0x40(%rsp), %rax
movq 0x80(%rax), %rdi
movq 0x10(%rsp), %rsi
subq $0x1, %rsi
movq 0x40(%rsp), %rax
movl 0xe4(%rax), %eax
imulq %rax, %rsi
movq 0x40(%rsp), %rax
movl 0xe4(%rax), %edx
callq 0x13bb30
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rax
movq 0x88(%rax), %rdi
movq 0x10(%rsp), %rsi
subq $0x1, %rsi
movq 0x40(%rsp), %rax
movl 0xe8(%rax), %eax
imulq %rax, %rsi
movq 0x40(%rsp), %rax
movl 0xe8(%rax), %edx
callq 0x13bb30
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rax
movq 0x40(%rsp), %rcx
movl 0xec(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
cmpq 0x30(%rsp), %rax
jae 0x13b0cc
movq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x13bc30
movl %eax, %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x28(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
movq 0x28(%rsp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x40(%rsp), %rax
movq 0x68(%rax), %rdi
movq 0x28(%rsp), %rax
movl 0x18(%rax), %esi
callq 0x1b4bc0
movl %eax, %eax
addq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x13b05e
movq 0x40(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x13bc30
movl %eax, %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x40(%rsp), %rax
movq 0x68(%rax), %rdi
movq 0x28(%rsp), %rax
movl 0x18(%rax), %esi
callq 0x1b4bc0
movl %eax, 0x24(%rsp)
movq 0x40(%rsp), %rax
movq 0x70(%rax), %rdi
movq 0x8(%rsp), %rsi
movl 0x24(%rsp), %edx
callq 0x13bb30
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)