// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/wtree_encseq.c
// Function: gt_wtree_encseq_select_rec
static GtUword gt_wtree_encseq_select_rec(GtWtreeEncseq *we,
                                          GtUword i,
                                          GtWtreeSymbol sym,
                                          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, child_start;

  if (alpha_start < alpha_end) {
    bit = middle < (unsigned int) sym ? 1 : 0;
    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) {
      alpha_end = middle;
      child_start = node_start + we->parent_instance.members->length;
      node_size = left_child_size;
    }
    else {
      if (node_start != 0)
        one_rank_prefix =
          gt_compressed_bitsequence_rank_1(we->c_bits, node_start - 1);
      alpha_start = middle + 1;
      node_size =
        gt_compressed_bitsequence_rank_1(we->c_bits,
                                         node_start + node_size - 1) -
        one_rank_prefix;
      child_start =
        node_start + we->parent_instance.members->length + left_child_size;
    }
    if (node_size != 0) {
      i = gt_wtree_encseq_select_rec(we, i, sym, child_start, node_size,
                                     alpha_start, alpha_end);
      if (i < node_size) {
        return (bit == 0 ?
                gt_compressed_bitsequence_select_0(we->c_bits,
                                                   zero_rank_prefix + i + 1) :
                gt_compressed_bitsequence_select_1(we->c_bits,
                                                   one_rank_prefix + i + 1)) -
          node_start;
      }
    }
    return ULONG_MAX;
  }
  if (i <= node_size)
    return i - 1;
  return ULONG_MAX;
}

// Assembly:
subq $0x78, %rsp
movl 0x80(%rsp), %eax
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movl %r9d, 0x44(%rsp)
movl 0x44(%rsp), %eax
addl 0x80(%rsp), %eax
shrl %eax
movl %eax, 0x40(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movl 0x44(%rsp), %eax
cmpl 0x80(%rsp), %eax
jae 0x1f8449
movl 0x40(%rsp), %edx
movq 0x58(%rsp), %rax
movl %eax, %esi
xorl %eax, %eax
movl $0x1, %ecx
cmpl %esi, %edx
cmovbl %ecx, %eax
movl %eax, 0x3c(%rsp)
cmpq $0x0, 0x50(%rsp)
je 0x1f82cc
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x50(%rsp), %rsi
subq $0x1, %rsi
callq 0x13b2c0
movq %rax, 0x30(%rsp)
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x50(%rsp), %rsi
addq 0x48(%rsp), %rsi
subq $0x1, %rsi
callq 0x13b2c0
subq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x3c(%rsp)
jne 0x1f8326
movl 0x40(%rsp), %eax
movl %eax, 0x80(%rsp)
movq 0x50(%rsp), %rax
movq 0x68(%rsp), %rcx
movq 0x8(%rcx), %rcx
addq (%rcx), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
jmp 0x1f8396
cmpq $0x0, 0x50(%rsp)
je 0x1f834a
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x50(%rsp), %rsi
subq $0x1, %rsi
callq 0x13b130
movq %rax, 0x28(%rsp)
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x50(%rsp), %rsi
addq 0x48(%rsp), %rsi
subq $0x1, %rsi
callq 0x13b130
subq 0x28(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
movq 0x68(%rsp), %rcx
movq 0x8(%rcx), %rcx
addq (%rcx), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x1f843e
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq 0x48(%rsp), %r8
movl 0x44(%rsp), %r9d
movl 0x80(%rsp), %eax
movl %eax, (%rsp)
callq 0x1f8230
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
cmpq 0x48(%rsp), %rax
jae 0x1f843c
cmpl $0x0, 0x3c(%rsp)
jne 0x1f840a
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x30(%rsp), %rsi
addq 0x60(%rsp), %rsi
addq $0x1, %rsi
callq 0x13bdf0
movq %rax, 0x10(%rsp)
jmp 0x1f842b
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x28(%rsp), %rsi
addq 0x60(%rsp), %rsi
addq $0x1, %rsi
callq 0x13b490
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
subq 0x50(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x1f846e
jmp 0x1f843e
movq $-0x1, 0x70(%rsp)
jmp 0x1f846e
movq 0x60(%rsp), %rax
cmpq 0x48(%rsp), %rax
ja 0x1f8465
movq 0x60(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x1f846e
movq $-0x1, 0x70(%rsp)
movq 0x70(%rsp), %rax
addq $0x78, %rsp
retq
nopl (%rax,%rax)