// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/esa-merge.c
// Function: gt_emissionmergedesa_stepdeleteandinsertothersuffixes
int gt_emissionmergedesa_stepdeleteandinsertothersuffixes(
                                 Emissionmergedesa *emmesa, GtError *err)
{
  Mergertrienode *tmpsmallestleaf, *tmplcpnode;
  Largelcpvalue tmpexception;
  GtUchar tmpsmalllcpvalue;
  int retval;
  GtUword tmpsuftabvalue,
         tmplcpvalue,
         tmplastbranchdepth;
  unsigned int tmpidx;

  gt_error_check(err);
  for (emmesa->buf.nextstoreidx = 0;
      emmesa->numofentries > 0 &&
      emmesa->buf.nextstoreidx < (unsigned int) SIZEOFMERGERESULTBUFFER;
      emmesa->buf.nextstoreidx++)
  {
    tmpsmallestleaf = gt_mergertrie_findsmallestnode(&emmesa->trierep);
    tmplastbranchdepth = tmpsmallestleaf->parent->depth;
    tmpidx = tmpsmallestleaf->suffixinfo.idx;
    emmesa->buf.suftabstore[emmesa->buf.nextstoreidx].idx = tmpidx;
    emmesa->buf.suftabstore[emmesa->buf.nextstoreidx].startpos
      = tmpsmallestleaf->suffixinfo.startpos;
    if (emmesa->nextpostable[tmpidx] >
       gt_encseq_total_length(emmesa->suffixarraytable[tmpidx].encseq))
    {
      gt_mergertrie_deletesmallestpath(tmpsmallestleaf,&emmesa->trierep);
      emmesa->numofentries--;
    } else
    {
      retval = gt_readnextfromstream_GtUchar(&tmpsmalllcpvalue,
                                       &emmesa->suffixarraytable[tmpidx].
                                                lcptabstream);
      if (retval < 0)
      {
        return -1;
      }
      if (retval == 0)
      {
        gt_error_set(err,"file %s: line %d: unexpected end of file when "
                        "reading lcptab",__FILE__,__LINE__);
        return -2;
      }
      if (tmpsmalllcpvalue == (GtUchar) LCPOVERFLOW)
      {
        retval = gt_readnextfromstream_Largelcpvalue(
                               &tmpexception,
                               &emmesa->suffixarraytable[tmpidx].llvtabstream);
        if (retval < 0)
        {
          return -3;
        }
        if (retval == 0)
        {
          gt_error_set(err,"file %s: line %d: unexpected end of file when "
                        "reading llvtab",__FILE__,__LINE__);
          return -4;
        }
        tmplcpvalue = tmpexception.value;
      } else
      {
        tmplcpvalue = (GtUword) tmpsmalllcpvalue;
      }
      if (tmplcpvalue > tmplastbranchdepth)
      {
        tmplastbranchdepth = tmplcpvalue;
      }
      tmplcpnode = findlargestnodeleqlcpvalue(tmpsmallestleaf,tmplcpvalue,err);
      retval = gt_readnextfromstream_GtUword(&tmpsuftabvalue,
                                         &emmesa->suffixarraytable[tmpidx].
                                         suftabstream_GtUword);
      if (retval == 0)
      {
        gt_error_set(err,"file %s: line %d: unexpected end of file when "
                      "reading suftab",__FILE__,__LINE__);
        return -6;
      }
      emmesa->nextpostable[tmpidx]++;
      fillandinsert(&emmesa->trierep,
                    tmpidx,
                    tmpsuftabvalue,
                    tmplcpnode,
                    emmesa->ident++);
      tmpsmallestleaf = gt_mergertrie_findsmallestnode(&emmesa->trierep);
      gt_mergertrie_deletesmallestpath(tmpsmallestleaf,&emmesa->trierep);
    }
    if (emmesa->numofentries > 0)
    {
      emmesa->buf.lcptabstore[emmesa->buf.nextstoreidx]
        = tmplastbranchdepth;
      emmesa->buf.lastpage = false;
    } else
    {
      emmesa->buf.lastpage = true;
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
testq %rsi, %rsi
movq %rsi, (%rsp)
je 0x3115ea
movq %rsi, %rdi
callq 0xfcc32
testb %al, %al
jne 0x3118e2
movl $0x0, 0x1c(%r14)
cmpl $0x0, 0x8(%r14)
je 0x311853
leaq 0x30028(%r14), %rbp
leaq 0x10020(%r14), %rax
movq %rax, 0x18(%rsp)
movq %rbp, 0x10(%rsp)
movq %rbp, %rdi
callq 0x31fe50
movq %rax, %r12
movq 0x20(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, 0x8(%rsp)
movl (%r12), %r15d
movl 0x1c(%r14), %eax
shlq $0x4, %rax
movq 0x18(%rsp), %rdx
movl %r15d, (%rdx,%rax)
movq 0x8(%r12), %rcx
movq %rcx, 0x8(%rdx,%rax)
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rbx
movq 0x30058(%r14), %rax
movq %r15, %r13
shlq $0x8, %r13
movq (%rax,%r13), %rdi
callq 0xe7b9c
cmpq %rax, %rbx
jbe 0x31168f
movq %r12, %rdi
movq %rbp, %rsi
callq 0x31fe6d
movl 0x8(%r14), %eax
decl %eax
movl %eax, 0x8(%r14)
movq 0x8(%rsp), %rbx
jmp 0x31181f
movq 0x30058(%r14), %rax
leaq (%rax,%r13), %rbx
addq $0xd0, %rbx
movl 0x4(%rbx), %eax
cmpl (%rbx), %eax
jb 0x3116e6
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rcx
movl $0x1, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x17b40
movq %rax, %rbp
movl %ebp, (%rbx)
movq 0x10(%rbx), %rdi
callq 0x17f00
testl %eax, %eax
jne 0x3118d8
movl $0x0, 0x4(%rbx)
xorl %eax, %eax
testl %ebp, %ebp
je 0x311889
movq 0x8(%rbx), %rcx
leal 0x1(%rax), %edx
movl %edx, 0x4(%rbx)
movl %eax, %eax
movzbl (%rcx,%rax), %ebp
cmpq $0xff, %rbp
jne 0x31176b
movq 0x30058(%r14), %rax
leaq (%rax,%r13), %rbx
addq $0xe8, %rbx
movl 0x4(%rbx), %eax
cmpl (%rbx), %eax
jb 0x311756
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rcx
movl $0x10, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x17b40
movq %rax, %rbp
movl %ebp, (%rbx)
movq 0x10(%rbx), %rdi
callq 0x17f00
testl %eax, %eax
jne 0x3118dd
movl $0x0, 0x4(%rbx)
xorl %eax, %eax
testl %ebp, %ebp
je 0x3118ae
movq 0x8(%rbx), %rcx
leal 0x1(%rax), %edx
movl %edx, 0x4(%rbx)
movl %eax, %eax
shlq $0x4, %rax
movq 0x8(%rcx,%rax), %rbp
movq (%rsp), %rdi
movq 0x8(%rsp), %rbx
cmpq %rbx, %rbp
cmovaq %rbp, %rbx
testq %rdi, %rdi
je 0x31178d
callq 0xfcc32
testb %al, %al
jne 0x3118d3
movq 0x20(%r12), %r12
testq %r12, %r12
je 0x3117a0
cmpq %rbp, 0x28(%r12)
ja 0x31178d
jmp 0x3117b5
movq (%rsp), %rdi
leaq 0xd07dc(%rip), %rsi     # 0x3e1f87
movq %rbp, %rdx
xorl %eax, %eax
callq 0xfcb67
movq 0x30058(%r14), %rax
leaq (%rax,%r13), %rsi
addq $0xa0, %rsi
leaq 0x20(%rsp), %rdi
callq 0x3118e7
testl %eax, %eax
je 0x311864
movq 0x10(%r14), %rax
incq (%rax,%r15,8)
movq 0x20(%rsp), %rax
incq (%r14)
movl %r15d, 0x28(%rsp)
movq %rax, 0x30(%rsp)
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
leaq 0x28(%rsp), %rdx
callq 0x31fa2c
movq %rbp, %rdi
callq 0x31fe50
movq %rax, %rdi
movq %rbp, %rsi
callq 0x31fe6d
movl 0x8(%r14), %eax
testl %eax, %eax
je 0x311847
movl 0x1c(%r14), %eax
movq %rbx, 0x20(%r14,%rax,8)
movb $0x0, 0x30020(%r14)
incl %eax
movl %eax, 0x1c(%r14)
cmpl $0x2000, %eax           # imm = 0x2000
jb 0x311615
jmp 0x311853
movb $0x1, 0x30020(%r14)
incl 0x1c(%r14)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd06c4(%rip), %rsi     # 0x3e1f2f
leaq 0xd066a(%rip), %rdx     # 0x3e1edc
movq (%rsp), %rdi
movl $0xd0, %ecx
xorl %eax, %eax
callq 0xfcb67
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
jmp 0x311855
leaq 0xd0662(%rip), %rsi     # 0x3e1ef2
leaq 0xd0645(%rip), %rdx     # 0x3e1edc
movq (%rsp), %rdi
movl $0xae, %ecx
xorl %eax, %eax
callq 0xfcb67
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x311855
leaq 0x48290(%rip), %rsi     # 0x359b45
leaq 0xd0620(%rip), %rdx     # 0x3e1edc
movq (%rsp), %rdi
movl $0xbd, %ecx
xorl %eax, %eax
callq 0xfcb67
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
jmp 0x311855
callq 0x90dc2
callq 0x90d72
callq 0x90d9a
callq 0x90d39