// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rax
movq %rdi, %r14
movq 0x90(%rdi), %rbx
movl 0xd8(%rdi), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, %r15
testq %rbx, %rbx
jne 0x12fc52
leaq 0x251bd5(%rip), %rsi    # 0x381806
movl $0x20, %edi
movl $0x1cf, %edx            # imm = 0x1CF
callq 0x1092b2
movq %rax, %rbx
movq %rax, 0x90(%r14)
leaq 0x1(%r15), %rax
movq %rax, 0x8(%rbx)
cmpq 0x8(%rbx), %r15
je 0x12fdee
movq %r15, 0x8(%rbx)
movl 0xd8(%r14), %eax
movl %eax, 0x1c(%rbx)
movq 0xb8(%r14), %rax
decq %rax
cmpq %rax, %r15
jne 0x12fc83
movl 0xe0(%r14), %eax
movl %eax, 0x1c(%rbx)
movl 0xec(%r14), %esi
xorl %edi, %edi
movq %r15, %rax
xorl %edx, %edx
divq %rsi
movq %rax, %r13
movl $0x0, %r12d
cmpq %rsi, %r15
jb 0x12fd58
movl 0xe4(%r14), %edx
cmpq $0x41, %rdx
jae 0x12fdfd
leaq -0x1(%r13), %rax
testq %rdx, %rdx
je 0x12fcff
movq 0x80(%r14), %rdi
movq %rax, %rcx
imulq %rdx, %rcx
movq %rcx, %r8
shrq $0x6, %r8
movq (%rdi,%r8,8), %r12
shlq %cl, %r12
andl $0x3f, %ecx
leal (%rcx,%rdx), %r9d
cmpl $0x41, %r9d
jb 0x12fcf6
movq 0x8(%rdi,%r8,8), %rdi
negb %cl
shrq %cl, %rdi
orq %rdi, %r12
negb %dl
movl %edx, %ecx
shrq %cl, %r12
jmp 0x12fd02
xorl %r12d, %r12d
movl 0xe8(%r14), %edx
cmpq $0x41, %rdx
jae 0x12fe02
testq %rdx, %rdx
je 0x12fd56
movq 0x88(%r14), %r8
imulq %rdx, %rax
movq %rax, %r9
shrq $0x6, %r9
movq (%r8,%r9,8), %rdi
movl %eax, %ecx
shlq %cl, %rdi
movl %eax, %ecx
andl $0x3f, %ecx
leal (%rcx,%rdx), %eax
cmpl $0x41, %eax
jb 0x12fd4d
movq 0x8(%r8,%r9,8), %rax
negb %cl
shrq %cl, %rax
orq %rax, %rdi
negb %dl
movl %edx, %ecx
shrq %cl, %rdi
jmp 0x12fd58
xorl %edi, %edi
movq %rdi, 0x10(%rbx)
imulq %rsi, %r13
movq %r14, %rdi
cmpq %r15, %r13
jae 0x12fd8e
movq %r13, %rsi
callq 0x1303a3
movl %eax, 0x18(%rbx)
movl %eax, %ecx
addq %rcx, 0x10(%rbx)
movq 0x68(%r14), %rdi
movl %eax, %esi
callq 0x16c234
movl %eax, %eax
addq %rax, %r12
incq %r13
jmp 0x12fd60
movq %r15, %rsi
callq 0x1303a3
movl %eax, 0x18(%rbx)
movq 0x68(%r14), %rdi
movl %eax, %esi
callq 0x16c234
cmpl $0x41, %eax
jae 0x12fdf8
testl %eax, %eax
je 0x12fde9
movq 0x70(%r14), %rdi
movl %r12d, %edx
movq %r12, %r8
shrq $0x6, %r8
movq (%rdi,%r8,8), %rsi
movl %r12d, %ecx
shlq %cl, %rsi
andl $0x3f, %edx
movl %eax, %ecx
addl %edx, %ecx
cmpl $0x41, %ecx
jb 0x12fde0
movq 0x8(%rdi,%r8,8), %rdi
negb %dl
movl %edx, %ecx
shrq %cl, %rdi
orq %rdi, %rsi
negb %al
movl %eax, %ecx
shrq %cl, %rsi
jmp 0x12fdeb
xorl %esi, %esi
movq %rsi, (%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x3d024
callq 0x3cfb2
callq 0x3cfeb