// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/esa-dfs.c
// Function: gt_depthfirstesa
int gt_depthfirstesa(Sequentialsuffixarrayreader *ssar,
                  Dfsinfo *(*allocateDfsinfo)(Dfsstate *),
                  void(*freeDfsinfo)(Dfsinfo *,Dfsstate *),
                  int(*processleafedge)(bool,GtUword,Dfsinfo *,
                                        GtUword,Dfsstate *,
                                        GtError *),
                  int(*processbranchedge)(bool,
                                          GtUword,
                                          Dfsinfo *,
                                          Dfsinfo *,
                                          Dfsstate *,
                                          GtError *),
                  int(*processcompletenode)(GtUword,
                                            Dfsinfo *,GtUword,
                                            Dfsstate *,GtError *),
                  void (*assignleftmostleaf)(Dfsinfo *,GtUword,
                                             Dfsstate *),
                  void (*assignrightmostleaf)(Dfsinfo *,GtUword,
                                              GtUword,
                                              GtUword,Dfsstate *),
                  Dfsstate *state,
                  GT_UNUSED GtLogger *logger,
                  GtError *err)
{
  bool firstedge,
       firstrootedge;
  GtUword previoussuffix = 0,
         previouslcp,
         currentindex,
         currentlcp = 0, /* May be necessary if currentlcp is used after the
                            outer while loop */
         nonspecials,
         allocatedItvinfo = 0,
         nextfreeItvinfo = 0;
  Itvinfo *stackspace = NULL;
  bool haserr = false;

  firstrootedge = true;
  PUSHDFS(0,true);
  if (assignleftmostleaf != NULL)
  {
    assignleftmostleaf(TOP.dfsinfo,0,state);
  }
  nonspecials = gt_Sequentialsuffixarrayreader_nonspecials(ssar);
  for (currentindex = 0; currentindex < nonspecials; currentindex++)
  {
    SSAR_NEXTSEQUENTIALLCPTABVALUE(currentlcp,ssar);
    SSAR_NEXTSEQUENTIALSUFTABVALUE(previoussuffix,ssar);
    while (currentlcp < TOP.depth)
    {
      if (TOP.lastisleafedge)
      {
        if (processleafedge != NULL &&
            processleafedge(false,TOP.depth,TOP.dfsinfo,
                            previoussuffix,state,err) != 0)
        {
          haserr = true;
          break;
        }
      } else
      {
        gt_assert(nextfreeItvinfo < allocatedItvinfo);
        if (processbranchedge != NULL &&
            processbranchedge(false,
                              TOP.depth,
                              TOP.dfsinfo,
                              ABOVETOP.dfsinfo,
                              state,
                              err) != 0)
        {
          haserr = true;
          break;
        }
      }
      if (assignrightmostleaf != NULL)
      {
        assignrightmostleaf(TOP.dfsinfo,
                            currentindex,
                            previoussuffix,
                            currentlcp,
                            state);
      }
      if (processcompletenode != NULL &&
          processcompletenode(TOP.depth,TOP.dfsinfo,
                              nextfreeItvinfo >= 2UL ? BELOWTOP.depth
                                                     : 0,
                              state,err) != 0)
      {
        haserr = true;
        break;
      }
      gt_assert(nextfreeItvinfo > 0);
      nextfreeItvinfo--;
    }
    if (haserr)
    {
      break;
    }
    if (currentlcp == TOP.depth)
    {
      if (firstrootedge && TOP.depth == 0)
      {
        firstedge = true;
        firstrootedge = false;
      } else
      {
        firstedge = false;
      }
      if (TOP.lastisleafedge)
      {
        if (processleafedge != NULL &&
            processleafedge(firstedge,TOP.depth,TOP.dfsinfo,
                            previoussuffix,state,err) != 0)
        {
          haserr = true;
          break;
        }
      } else
      {
        if (!firstedge)
        {
          gt_assert(nextfreeItvinfo < allocatedItvinfo);
        }
        if (processbranchedge != NULL &&
            processbranchedge(firstedge,
                              TOP.depth,
                              TOP.dfsinfo,
                              /*firstedge ? NULL : ABOVETOP.dfsinfo,*/
                              ABOVETOP.dfsinfo,
                              state,
                              err) != 0)
        {
          haserr = true;
          break;
        }
        TOP.lastisleafedge = true;
      }
    } else
    {
      PUSHDFS(currentlcp,true);
      if (BELOWTOP.lastisleafedge)
      {
        if (assignleftmostleaf != NULL)
        {
          assignleftmostleaf(TOP.dfsinfo,currentindex,state);
        }
        if (processleafedge != NULL &&
            processleafedge(true,
                            TOP.depth,
                            TOP.dfsinfo,
                            previoussuffix,
                            state,
                            err) != 0)
        {
          haserr = true;
          break;
        }
        BELOWTOP.lastisleafedge = false;
      } else
      {
        previouslcp = TOP.depth;
        if (processbranchedge != NULL &&
            processbranchedge(true,
                              previouslcp,
                              TOP.dfsinfo,
                              NULL, /* not used since firstsucc = true */
                              state,
                              err) != 0)
        {
          haserr = true;
          break;
        }
      }
    }
    gt_assert(!haserr);
  }
  freeItvinfo(stackspace,
              allocatedItvinfo,
              freeDfsinfo,
              state);
  return haserr ? -1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, 0x50(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, %r13
movq %rsi, %rcx
movq %rdi, 0x10(%rsp)
movq 0xc0(%rsp), %r14
movq 0xb0(%rsp), %rbp
xorl %ebx, %ebx
movl $0x20, %r15d
movl $0x20, %edx
xorl %edi, %edi
xorl %esi, %esi
movq %rcx, 0x68(%rsp)
movq %r14, %r8
callq 0x31b7ff
movq %rax, %r12
movq $0x0, 0x8(%rax)
movb $0x1, (%rax)
testq %rbp, %rbp
je 0x31b079
movq 0x10(%r12), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq *%rbp
movq 0x10(%rsp), %rdi
callq 0x1ae599
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x31b791
movq %r13, 0x60(%rsp)
movl $0x20, %r15d
movl $0x1, %ebp
movb $0x1, %al
movl %eax, 0x24(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ebx, %ebx
movq $0x0, 0x28(%rsp)
movq %rax, 0x48(%rsp)
movq 0xc0(%rsp), %r13
movq 0x10(%rsp), %rsi
cmpb $0x1, 0x40(%rsi)
jne 0x31b187
movq (%rsi), %r13
movl 0xd4(%r13), %eax
cmpl 0xd0(%r13), %eax
jb 0x31b147
movq 0xd8(%r13), %rdi
movq 0xe0(%r13), %rcx
movl $0x1, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x17b40
movq %rax, %r14
movl %r14d, 0xd0(%r13)
movq 0xe0(%r13), %rdi
callq 0x17f00
testl %eax, %eax
jne 0x31b7e6
movl $0x0, 0xd4(%r13)
testl %r14d, %r14d
movq 0x10(%rsp), %rsi
je 0x31b3a5
movq 0xd8(%r13), %rax
movl 0xd4(%r13), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0xd4(%r13)
movb (%rax,%rcx), %al
movq %rax, 0x48(%rsp)
xorl %eax, %eax
testb %al, %al
movq 0xc0(%rsp), %r13
jne 0x31b1c5
movq 0x48(%rsp), %rax
cmpb $-0x1, %al
je 0x31b2cb
movzbl %al, %ebx
jmp 0x31b1c0
movq 0x20(%rsi), %rax
cmpq 0x10(%rsi), %rax
jae 0x31b1c5
movq (%rsi), %rcx
movq 0x60(%rcx), %rdx
leaq 0x1(%rax), %rsi
movq 0x10(%rsp), %rdi
movq %rsi, 0x20(%rdi)
movq 0x10(%rsp), %rsi
movzbl (%rdx,%rax), %ebx
cmpq $0xff, %rbx
movq %rbx, 0x48(%rsp)
je 0x31b296
movb $0x1, %r14b
jmp 0x31b1c8
xorl %r14d, %r14d
testb %r14b, %r14b
je 0x31b782
movq (%rsi), %r14
cmpb $0x1, 0x40(%rsi)
jne 0x31b200
movq 0xb0(%r14), %rcx
testq %rcx, %rcx
je 0x31b21e
movl 0xa4(%r14), %eax
cmpl 0xa0(%r14), %eax
jae 0x31b23c
movq 0x8(%rsp), %rax
jmp 0x31b421
movq 0x58(%r14), %rax
movq 0x18(%rsi), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x18(%rsi)
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
jmp 0x31b490
movl 0x8c(%r14), %eax
cmpl 0x88(%r14), %eax
jae 0x31b3ac
movq 0x8(%rsp), %rax
jmp 0x31b45f
movq 0xa8(%r14), %rdi
movl $0x8, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x17b40
movq %rax, 0x40(%rsp)
movl %eax, 0xa0(%r14)
movq 0xb0(%r14), %rdi
callq 0x17f00
testl %eax, %eax
je 0x31b406
movq 0xd0(%rsp), %rdi
leaq 0x479cd(%rip), %rsi     # 0x362c4e
leaq 0xd0de7(%rip), %rdx     # 0x3ec06f
xorl %eax, %eax
callq 0x1019cf
movb $0x1, %al
jmp 0x31b421
movq 0x68(%rcx), %rcx
movq 0x28(%rsi), %rdx
movq %rsi, %rdi
movq %rdx, %rsi
shlq $0x4, %rsi
cmpq %rax, (%rcx,%rsi)
jne 0x31b7f5
addq %rsi, %rcx
incq %rdx
movq %rdx, 0x28(%rdi)
movq 0x8(%rcx), %rbx
movb $0x1, %r14b
movq %rdi, %rsi
jmp 0x31b1c8
movq (%rsi), %r13
movl 0xec(%r13), %eax
cmpl 0xe8(%r13), %eax
jb 0x31b332
movq 0xf0(%r13), %rdi
movq 0xf8(%r13), %rcx
movl $0x10, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x17b40
movq %rax, %r14
movl %r14d, 0xe8(%r13)
movq 0xf8(%r13), %rdi
callq 0x17f00
testl %eax, %eax
jne 0x31b7fa
movl $0x0, 0xec(%r13)
testl %r14d, %r14d
movq 0x10(%rsp), %rsi
je 0x31b76e
movq 0xf0(%r13), %rax
movl 0xec(%r13), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0xec(%r13)
shlq $0x4, %rcx
movq 0x8(%rax,%rcx), %rax
xorl %r14d, %r14d
movq %rax, 0x58(%rsp)
testb %r14b, %r14b
movq 0xc0(%rsp), %r13
je 0x31b399
movq 0xd0(%rsp), %rdi
leaq 0x4782b(%rip), %rsi     # 0x362ba2
leaq 0xd01f3(%rip), %rdx     # 0x3eb571
movl $0x88, %ecx
xorl %eax, %eax
callq 0x1019cf
movq 0x10(%rsp), %rsi
movb $0x1, %al
movq %rax, 0x8(%rsp)
movq %rbx, %rax
xorb $0x1, %r14b
movq %rax, %rbx
jmp 0x31b1c8
movb $0x1, %al
jmp 0x31b169
movq 0x90(%r14), %rdi
movq 0x98(%r14), %rcx
movl $0x4, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x17b40
movq %rax, 0x40(%rsp)
movl %eax, 0x88(%r14)
movq 0x98(%r14), %rdi
callq 0x17f00
testl %eax, %eax
je 0x31b444
movq 0xd0(%rsp), %rdi
leaq 0x4785a(%rip), %rsi     # 0x362c4e
leaq 0x47c74(%rip), %rdx     # 0x36306f
xorl %eax, %eax
callq 0x1019cf
movb $0x1, %al
jmp 0x31b45f
movl $0x0, 0xa4(%r14)
cmpl $0x0, 0x40(%rsp)
movq 0x8(%rsp), %rax
je 0x31b749
movq %rax, 0x8(%rsp)
movq 0xa8(%r14), %rax
movl 0xa4(%r14), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0xa4(%r14)
movq (%rax,%rcx,8), %rax
jmp 0x31b47f
movl $0x0, 0x8c(%r14)
cmpl $0x0, 0x40(%rsp)
movq 0x8(%rsp), %rax
je 0x31b749
movq %rax, 0x8(%rsp)
movq 0x90(%r14), %rax
movl 0x8c(%r14), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x8c(%r14)
movl (%rax,%rcx,4), %eax
movq %rax, 0x18(%rsp)
movb $0x1, %r14b
testb %r14b, %r14b
je 0x31b782
leaq (,%rbp,2), %rax
addq %rbp, %rax
leaq 0x10(,%rax,8), %r14
movq 0xb0(%rsp), %rax
movq -0x20(%r12,%r14), %rsi
cmpq %rsi, %rbx
jae 0x31b597
cmpb $0x1, -0x28(%r12,%r14)
jne 0x31b4e6
cmpq $0x0, 0x38(%rsp)
je 0x31b519
movq -0x18(%r12,%r14), %rdx
xorl %edi, %edi
movq 0x18(%rsp), %rcx
movq %r13, %r8
movq 0xd0(%rsp), %r9
callq *0x38(%rsp)
jmp 0x31b511
cmpq %r15, %rbp
jae 0x31b7e1
cmpq $0x0, 0x30(%rsp)
je 0x31b519
movq -0x18(%r12,%r14), %rdx
movq (%r12,%r14), %rcx
xorl %edi, %edi
movq %r13, %r8
movq 0xd0(%rsp), %r9
callq *0x30(%rsp)
testl %eax, %eax
jne 0x31b59e
movq 0xb8(%rsp), %rax
testq %rax, %rax
je 0x31b53d
movq -0x18(%r12,%r14), %rdi
movq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rcx
movq %r13, %r8
callq *%rax
cmpq $0x0, 0x50(%rsp)
movq 0xb0(%rsp), %rax
je 0x31b581
cmpq $0x2, %rbp
jb 0x31b55a
movq -0x38(%r12,%r14), %rdx
jmp 0x31b55c
xorl %edx, %edx
movq -0x20(%r12,%r14), %rdi
movq -0x18(%r12,%r14), %rsi
movq %r13, %rcx
movq 0xd0(%rsp), %r8
callq *0x50(%rsp)
testl %eax, %eax
movq 0xb0(%rsp), %rax
jne 0x31b5aa
decq %rbp
addq $-0x18, %r14
cmpq $-0x1, %rbp
jne 0x31b4ab
jmp 0x31b7dc
movq 0x8(%rsp), %rcx
jmp 0x31b5ac
movb $0x1, %cl
movq 0xb0(%rsp), %rax
jmp 0x31b5ac
movb $0x1, %cl
movq %rcx, 0x8(%rsp)
testb $0x1, %cl
jne 0x31b782
movq -0x20(%r12,%r14), %rsi
cmpq %rsi, %rbx
jne 0x31b619
testq %rsi, %rsi
sete %al
movl 0x24(%rsp), %ecx
andb %cl, %al
movzbl %cl, %ecx
movl $0x0, %edx
cmovnel %edx, %ecx
movl %ecx, 0x24(%rsp)
cmpb $0x1, -0x28(%r12,%r14)
jne 0x31b6bf
movq 0x38(%rsp), %r10
testq %r10, %r10
je 0x31b72a
movq -0x18(%r12,%r14), %rdx
movzbl %al, %edi
movq 0x18(%rsp), %rcx
movq %r13, %r8
movq 0xd0(%rsp), %r9
callq *%r10
jmp 0x31b726
cmpq %r15, %rbp
jb 0x31b649
jne 0x31b7eb
leaq 0x20(%r15), %rdx
movq %r12, %rdi
movq %r15, %rsi
movq %rdx, %r15
movq 0x68(%rsp), %rcx
movq %r13, %r8
callq 0x31b7ff
movq %rax, %r12
movq 0xb0(%rsp), %rax
movq %rbx, -0x8(%r12,%r14)
movb $0x1, -0x10(%r12,%r14)
incq %rbp
cmpb $0x1, -0x28(%r12,%r14)
movq 0x10(%rsp), %rsi
jne 0x31b701
testq %rax, %rax
je 0x31b680
movq (%r12,%r14), %rdi
movq 0x28(%rsp), %rsi
movq %r13, %rdx
callq *%rax
movq 0x10(%rsp), %rsi
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x31b6b7
movq -0x8(%r12,%r14), %rsi
movq (%r12,%r14), %rdx
movl $0x1, %edi
movq 0x18(%rsp), %rcx
movq %r13, %r8
movq 0xd0(%rsp), %r9
callq *%rax
movq 0x10(%rsp), %rsi
testl %eax, %eax
jne 0x31b77b
movb $0x0, -0x28(%r12,%r14)
jmp 0x31b72f
cmpq %r15, %rbp
setb %cl
orb %al, %cl
je 0x31b7f0
movq 0x30(%rsp), %r10
testq %r10, %r10
je 0x31b6f9
movq -0x18(%r12,%r14), %rdx
movq (%r12,%r14), %rcx
movzbl %al, %edi
movq %r13, %r8
movq 0xd0(%rsp), %r9
callq *%r10
testl %eax, %eax
jne 0x31b77b
movb $0x1, -0x28(%r12,%r14)
jmp 0x31b72a
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x31b72f
movq (%r12,%r14), %rdx
movl $0x1, %edi
movq %rbx, %rsi
xorl %ecx, %ecx
movq %r13, %r8
movq 0xd0(%rsp), %r9
callq *%rax
testl %eax, %eax
jne 0x31b77b
movq 0x10(%rsp), %rsi
movq 0x28(%rsp), %rcx
incq %rcx
movq %rcx, 0x28(%rsp)
cmpq 0x70(%rsp), %rcx
jne 0x31b0d6
jmp 0x31b782
xorl %r14d, %r14d
movq 0xd0(%rsp), %rdi
leaq 0x478fc(%rip), %rsi     # 0x363057
xorl %eax, %eax
callq 0x1019cf
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x31b487
movb $0x1, %r14b
movq 0x58(%rsp), %rax
jmp 0x31b356
movb $0x1, %al
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
andb $0x1, %al
movzbl %al, %ebx
movq 0x60(%rsp), %r13
testq %r15, %r15
movq 0xc0(%rsp), %rbp
je 0x31b7b5
leaq 0x10(%r12), %r14
movq (%r14), %rdi
movq %rbp, %rsi
callq *%r13
addq $0x18, %r14
decq %r15
jne 0x31b7a3
leaq 0xcfdb5(%rip), %rsi     # 0x3eb571
movq %r12, %rdi
movl $0x57, %edx
callq 0x109670
negl %ebx
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x92b33
callq 0x92a88
callq 0x92a38
callq 0x92ac1
callq 0x92afa
callq 0x929ff
callq 0x92a60