// File: /workspace/github_c_makefile_star2_O1/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 0x1a708a
movq %rcx, %rbx
movq %rsi, %r15
testq %rcx, %rcx
sete %al
testq %rsi, %rsi
setne %cl
orb %al, %cl
je 0x1a708a
movq %rdx, %r12
movq %rdi, %r14
movq 0x10(%rdi), %rax
movq $-0x1, %r13
testq %rax, %rax
je 0x1a6f79
movq 0x8(%rax), %rcx
movq (%rax), %rdx
cmpq %rcx, %r13
cmovaeq %rcx, %r13
movq %rdx, %rax
testq %rdx, %rdx
jne 0x1a6f63
cmpl $0x0, 0x4(%r14)
jne 0x1a708f
movq 0x20(%r14), %rax
movq %r13, %rsi
subq %rax, %rsi
jb 0x1a7094
movq 0x38(%r14), %rbp
leaq (%rax,%rbp), %rcx
cmpq %rcx, %r13
jae 0x1a6fc1
subq %r13, %rbp
addq %rax, %rbp
movq 0x40(%r14), %rdx
movq 0x48(%r14), %rdi
imulq %rdx, %rsi
addq %rdi, %rsi
imulq %rbp, %rdx
callq 0x17cd0
jmp 0x1a6fc3
xorl %ebp, %ebp
movq %rbp, 0x38(%r14)
movq %r13, 0x20(%r14)
cmpq %r12, %r13
cmovbeq %r12, %r13
subq %r13, %rbx
addq %r12, %rbx
je 0x1a707b
movq 0x30(%r14), %rax
subq %rbp, %rax
cmpq %rax, %rbx
jbe 0x1a7012
addq %rbx, %rbp
movq 0x48(%r14), %rdi
movq 0x40(%r14), %rsi
imulq %rbp, %rsi
leaq 0x205ea4(%rip), %rdx    # 0x3acea4
movl $0x147, %ecx            # imm = 0x147
callq 0x1094e6
movq %rax, 0x48(%r14)
movq %rbp, 0x30(%r14)
movq 0x38(%r14), %rbp
shlq $0x3, %rbp
subq %r12, %r13
addq 0x48(%r14), %rbp
cmpb $0x1, 0x28(%r14)
movq %rbx, (%rsp)
jne 0x1a7054
cmpq $0x1, %rbx
movq %rbx, %r12
adcq $0x0, %r12
xorl %ebx, %ebx
leaq (%rbx,%r13), %rsi
movq %r15, %rdi
callq 0x205eeb
movq %rax, (%rbp,%rbx,8)
incq %rbx
cmpq %rbx, %r12
jne 0x1a7039
jmp 0x1a7073
leaq (%r15,%r13,8), %rax
cmpq $0x1, %rbx
adcq $0x0, %rbx
xorl %edx, %edx
movq (%rax,%rdx,8), %rsi
movq %rsi, (%rbp,%rdx,8)
incq %rdx
cmpq %rdx, %rbx
jne 0x1a7062
movq (%rsp), %rax
addq %rax, 0x38(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x61b03
callq 0x61a91
callq 0x61aca
nopl (%rax)