// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/eis-sequencemultiread.c
// Function: seqReaderSetMove2Backlog
static void
seqReaderSetMove2Backlog(void *backlogState, const void *seqData,
                         GtUword requestStart, size_t requestLen)
{
  GtUword requestMinPos;
  struct seqReaderSet *readerSet = backlogState;
  gt_assert(backlogState && (requestLen?(seqData!=NULL):1));
  requestMinPos = seqReaderSetFindMinOpenRequest(readerSet);
  /* 1. pass all data to be invalidated to automatic sinks */
  {
    int i, numAutoConsumers = readerSet->numAutoConsumers;
    struct seqSinkState *sinks = readerSet->autoConsumerList;
    /* The following must hold, as writer is not defined */
    gt_assert(numAutoConsumers == 0);
    for (i = 0; i < numAutoConsumers; ++i)
    {
      SDWWrite(sinks[i].writer, seqData, requestLen);
    }
  }
  /* 2. move still unread old values as far as possible to head of copy */
  gt_assert(requestMinPos >= readerSet->backlogStartPos);
  if (requestMinPos < readerSet->backlogStartPos + readerSet->backlogLen)
  {
    size_t backlogUnread
      = readerSet->backlogLen - requestMinPos + readerSet->backlogStartPos;
    memmove(readerSet->seqDataBacklog,
            (char *)readerSet->seqDataBacklog
            + (requestMinPos - readerSet->backlogStartPos)
            * readerSet->backlogElemSize,
            readerSet->backlogElemSize * backlogUnread);
    readerSet->backlogLen = backlogUnread;
    readerSet->backlogStartPos = requestMinPos;
  }
  else
  {
    readerSet->backlogLen = 0;
    readerSet->backlogStartPos = requestMinPos;
  }
  {
    GtUword copyStartPos = GT_MAX(requestMinPos, requestStart);
    size_t copyLen = requestLen - copyStartPos + requestStart;
    /* 3. extend backlog to also accept all invalidated values still needed */
    if (copyLen)
    {
      GtUword *destSptr;

      size_t idx, backlogSizeLeft
        = readerSet->backlogSize - readerSet->backlogLen;
      if (copyLen > backlogSizeLeft)
      {
        size_t newSize = readerSet->backlogLen + copyLen;
        readerSet->seqDataBacklog
          = gt_realloc(readerSet->seqDataBacklog, readerSet->backlogElemSize
                       * newSize);
        readerSet->backlogSize = newSize;
      }
      destSptr = ((GtUword *) readerSet->seqDataBacklog) +
                 readerSet->backlogLen;
      if (readerSet->fromSuffixsortspace)
      {
        GtSuffixsortspace *srcSptr = (GtSuffixsortspace *) seqData;
        for (idx = 0; idx< copyLen; idx++)
        {
          destSptr[idx]
            = gt_suffixsortspace_getdirect(srcSptr,
                                           copyStartPos - requestStart + idx);
        }
      } else
      {
        ESASuffixptr *srcSptr
          = ((ESASuffixptr *) seqData) + (copyStartPos - requestStart);
        for (idx = 0; idx< copyLen; idx++)
        {
          destSptr[idx] = ESASUFFIXPTRGET(srcSptr,idx);
        }
      }
      /*
      memcpy((char *)readerSet->seqDataBacklog
             + readerSet->backlogLen * readerSet->backlogElemSize,
             (char *)seqData
             + (copyStartPos - requestStart) * readerSet->backlogElemSize,
             readerSet->backlogElemSize * copyLen);
      */
      readerSet->backlogLen += copyLen;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x19e929
movq %rcx, %r14
movq %rsi, %r15
testq %rcx, %rcx
sete %al
testq %rsi, %rsi
setne %cl
orb %al, %cl
je 0x19e929
movq %rdx, %r8
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movq $-0x1, %r12
testq %rax, %rax
je 0x19e821
movq 0x8(%rax), %rcx
movq (%rax), %rdx
cmpq %rcx, %r12
cmovaeq %rcx, %r12
movq %rdx, %rax
testq %rdx, %rdx
jne 0x19e80b
cmpl $0x0, 0x4(%rbx)
jne 0x19e92e
movq 0x20(%rbx), %rax
movq %r12, %rsi
subq %rax, %rsi
jb 0x19e933
movq 0x38(%rbx), %r13
leaq (%rax,%r13), %rcx
cmpq %rcx, %r12
jae 0x19e86e
subq %r12, %r13
addq %rax, %r13
movq 0x40(%rbx), %rdx
movq 0x48(%rbx), %rdi
imulq %rdx, %rsi
addq %rdi, %rsi
imulq %r13, %rdx
movq %r8, %rbp
callq 0x17cd0
movq %rbp, %r8
jmp 0x19e871
xorl %r13d, %r13d
movq %r13, 0x38(%rbx)
movq %r12, 0x20(%rbx)
cmpq %r8, %r12
cmovbeq %r8, %r12
movq %r14, %rbp
subq %r12, %rbp
addq %r8, %rbp
je 0x19e91a
movq 0x30(%rbx), %rax
subq %r13, %rax
cmpq %rax, %rbp
jbe 0x19e8d1
addq %rbp, %r13
movq 0x48(%rbx), %rdi
movq 0x40(%rbx), %rsi
imulq %r13, %rsi
leaq 0x205082(%rip), %rdx    # 0x3a3933
movl $0x147, %ecx            # imm = 0x147
movq %r8, (%rsp)
callq 0x104461
movq (%rsp), %r8
movq %rax, 0x48(%rbx)
movq %r13, 0x30(%rbx)
movq 0x38(%rbx), %r13
jmp 0x19e8d5
movq 0x48(%rbx), %rax
leaq (%rax,%r13,8), %r13
subq %r8, %r12
cmpb $0x1, 0x28(%rbx)
jne 0x19e8ff
movq %r15, %rdi
movq %r12, %rsi
callq 0x1fc7ed
movq %rax, (%r13)
incq %r12
addq $0x8, %r13
cmpq %r12, %r14
jne 0x19e8e2
jmp 0x19e916
leaq (%r15,%r12,8), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rdx, (%r13,%rcx,8)
incq %rcx
cmpq %rcx, %rbp
jne 0x19e905
addq %rbp, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x60621
callq 0x605af
callq 0x605e8