// File: /workspace/github_c_makefile_star2_O2/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, %r12
movq %rdi, %rbx
cmpq $0x0, 0x10(%rdi)
je 0x2c0c30
movq %rsi, %r15
cmpq $0x0, 0x10(%rsi)
je 0x2c0d25
movl (%r12), %eax
shlq $0x4, %rax
addq (%rbx), %rax
movq 0x28(%r15), %r13
movq %rax, 0x10(%rsp)
movq (%rax), %rdi
callq 0x7055e
movq %r12, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movq 0x8(%r12), %rsi
addq %r13, %rsi
movb $-0x1, %bpl
cmpq %rax, %rsi
jae 0x2c0afd
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %edx
callq 0x705e4
movl %eax, %ebp
movq %r15, 0x28(%rsp)
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x2c0cf7
movl (%r12), %r12d
xorl %r14d, %r14d
movq %rax, %r15
testq %rax, %rax
je 0x2c0c14
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2c10eb
cmpb $-0x2, %al
jb 0x2c0b48
cmpb $-0x2, %bpl
jb 0x2c0c14
cmpl %r12d, (%r15)
jbe 0x2c0b4d
jmp 0x2c0c14
cmpb %bpl, %al
jae 0x2c0b56
movq 0x18(%r15), %rax
movq %r15, %r14
jmp 0x2c0b16
ja 0x2c0c14
movq 0x10(%r15), %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %eax
movl %eax, 0xc(%rsp)
leaq 0x1(%r13), %rcx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x38(%rsp)
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq %rdi, %r12
callq 0x7055e
movq %rax, %rbp
decq %rbp
movl (%r15), %eax
shlq $0x4, %rax
movq (%rbx), %rcx
movq (%rcx,%rax), %r8
movl 0x8(%rcx,%rax), %r9d
movq 0x8(%r15), %rax
addq %rax, %r13
incq %r13
cmpq $0x0, 0x40(%rsp)
je 0x2c0c8c
movq 0x28(%r15), %rcx
addq %rcx, %rax
decq %rax
movq %r12, %rdi
movl 0xc(%rsp), %esi
movq 0x30(%rsp), %rdx
movq %rbp, %rcx
pushq %rax
pushq %r13
callq 0x2c0d75
addq $0x10, %rsp
movq 0x38(%rsp), %rdx
addq %rax, %rdx
movq 0x28(%r15), %r13
cmpq %r13, %rdx
movq 0x18(%rsp), %r12
movq 0x20(%rsp), %rax
jae 0x2c0adb
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x2c0cd6
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x2c0d5d
movq %r15, 0x18(%rax)
testq %r14, %r14
je 0x2c0c70
movq %rax, 0x18(%r14)
jmp 0x2c0c7d
movq %rbx, %rdi
callq 0x2c1086
movq %rax, %r15
andq $0x0, 0x20(%rax)
movups (%r12), %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x28(%rax)
andq $0x0, 0x18(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2c0d5d
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x2c0c6a
movq %r15, 0x20(%rax)
movq %r15, 0x10(%rbx)
jmp 0x2c0c7d
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, 0x10(%rsp)
movq %r8, 0x20(%rsp)
callq 0x7055e
decq %rax
movq %r12, %rdi
movl 0xc(%rsp), %esi
movq 0x30(%rsp), %rdx
movq %rbp, %rcx
movq 0x20(%rsp), %r8
movl 0x10(%rsp), %r9d
pushq %rax
pushq %r13
callq 0x2c0d75
addq $0x10, %rsp
movq 0x38(%rsp), %rdx
addq %rax, %rdx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rcx
callq 0x2c0df6
testq %r14, %r14
jne 0x2c0c2a
movq 0x28(%rsp), %rcx
movq %rax, 0x10(%rcx)
testq %rax, %rax
jne 0x2c0c79
jmp 0x2c0c7d
movq 0x17726a(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2430b(%rip), %rsi     # 0x2e5013
leaq 0xc3a78(%rip), %rdx     # 0x384787
leaq 0xc3a3e(%rip), %rcx     # 0x384754
leaq 0xc3a52(%rip), %r8      # 0x38476f
movl $0x205, %r9d            # imm = 0x205
jmp 0x2c0d51
movq 0x17723c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x242dd(%rip), %rsi     # 0x2e5013
leaq 0xc3a03(%rip), %rdx     # 0x384740
leaq 0xc3a10(%rip), %rcx     # 0x384754
leaq 0xc3a24(%rip), %r8      # 0x38476f
movl $0x1f4, %r9d            # imm = 0x1F4
xorl %eax, %eax
callq 0x17a50
callq 0x17390