// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/eis-suffixerator-interface.c
// Function: SfxIGenerate
static size_t
SfxIGenerate(void *iface,
             void *backlogState,
             move2BacklogFunc move2Backlog,
             void *output,
             GtUword generateStart,
             size_t len,
             SeqDataTranslator xltor)
{
  sfxInterface *sfxi = iface;
  size_t elemsLeft = len;
  gt_assert(sfxi && backlogState && move2Backlog && output);
  gt_assert(generateStart + len <= gt_SfxIGetLength(sfxi));
  do
  {
    if (generateStart < sfxi->lastGeneratedStart + sfxi->lastGeneratedLen)
    {
      size_t copyLen = GT_MIN(elemsLeft, sfxi->lastGeneratedStart
                           + sfxi->lastGeneratedLen - generateStart),
        charsWritten =
        SDRTranslateSuffixsortspace(xltor, output,
                                    sfxi->lastGeneratedSufTabSegment,
                                    generateStart - sfxi->lastGeneratedStart,
                                    copyLen);
      generateStart += copyLen;
      elemsLeft -= copyLen;
      output = (char *)output + charsWritten;
    }
    /* 1. read next region of sequence by calling nextSfxIterator */
    if (elemsLeft)
    {

      move2Backlog(backlogState, sfxi->lastGeneratedSufTabSegment,
                   sfxi->lastGeneratedStart, sfxi->lastGeneratedLen);
      sfxi->lastGeneratedStart += sfxi->lastGeneratedLen;
      sfxi->lastGeneratedSufTabSegment
        = gt_Sfxiterator_next(&sfxi->lastGeneratedLen,
                              NULL,
                              sfxi->sfi);
      if (sfxi->lastGeneratedSufTabSegment != NULL)
      {
        /* size_t because the current approach cannot generate more
         * than memory will hold anyway */
        size_t pos, lastGeneratedLen = sfxi->lastGeneratedLen;

        if (!sfxi->rot0Pos.defined)
        {
          for (pos=0; pos < lastGeneratedLen; pos++)
          {
            if (gt_suffixsortspace_getdirect(sfxi->lastGeneratedSufTabSegment,
                                             pos) == 0)
            {
              sfxi->rot0Pos.defined = true;
              sfxi->rot0Pos.valueunsignedlong = sfxi->lastGeneratedStart + pos;
              break;
            }
          }
        }
        /* uncomment this to reenable synchronous writing of tables */
/*if (sfxi->lastGeneratedSufTabSegment == NULL */
/*    || suftab2file(&sfxi->outfileinfo, sfxi->lastGeneratedSufTabSegment, */
/*                   sfxi->so.readmode, sfxi->lastGeneratedLen, err) != 0) */
/*       break; */
      }
      else
        break;
    }
    /* 5. if positions in region don't suffice go back to step 3. */
  } while (elemsLeft);
  return len - elemsLeft;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x28(%rsp)
movq %rsi, %xmm0
movq %rdi, %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq %rcx, %xmm0
movq %rdx, 0x30(%rsp)
movq %rdx, %xmm2
punpcklqdq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0]
pxor %xmm0, %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm0, %xmm1
movdqa %xmm1, %xmm0
shufps $0xdd, %xmm2, %xmm0     # xmm0 = xmm0[1,3],xmm2[1,3]
shufps $0x88, %xmm2, %xmm1     # xmm1 = xmm1[0,2],xmm2[0,2]
andps %xmm0, %xmm1
movmskps %xmm1, %eax
testl %eax, %eax
jne 0x14acc7
movq %r8, %r14
movq %rdi, %rbp
leaq (%r9,%r8), %rax
cmpq (%rdi), %rax
ja 0x14acf5
movq %rcx, %r15
leaq 0x108(%rbp), %rax
movq %rax, 0x20(%rsp)
movq %r9, (%rsp)
movq %r9, %r13
movq 0x110(%rbp), %rax
movq 0x108(%rbp), %r12
addq %rax, %r12
subq %r14, %r12
jbe 0x14ac09
cmpq %r12, %r13
movq %r13, 0x10(%rsp)
cmovbq %r13, %r12
movq 0x118(%rbp), %rbx
movq %r14, 0x18(%rsp)
subq %rax, %r14
leaq 0x70(%rsp), %rax
movq (%rax), %rdi
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x14abcb
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
movq %r12, %r8
callq *%rax
jmp 0x14abf6
movq %rdi, 0x8(%rsp)
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x14abed
leaq (%r14,%r13), %rsi
movq %rbx, %rdi
callq 0x1af5f2
movq %rax, (%r15,%r13,8)
incq %r13
jmp 0x14abd3
movq 0x8(%rsp), %rax
imulq %r12, %rax
movq 0x18(%rsp), %r14
addq %r12, %r14
movq 0x10(%rsp), %r13
subq %r12, %r13
addq %rax, %r15
testq %r13, %r13
je 0x14acb1
movq 0x118(%rbp), %rsi
movq 0x108(%rbp), %rcx
movq 0x110(%rbp), %rdx
movq 0x28(%rsp), %rdi
callq *0x30(%rsp)
movq 0xf0(%rbp), %rdx
movq 0x108(%rbp), %rax
addq %rax, 0x110(%rbp)
movq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x1ab5be
movq %rax, 0x118(%rbp)
testq %rax, %rax
je 0x14acb1
cmpb $0x0, 0xf8(%rbp)
jne 0x14ab79
movq %r14, %r12
movq 0x108(%rbp), %r14
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x14aca9
movq 0x118(%rbp), %rdi
movq %rbx, %rsi
callq 0x1af5f2
testq %rax, %rax
je 0x14ac94
incq %rbx
jmp 0x14ac76
movb $0x1, 0xf8(%rbp)
addq 0x110(%rbp), %rbx
movq %rbx, 0x100(%rbp)
movq %r12, %r14
jmp 0x14ab79
movq (%rsp), %rax
subq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2ed29a(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x19a33b(%rip), %rsi    # 0x2e5013
leaq 0x1f93d1(%rip), %rdx    # 0x3440b0
leaq 0x1f93f9(%rip), %rcx    # 0x3440df
leaq 0x1f9349(%rip), %r8     # 0x344036
movl $0x177, %r9d            # imm = 0x177
jmp 0x14ad21
movq 0x2ed26c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x19a30d(%rip), %rsi    # 0x2e5013
leaq 0x1f93df(%rip), %rdx    # 0x3440ec
leaq 0x1f93cb(%rip), %rcx    # 0x3440df
leaq 0x1f931b(%rip), %r8     # 0x344036
movl $0x178, %r9d            # imm = 0x178
xorl %eax, %eax
callq 0x17a50
callq 0x17390