// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/merger-trie.c
// Function: gt_mergertrie_insertsuffix
void gt_mergertrie_insertsuffix(Mergertrierep *trierep,
                             Mergertrienode *node,
                             Suffixinfo *suffixinfo)
{
  if (trierep->root == NULL)
  {
    trierep->root = mtrie_makeroot(trierep,suffixinfo);
  } else
  {
    GtUword currentdepth, lcpvalue, totallength;
    Mergertrienode *currentnode, *newleaf, *newbranch, *succ;
    Nodepair np;
    GtUchar cc;
    Encseqreadinfo *eri = trierep->encseqreadinfo + suffixinfo->idx;

    gt_assert(!MTRIE_ISLEAF(node));
    currentnode = node;
    currentdepth = node->depth;
    totallength = gt_encseq_total_length(eri->encseqptr);
    while (true)
    {
      if (suffixinfo->startpos + currentdepth >= totallength)
      {
        cc = (GtUchar) GT_SEPARATOR;
      } else
      {
        /* Random access */
        cc = gt_encseq_get_encoded_char(eri->encseqptr,
                                            suffixinfo->startpos + currentdepth,
                                            eri->readmode);
      }
      gt_assert(currentnode != NULL);
      gt_assert(!MTRIE_ISLEAF(currentnode));
      if (!hassuccessor(trierep,&np,currentdepth,currentnode,cc,
                        suffixinfo->idx))
      {
        newleaf = mtrie_makenewleaf(trierep,suffixinfo);
        newleaf->rightsibling = np.current;
        SHOWNODERELATIONS(newleaf);
        if (np.previous == NULL)
        {
          SETFIRSTCHILD(currentnode,newleaf);
          SHOWNODERELATIONS(currentnode);
        } else
        {
          np.previous->rightsibling = newleaf;
          SHOWNODERELATIONS(np.previous);
        }
        return;
      }
      succ = np.current;
      if MTRIE_ISLEAF(succ)
      {
        lcpvalue = getlcp(eri->encseqptr,
                          eri->readmode,
                          suffixinfo->startpos + currentdepth + 1,
                          gt_encseq_total_length(eri->encseqptr) - 1,
                          trierep->encseqreadinfo[succ->suffixinfo.idx].
                                encseqptr,
                          trierep->encseqreadinfo[succ->suffixinfo.idx].
                                readmode,
                          succ->suffixinfo.startpos + currentdepth + 1,
                          gt_encseq_total_length(
                              trierep->encseqreadinfo[succ->suffixinfo.idx].
                                        encseqptr) - 1);
        newbranch = mtrie_makenewbranch(trierep,
                                  suffixinfo,
                                  currentdepth + lcpvalue + 1,
                                  succ);
        if (np.previous == NULL)
        {
          SETFIRSTCHILD(currentnode,newbranch);
          SHOWNODERELATIONS(currentnode);
        } else
        {
          np.previous->rightsibling = newbranch;
          SHOWNODERELATIONS(np.previous);
        }
        return;
      }
      lcpvalue = getlcp(eri->encseqptr,
                        eri->readmode,
                        suffixinfo->startpos + currentdepth + 1,
                        gt_encseq_total_length(eri->encseqptr) - 1,
                        trierep->encseqreadinfo[succ->suffixinfo.idx].encseqptr,
                        trierep->encseqreadinfo[succ->suffixinfo.idx].readmode,
                        succ->suffixinfo.startpos + currentdepth + 1,
                        succ->suffixinfo.startpos + succ->depth - 1);
      if (currentdepth + lcpvalue + 1 < succ->depth)
      {
        newbranch = mtrie_makenewbranch(trierep,
                                  suffixinfo,
                                  currentdepth + lcpvalue + 1,
                                  succ);
        if (np.previous == NULL)
        {
          SETFIRSTCHILD(currentnode,newbranch);
          SHOWNODERELATIONS(currentnode);
        } else
        {
          np.previous->rightsibling = newbranch;
          SHOWNODERELATIONS(np.previous);
        }
        return;
      }
      currentnode = succ;
      currentdepth = currentnode->depth;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rdi, %r14
cmpq $0x0, 0x10(%rdi)
je 0x31fbe0
movq %rsi, %r15
cmpq $0x0, 0x10(%rsi)
je 0x31fcb3
movl (%rbx), %eax
shlq $0x4, %rax
addq (%r14), %rax
movq 0x28(%r15), %r13
movq %rax, 0x18(%rsp)
movq (%rax), %rdi
callq 0xe7b9c
movq %rbx, 0x8(%rsp)
movq %rax, 0x20(%rsp)
movq 0x8(%rbx), %rsi
addq %r13, %rsi
movb $-0x1, %bpl
cmpq %rax, %rsi
jae 0x31fa9e
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %edx
callq 0xe7bbc
movl %eax, %ebp
movq %r15, 0x28(%rsp)
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x31fcae
movl (%rbx), %ebx
xorl %r12d, %r12d
movq %rax, %r15
movq (%r14), %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x320003
cmpb $-0x2, %al
jb 0x31fade
cmpb $-0x2, %bpl
jb 0x31fbb5
cmpl %ebx, (%r15)
jbe 0x31fae3
jmp 0x31fbb5
cmpb %bpl, %al
jae 0x31faf4
movq 0x18(%r15), %rax
movq %r15, %r12
testq %rax, %rax
jne 0x31fab5
jmp 0x31fbaf
ja 0x31fbb5
movq 0x10(%r15), %rax
movq %rax, 0x40(%rsp)
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %eax
movl %eax, 0x14(%rsp)
leaq 0x1(%r13), %rcx
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rbp
movq %rcx, 0x38(%rsp)
addq %rcx, %rbp
movq %rdi, 0x30(%rsp)
callq 0xe7b9c
movq %rax, %rbx
decq %rbx
movl (%r15), %eax
shlq $0x4, %rax
movq (%r14), %rcx
movq (%rcx,%rax), %r8
movl 0x8(%rcx,%rax), %r9d
movq 0x8(%r15), %rax
addq %rax, %r13
incq %r13
cmpq $0x0, 0x40(%rsp)
je 0x31fc43
movq 0x28(%r15), %rcx
addq %rcx, %rax
decq %rax
movq 0x30(%rsp), %rdi
movl 0x14(%rsp), %esi
movq %rbp, %rdx
movq %rbx, %rcx
pushq %rax
pushq %r13
callq 0x31fcb8
addq $0x10, %rsp
movq 0x38(%rsp), %rdx
addq %rax, %rdx
movq 0x28(%r15), %r13
cmpq %r13, %rdx
movq 0x8(%rsp), %rbx
movq 0x20(%rsp), %rax
jae 0x31fa7d
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x31fc8d
movq %r15, %r12
xorl %r15d, %r15d
movq 0x8(%rsp), %rbx
movq %r14, %rdi
callq 0x31ffcd
movups (%rbx), %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r15, 0x18(%rax)
testq %r12, %r12
je 0x31fc27
movq %rax, 0x18(%r12)
jmp 0x31fc34
movq %r14, %rdi
callq 0x31ffcd
movq %rbx, %r15
movq %rax, %rbx
xorl %eax, %eax
movq %rax, 0x20(%rbx)
movups (%r15), %xmm0
movups %xmm0, (%rbx)
movq %rax, 0x28(%rbx)
movq %rax, 0x18(%rbx)
movq %r14, %rdi
callq 0x31ffcd
movups (%r15), %xmm0
movups %xmm0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq %rax, 0x10(%rbx)
movq %rbx, 0x20(%rax)
movq %rbx, 0x10(%r14)
jmp 0x31fc34
movq 0x28(%rsp), %rcx
movq %rax, 0x10(%rcx)
movq %rcx, 0x20(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, %rdi
movl %r9d, 0x18(%rsp)
movq %r8, 0x20(%rsp)
callq 0xe7b9c
decq %rax
movq 0x30(%rsp), %rdi
movl 0x14(%rsp), %esi
movq %rbp, %rdx
movq %rbx, %rcx
movq 0x20(%rsp), %r8
movl 0x18(%rsp), %r9d
pushq %rax
pushq %r13
callq 0x31fcb8
addq $0x10, %rsp
movq 0x38(%rsp), %rdx
addq %rax, %rdx
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rcx
callq 0x31fd53
testq %r12, %r12
jne 0x31fbd9
movq 0x28(%rsp), %rcx
movq %rax, 0x10(%rcx)
testq %rax, %rax
jne 0x31fc30
jmp 0x31fc34
callq 0x93e72
callq 0x93eab