// File: /workspace/github_c_makefile_star2_O3/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, 0x30(%rsp)
movq %rsi, %xmm0
movq %rdi, %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq %rcx, %xmm0
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 0x19f749
movq %r8, %r15
movq %rdi, %rbp
leaq (%r9,%r8), %rax
cmpq (%rdi), %rax
ja 0x19f74e
movq %rcx, %rbx
movq %rdx, %r13
leaq 0x108(%rbp), %rax
movq %rax, 0x28(%rsp)
movq %r9, 0x8(%rsp)
movq %r9, (%rsp)
movq %rdx, 0x18(%rsp)
movq 0x110(%rbp), %rax
movq 0x108(%rbp), %r12
addq %rax, %r12
subq %r15, %r12
jbe 0x19f637
movq (%rsp), %rcx
cmpq %r12, %rcx
cmovbq %rcx, %r12
movq 0x118(%rbp), %r13
movq %r15, 0x20(%rsp)
movq %r15, %r14
subq %rax, %r14
leaq 0x70(%rsp), %rax
movq (%rax), %rdi
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x19f63d
movq %rbx, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %r12, %r8
callq *%rax
jmp 0x19f66b
movq (%rsp), %r14
jmp 0x19f682
movq %rdi, 0x10(%rsp)
testq %r12, %r12
je 0x19f662
xorl %r15d, %r15d
leaq (%r14,%r15), %rsi
movq %r13, %rdi
callq 0x1fc7ed
movq %rax, (%rbx,%r15,8)
incq %r15
cmpq %r15, %r12
jne 0x19f64a
movq 0x10(%rsp), %rax
imulq %r12, %rax
movq 0x20(%rsp), %r15
addq %r12, %r15
movq (%rsp), %r14
subq %r12, %r14
addq %rax, %rbx
movq 0x18(%rsp), %r13
testq %r14, %r14
je 0x19f732
movq 0x118(%rbp), %rsi
movq 0x108(%rbp), %rcx
movq 0x110(%rbp), %rdx
movq 0x30(%rsp), %rdi
callq *%r13
movq 0xf0(%rbp), %rdx
movq 0x108(%rbp), %rax
addq %rax, 0x110(%rbp)
movq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x1f8bd2
movq %rax, 0x118(%rbp)
testq %rax, %rax
je 0x19f732
movq %r14, (%rsp)
movq 0x108(%rbp), %r14
testq %r14, %r14
sete %al
orb 0xf8(%rbp), %al
jne 0x19f5e3
movq %rbx, %r12
xorl %ebx, %ebx
movq 0x118(%rbp), %rdi
movq %rbx, %rsi
callq 0x1fc7ed
testq %rax, %rax
je 0x19f715
incq %rbx
cmpq %rbx, %r14
jne 0x19f6f7
jmp 0x19f72a
movb $0x1, 0xf8(%rbp)
addq 0x110(%rbp), %rbx
movq %rbx, 0x100(%rbp)
movq %r12, %rbx
jmp 0x19f5e3
movq 0x8(%rsp), %rax
subq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x60a93
callq 0x60acc