// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rdx, %r12
movq %rdi, %rbx
cmpq $0x0, 0x10(%rdi)
je 0x329e74
movq %rsi, %r13
cmpq $0x0, 0x10(%rsi)
je 0x329fb0
movl (%r12), %eax
shlq $0x4, %rax
movq %rbx, 0x8(%rsp)
addq (%rbx), %rax
movq 0x28(%r13), %r15
movq %rax, 0x18(%rsp)
movq (%rax), %rdi
callq 0xec1d8
movq %rax, 0x28(%rsp)
movq %r12, 0x10(%rsp)
movq 0x8(%r12), %rsi
addq %r15, %rsi
movb $-0x1, %bpl
cmpq 0x28(%rsp), %rsi
jae 0x329d44
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %edx
callq 0xec1f8
movl %eax, %ebp
testq %r13, %r13
je 0x329fa6
movq %r13, 0x20(%rsp)
movq 0x10(%r13), %r13
testq %r13, %r13
je 0x329fab
movl (%r12), %r14d
xorl %ebx, %ebx
movq %r13, %r12
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x32a343
cmpb $-0x2, %al
jb 0x329d98
movl $0x1, %ecx
cmpb $-0x2, %bpl
jb 0x329dae
cmpl (%r12), %r14d
movl $0x0, %ecx
adcl $-0x1, %ecx
orl $0x1, %ecx
jmp 0x329dae
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpb $-0x3, %bpl
ja 0x329dae
cmpb %bpl, %al
jb 0x329dae
seta %al
movzbl %al, %ecx
testl %ecx, %ecx
je 0x329dcf
cmpl $0x1, %ecx
je 0x329dcb
movq 0x18(%r12), %r13
movq %r12, %rbx
testq %r13, %r13
jne 0x329d65
xorl %eax, %eax
movq %r12, %rbx
jmp 0x329dd4
xorl %eax, %eax
jmp 0x329dd1
movb $0x1, %al
movq %r12, %r13
testb %al, %al
je 0x329ec3
cmpq $0x0, 0x10(%r13)
movq 0x18(%rsp), %rax
movq (%rax), %rbp
je 0x329ee8
movl 0x8(%rax), %eax
movl %eax, 0x4(%rsp)
leaq 0x1(%r15), %r14
movq 0x10(%rsp), %r12
addq 0x8(%r12), %r14
movq %rbp, %rdi
callq 0xec1d8
leaq -0x1(%rax), %rcx
movq 0x8(%rsp), %rax
movq (%rax), %rax
movl (%r13), %edx
shlq $0x4, %rdx
movq (%rax,%rdx), %r8
movl 0x8(%rax,%rdx), %r9d
movq 0x8(%r13), %rax
leaq (%r15,%rax), %r10
incq %r10
movq 0x28(%r13), %rdx
leaq -0x1(%rax,%rdx), %rax
movq %rbp, %rdi
movl 0x4(%rsp), %esi
movq %r14, %rdx
pushq %rax
pushq %r10
callq 0x329fb5
addq $0x10, %rsp
leaq (%r15,%rax), %rdx
incq %rdx
movq 0x28(%r13), %r15
cmpq %r15, %rdx
jae 0x329d20
movq 0x8(%rsp), %rdi
movq %r12, %rsi
jmp 0x329f72
movq %rbx, %rdi
callq 0x32a30d
movq %rax, %r15
xorl %eax, %eax
movq %rax, 0x20(%r15)
movups (%r12), %xmm0
movups %xmm0, (%r15)
movq %rax, 0x28(%r15)
movq %rax, 0x18(%r15)
movq %rbx, %rdi
callq 0x32a30d
movups (%r12), %xmm0
movups %xmm0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x329eba
movq %r15, 0x20(%rax)
movq %r15, 0x10(%rbx)
jmp 0x329f97
movq 0x8(%rsp), %rdi
callq 0x32a30d
movq 0x10(%rsp), %rcx
movups (%rcx), %xmm0
movups %xmm0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq %r13, 0x18(%rax)
jmp 0x329f7a
movl 0x8(%rax), %eax
movl %eax, 0x4(%rsp)
leaq 0x1(%r15), %r14
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r12
addq %r14, %r12
movq %rbp, %rdi
callq 0xec1d8
decq %rax
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movl (%r13), %ecx
shlq $0x4, %rcx
movq (%rax,%rcx), %rdi
movq %rdi, 0x30(%rsp)
movl 0x8(%rax,%rcx), %eax
movl %eax, 0x28(%rsp)
addq 0x8(%r13), %r14
callq 0xec1d8
decq %rax
movq %rbp, %rdi
movl 0x4(%rsp), %esi
movq %r12, %rdx
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %r8
movl 0x28(%rsp), %r9d
pushq %rax
pushq %r14
callq 0x329fb5
addq $0x10, %rsp
leaq (%r15,%rax), %rdx
incq %rdx
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r13, %rcx
callq 0x32a050
testq %rbx, %rbx
je 0x329f85
movq %rax, 0x18(%rbx)
jmp 0x329f97
movq 0x20(%rsp), %rcx
movq %rax, 0x10(%rcx)
testq %rax, %rax
je 0x329f97
movq %rcx, 0x20(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x95e30
callq 0x95df7
callq 0x95e69