// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/wtree_encseq.c
// Function: gt_wtree_encseq_access_rec
static GtWtreeSymbol gt_wtree_encseq_access_rec(GtWtreeEncseq *we,
                                                GtUword pos,
                                                GtUword node_start,
                                                GtUword node_size,
                                                unsigned int alpha_start,
                                                unsigned int alpha_end)
{
  unsigned int middle = GT_DIV2(alpha_start + alpha_end);
  int bit;
  GtUword zero_rank_prefix = 0,
          one_rank_prefix = 0,
          left_child_size;
  gt_assert(pos < node_size);

  if (alpha_start < alpha_end) {
    bit = gt_compressed_bitsequence_access(we->c_bits, node_start + pos);
    if (node_start != 0)
      zero_rank_prefix =
        gt_compressed_bitsequence_rank_0(we->c_bits, node_start - 1);
    left_child_size =
      gt_compressed_bitsequence_rank_0(we->c_bits, node_start + node_size - 1) -
      zero_rank_prefix;

    if (bit == 0) {
      pos = gt_compressed_bitsequence_rank_0(we->c_bits, node_start + pos) -
        zero_rank_prefix - 1; /*convert count (rank) to position */
      alpha_end = middle;
      node_start += we->parent_instance.members->length;
      node_size = left_child_size;
      return gt_wtree_encseq_access_rec(we, pos, node_start,
                                        node_size, alpha_start, alpha_end);
    }
    else {
      if (node_start != 0)
        one_rank_prefix =
          gt_compressed_bitsequence_rank_1(we->c_bits, node_start - 1);
      pos = gt_compressed_bitsequence_rank_1(we->c_bits, node_start + pos) -
        one_rank_prefix - 1; /*convert count (rank) to position */
      alpha_start = middle + 1;
      node_size =
        gt_compressed_bitsequence_rank_1(we->c_bits,
                                         node_start + node_size - 1) -
        one_rank_prefix;
      node_start +=
        we->parent_instance.members->length + left_child_size;
      return gt_wtree_encseq_access_rec(we, pos, node_start,
                                        node_size, alpha_start, alpha_end);
    }
  }
  return (GtWtreeSymbol) alpha_start;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %r14d
movl %r8d, %r12d
movq %rcx, 0x8(%rsp)
movq %rdx, %rbx
movq %rdi, %rbp
movq %r12, 0x20(%rsp)
cmpq 0x8(%rsp), %rsi
jae 0x18d26d
cmpl %r14d, %r12d
jae 0x18d25b
movq 0x38(%rbp), %rdi
addq %rbx, %rsi
movq %rsi, 0x18(%rsp)
callq 0x12fb79
movl %eax, 0x10(%rsp)
testq %rbx, %rbx
je 0x18d18f
movq 0x38(%rbp), %rdi
leaq -0x1(%rbx), %rsi
callq 0x12fe86
movq %rax, %r13
jmp 0x18d192
xorl %r13d, %r13d
addl %r14d, %r12d
shrl %r12d
movq 0x38(%rbp), %rdi
movq 0x8(%rsp), %rax
leaq (%rbx,%rax), %r15
decq %r15
movq %r15, %rsi
callq 0x12fe86
subq %r13, %rax
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x10(%rsp)
jne 0x18d1ea
movq 0x38(%rbp), %rdi
movq 0x18(%rsp), %rsi
callq 0x12fe86
notq %r13
addq %rax, %r13
movq 0x8(%rbp), %rax
addq (%rax), %rbx
movq %r13, %rsi
movl %r12d, %r14d
movq 0x20(%rsp), %r12
jmp 0x18d14f
movq %r14, 0x10(%rsp)
movq %rbp, %r13
testq %rbx, %rbx
je 0x18d209
movq 0x38(%r13), %rdi
leaq -0x1(%rbx), %rsi
callq 0x12fe07
movq %rax, %rbp
jmp 0x18d20b
xorl %ebp, %ebp
movq 0x38(%r13), %rdi
movq 0x18(%rsp), %rsi
callq 0x12fe07
movq %rbp, %r14
notq %r14
addq %rax, %r14
incl %r12d
movq 0x38(%r13), %rdi
movq %r15, %rsi
callq 0x12fe07
movq %r14, %rsi
movq 0x8(%rsp), %rdx
addq %rbx, %rdx
movq 0x8(%r13), %rcx
addq (%rcx), %rdx
subq %rbp, %rax
movq %rdx, %rbx
movq %rax, 0x8(%rsp)
movq %r13, %rbp
movq 0x10(%rsp), %r14
jmp 0x18d14a
movl %r12d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5af55