// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/esa-maxpairs.c
// Function: processleafedge_maxpairs
static int processleafedge_maxpairs(bool firstsucc,
                                    GtUword fatherdepth,
                                    GtBUinfo_maxpairs *father,
                                    GtUword leafnumber,
                                    GtBUstate_maxpairs *state,
                                    GtError *err)
{
  unsigned int base;
  GtUword *start, *spptr;
  GtUchar leftchar;

#undef SKDEBUG
#ifdef SKDEBUG
  printf("%s "GT_WU" firstsucc=%s, depth(father)= "GT_WU"\n",
         __func__,
         leafnumber,
         firstsucc ? "true" : "false",
         fatherdepth);
#endif
  if (fatherdepth < (GtUword) state->searchlength)
  {
    setpostabto0_maxpairs(state);
    return 0;
  }
  if (leafnumber == 0)
  {
    leftchar = INITIALCHAR;
  } else
  {
    /* Random access */
    if (state->genericencseq.hasencseq)
    {
      leftchar = gt_encseq_get_encoded_char(state->genericencseq.seqptr.encseq,
                                            leafnumber - 1,
                                            state->readmode);
    } else
    {
      leftchar = state->sequence[leafnumber-1];
    }
  }
  state->initialized = false;
#ifdef SKDEBUG
  printf("%s: leftchar %u\n",__func__,(unsigned int) leftchar);
#endif
  if (firstsucc)
  {
    father->commonchar = leftchar;
    father->uniquecharposlength = 0;
    father->uniquecharposstart = state->uniquechar.nextfreeGtUword;
    for (base = 0; base < state->alphabetsize; base++)
    {
      NODEPOSLISTSTART(father,base) = state->poslist[base].nextfreeGtUword;
      NODEPOSLISTLENGTH(father,base) = 0;
    }
    add2poslist_maxpairs(state,father,(unsigned int) leftchar,leafnumber);
    return 0;
  }
  if (father->commonchar != ISLEFTDIVERSE)
  {
    CHECKCHAR(leftchar);
  }
  if (father->commonchar == ISLEFTDIVERSE)
  {
    for (base = 0; base < state->alphabetsize; base++)
    {
      if (leftchar != (GtUchar) base)
      {
        if (cartproduct1_maxpairs(state,fatherdepth,father,base,leafnumber,
                                  err) != 0)
        {
          return -1;
        }
      }
    }
    start = state->uniquechar.spaceGtUword +
            father->uniquecharposstart;
    for (spptr = start; spptr < start + father->uniquecharposlength; spptr++)
    {
      if (state->processmaxpairs(state->processmaxpairsinfo,
                                 &state->genericencseq,
                                 fatherdepth,
                                 GT_MIN(leafnumber,*spptr),
                                 GT_MAX(leafnumber,*spptr),err) != 0)
      {
        return -2;
      }
    }
  }
  add2poslist_maxpairs(state,father,(unsigned int) leftchar,leafnumber);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r14
movl 0x4(%r8), %eax
movq %rsi, 0x10(%rsp)
cmpq %rsi, %rax
jbe 0x14f057
movq %r14, %rdi
callq 0x14f5a4
jmp 0x14f12a
movq %r9, %r12
movq %rcx, %rbx
movq %rdx, %r15
movl %edi, %r13d
testq %rcx, %rcx
je 0x14f084
cmpb $0x1, 0x30(%r14)
jne 0x14f08d
movq 0x38(%r14), %rdi
leaq -0x1(%rbx), %rsi
movl 0x48(%r14), %edx
callq 0x705e4
movl %eax, %ebp
jmp 0x14f096
movb 0x8(%r14), %bpl
incb %bpl
jmp 0x14f096
movq 0x40(%r14), %rax
movb -0x1(%rax,%rbx), %bpl
movb $0x0, (%r14)
testb %r13b, %r13b
je 0x14f0e2
movb %bpl, (%r15)
andq $0x0, 0x10(%r15)
movq 0x20(%r14), %rax
movq %rax, 0x8(%r15)
movl 0x8(%r14), %eax
imulq $0x18, %rax, %rax
pushq $0x8
popq %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x14f118
movq 0x28(%r14), %rsi
movq 0x10(%rsi,%rdx), %rsi
movq 0x18(%r15), %rdi
movq %rsi, -0x8(%rdi,%rcx)
andq $0x0, (%rdi,%rcx)
addq $0x18, %rdx
addq $0x10, %rcx
jmp 0x14f0bc
movb (%r15), %cl
movl 0x8(%r14), %eax
movzbl %bpl, %esi
cmpb %al, %cl
movq %r12, 0x8(%rsp)
movl %esi, 0x4(%rsp)
je 0x14f108
cmpb %bpl, %cl
jne 0x14f13b
movzbl %al, %edx
movl %ebp, %ecx
cmpl %esi, %edx
jbe 0x14f13b
cmpb %al, %cl
je 0x14f13e
movq %r14, %rdi
movq %r15, %rsi
movl 0x4(%rsp), %edx
jmp 0x14f122
movzbl %bpl, %edx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rcx
callq 0x14f5d0
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb %al, (%r15)
xorl %r12d, %r12d
movq 0x8(%rsp), %r13
cmpl %eax, %r12d
jae 0x14f176
cmpb %r12b, %bpl
je 0x14f171
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movl %r12d, %ecx
movq %rbx, %r8
movq %r13, %r9
callq 0x14f711
testl %eax, %eax
jne 0x14f1d4
movl 0x8(%r14), %eax
incl %r12d
jmp 0x14f146
movq 0x8(%r15), %r13
shlq $0x3, %r13
addq 0x10(%r14), %r13
leaq 0x30(%r14), %r12
movq %r13, %rbp
movq 0x10(%r15), %rax
leaq (,%rax,8), %rax
addq %r13, %rax
cmpq %rax, %rbp
jae 0x14f10c
movq (%rbp), %r8
cmpq %rbx, %r8
movq %rbx, %rcx
cmovbq %r8, %rcx
movq 0x68(%r14), %rdi
cmovbeq %rbx, %r8
movq %r12, %rsi
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %r9
callq *0x50(%r14)
addq $0x8, %rbp
testl %eax, %eax
je 0x14f189
pushq $-0x2
jmp 0x14f1d6
pushq $-0x1
popq %rax
jmp 0x14f12c