// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x98, %rsp
leaq 0xa0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %rcx, 0x78(%rsp)
movq %r8, 0x70(%rsp)
movq %r9, 0x68(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x60(%rsp)
je 0x22e778
cmpq $0x0, 0x88(%rsp)
je 0x22e778
cmpq $0x0, 0x80(%rsp)
je 0x22e778
cmpq $0x0, 0x78(%rsp)
jne 0x22e7b0
movq 0x40d821(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2e788a(%rip), %rsi    # 0x516013
leaq 0x347d27(%rip), %rdx    # 0x5764b7
leaq 0x347d4f(%rip), %rcx    # 0x5764e6
leaq 0x347c70(%rip), %r8     # 0x57640e
movl $0x177, %r9d            # imm = 0x177
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x22e7b2
jmp 0x22e7b4
movq 0x70(%rsp), %rax
addq 0x68(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x60(%rsp), %rdi
callq 0x22edf0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jbe 0x22e812
movq 0x40d7bf(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2e7828(%rip), %rsi    # 0x516013
leaq 0x347d01(%rip), %rdx    # 0x5764f3
leaq 0x347ced(%rip), %rcx    # 0x5764e6
leaq 0x347c0e(%rip), %r8     # 0x57640e
movl $0x178, %r9d            # imm = 0x178
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x22e814
jmp 0x22e816
movq 0x70(%rsp), %rax
movq 0x60(%rsp), %rcx
movq 0x110(%rcx), %rcx
movq 0x60(%rsp), %rdx
addq 0x108(%rdx), %rcx
cmpq %rcx, %rax
jae 0x22e91a
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
movq 0x110(%rcx), %rcx
movq 0x60(%rsp), %rdx
addq 0x108(%rdx), %rcx
subq 0x70(%rsp), %rcx
cmpq %rcx, %rax
jae 0x22e86f
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x22e891
movq 0x60(%rsp), %rax
movq 0x110(%rax), %rax
movq 0x60(%rsp), %rcx
addq 0x108(%rcx), %rax
subq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x50(%rsp)
movq 0x78(%rsp), %rdi
movq 0x60(%rsp), %rcx
movq 0x118(%rcx), %rsi
movq 0x70(%rsp), %rdx
movq 0x60(%rsp), %rcx
subq 0x110(%rcx), %rdx
movq 0x50(%rsp), %rcx
movq (%rax), %r8
movq %r8, (%rsp)
movq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x22f1f0
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x58(%rsp)
movq 0x78(%rsp), %rax
addq 0x48(%rsp), %rax
movq %rax, 0x78(%rsp)
cmpq $0x0, 0x58(%rsp)
je 0x22ea53
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rcx
movq 0x118(%rcx), %rsi
movq 0x60(%rsp), %rcx
movq 0x110(%rcx), %rdx
movq 0x60(%rsp), %rcx
movq 0x108(%rcx), %rcx
callq *%rax
movq 0x60(%rsp), %rax
movq 0x108(%rax), %rcx
movq 0x60(%rsp), %rax
addq 0x110(%rax), %rcx
movq %rcx, 0x110(%rax)
movq 0x60(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
movq 0x60(%rsp), %rax
movq 0xf0(%rax), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x2e1b70
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x118(%rax)
movq 0x60(%rsp), %rax
cmpq $0x0, 0x118(%rax)
je 0x22ea4f
movq 0x60(%rsp), %rax
movq 0x108(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x60(%rsp), %rax
testb $0x1, 0xf8(%rax)
jne 0x22ea4d
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x22ea4b
movq 0x60(%rsp), %rax
movq 0x118(%rax), %rdi
movq 0x40(%rsp), %rsi
callq 0x2e9a60
cmpq $0x0, %rax
jne 0x22ea39
movq 0x60(%rsp), %rax
movb $0x1, 0xf8(%rax)
movq 0x60(%rsp), %rax
movq 0x110(%rax), %rcx
addq 0x40(%rsp), %rcx
movq 0x60(%rsp), %rax
movq %rcx, 0x100(%rax)
jmp 0x22ea4b
jmp 0x22ea3b
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x22e9e6
jmp 0x22ea4d
jmp 0x22ea51
jmp 0x22ea61
jmp 0x22ea53
jmp 0x22ea55
cmpq $0x0, 0x58(%rsp)
jne 0x22e816
movq 0x68(%rsp), %rax
subq 0x58(%rsp), %rax
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)