// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/sfx-bltrie.c
// Function: blindtrie_findcompanion
static GtBlindtriesnodeptr blindtrie_findcompanion(
                                    GtBlindtrie *blindtrie,
                                    GtUword currentstartpos,
                                    GtUword currenttwobitencodingstoppos)
{
  GtBlindtriesymbol newchar;
  GtBlindtriesnodeptr head, succ;
  GtUword headdepth;

  blindtrie->stack.nextfreeGtBlindtriesnodeptr = 0;
  head = GT_BLINDTRIE_ROOTIDX;
  while (!blindtrie_isleaf(blindtrie,head))
  {
    GT_STOREINARRAY (&blindtrie->stack, GtBlindtriesnodeptr, 128, head);
    headdepth = blindtrie_getdepth(blindtrie,head);
    if (blindtrie_isleftofboundary(blindtrie,currentstartpos,headdepth))
    {
      if (!blindtrie->cmpcharbychar &&
          blindtrie->has_twobitencoding_stoppos_support)
      {
        if ((GT_ISDIRREVERSE(blindtrie->readmode) &&
            GT_REVERSEPOS(blindtrie->totallength,currentstartpos+headdepth)
            >= currenttwobitencodingstoppos) ||
            (!GT_ISDIRREVERSE(blindtrie->readmode) &&
             currentstartpos + headdepth < currenttwobitencodingstoppos))
        {
          newchar = (GtBlindtriesymbol)
                    gt_encseq_get_encoded_char_nospecial(
                                                   blindtrie->encseq,
                                                   currentstartpos + headdepth,
                                                   blindtrie->readmode);
        } else
        {
          newchar = GT_UNIQUEINT(currentstartpos + headdepth);
        }
      } else
      {
        newchar = (GtBlindtriesymbol)
                  gt_encseq_get_encoded_char(blindtrie->encseq,
                                             currentstartpos + headdepth,
                                             blindtrie->readmode);
        if (GT_BLINDTRIECHAR_GT_ISSPECIAL(newchar))
        {
          newchar = GT_UNIQUEINT(currentstartpos + headdepth);
        }
      }
    } else
    {
      newchar = GT_UNIQUEINT(currentstartpos + headdepth);
    }
    if (GT_ISUNIQUEINT(newchar))
    {
      return blindtrie_extractleafnode(blindtrie,head);
    }
    succ = blindtrie_findsucc(blindtrie,
                              blindtrie_firstchild_get(blindtrie,head),
                              newchar);
    if (succ == GT_BLINDTRIE_REFNULL)
    {
      return blindtrie_extractleafnode(blindtrie,head);
    }
    head = succ;
  }
  GT_STOREINARRAY (&blindtrie->stack, GtBlindtriesnodeptr, 128, head);
  return head;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, (%rsp)
movq %rsi, %r12
movq %rdi, %rbx
movq $0x0, 0x20(%rdi)
xorl %ebp, %ebp
movl %ebp, %r15d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1f04d3
movq 0x20(%rbx), %rcx
testb %al, %al
jne 0x1f0469
movq 0x18(%rbx), %rax
cmpq %rax, %rcx
jb 0x1f0331
leaq 0x80(%rax), %rcx
movq %rcx, 0x18(%rbx)
movq 0x10(%rbx), %rdi
leaq 0x200(,%rax,4), %rsi
leaq 0x1cf01b(%rip), %rdx    # 0x3bf33e
movl $0x1d0, %ecx            # imm = 0x1D0
callq 0x1094e6
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x1f04c9
movq 0x20(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rbx)
movl %r15d, (%rax,%rcx,4)
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1f0bac
movq %rax, %r13
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x1f0375
addq %r12, %rax
movq 0x60(%rbx), %rcx
cmpq %rcx, %rax
cmovaeq %rcx, %rax
jmp 0x1f0379
movq 0x60(%rbx), %rax
addq %r12, %r13
cmpq %rax, %r13
jae 0x1f03c7
cmpb $0x0, 0x78(%rbx)
jne 0x1f03d0
cmpb $0x1, 0x7a(%rbx)
jne 0x1f03d0
movl 0x58(%rbx), %edx
movl %edx, %eax
orl $0x2, %eax
cmpl $0x3, %eax
jne 0x1f03af
movq %r13, %rcx
notq %rcx
addq 0x60(%rbx), %rcx
cmpq (%rsp), %rcx
jae 0x1f03b5
cmpl $0x3, %eax
je 0x1f03c7
cmpq (%rsp), %r13
jae 0x1f03c7
movq 0x40(%rbx), %rdi
movq %r13, %rsi
callq 0xec603
movzbl %al, %r13d
jmp 0x1f03ef
addq $0x100, %r13            # imm = 0x100
jmp 0x1f03ef
movq 0x40(%rbx), %rdi
movl 0x58(%rbx), %edx
movq %r13, %rsi
callq 0xec1f8
movzbl %al, %eax
addq $0x100, %r13            # imm = 0x100
cmpb $-0x2, %al
cmovbq %rax, %r13
cmpq $0x100, %r13            # imm = 0x100
jae 0x1f0450
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1f0b7f
movl %eax, %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1f0e60
xorl %ebp, %ebp
cmpq %r13, %rax
movl $0x0, %ecx
sbbl %ecx, %ecx
cmpq %r13, %rax
movl $0x1, %eax
cmoval %eax, %ecx
testl %ecx, %ecx
je 0x1f0445
cmpl $0x1, %ecx
je 0x1f0448
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1f0c08
movl %eax, %r14d
testl %eax, %eax
jne 0x1f0406
jmp 0x1f0448
movl %r14d, %ebp
testl %ebp, %ebp
jne 0x1f02e3
movq %rbx, %rdi
movl %r15d, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1f0e27
movq 0x18(%rbx), %rax
cmpq %rax, %rcx
jb 0x1f049e
leaq 0x80(%rax), %rcx
movq %rcx, 0x18(%rbx)
movq 0x10(%rbx), %rdi
leaq 0x200(,%rax,4), %rsi
leaq 0x1ceeae(%rip), %rdx    # 0x3bf33e
movl $0x202, %ecx            # imm = 0x202
callq 0x1094e6
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x1f04ce
movq 0x20(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rbx)
movl %r15d, (%rax,%rcx,4)
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x780b4
callq 0x780ed