// File: /workspace/github_c_makefile_star2_O2/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 0x149b67
movq %rcx, %r14
movq %rsi, %r15
testq %rcx, %rcx
sete %al
testq %rsi, %rsi
setne %cl
orb %al, %cl
je 0x149b67
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
pushq $-0x1
popq %r12
movq (%rax), %rax
testq %rax, %rax
je 0x149a5d
movq 0x8(%rax), %rcx
cmpq %rcx, %r12
cmovaeq %rcx, %r12
jmp 0x149a48
cmpl $0x0, 0x4(%rbx)
jne 0x149b95
movq 0x20(%rbx), %rax
movq %r12, %rsi
subq %rax, %rsi
jb 0x149bc3
movq 0x38(%rbx), %r13
leaq (%rax,%r13), %rcx
cmpq %rcx, %r12
jae 0x149aaa
subq %r12, %r13
addq %rax, %r13
movq %rdx, %rbp
movq 0x40(%rbx), %rdx
movq 0x48(%rbx), %rdi
imulq %rdx, %rsi
addq %rdi, %rsi
imulq %r13, %rdx
callq 0x17c50
movq %rbp, %rdx
jmp 0x149aad
xorl %r13d, %r13d
movq %r13, 0x38(%rbx)
movq %r12, 0x20(%rbx)
cmpq %rdx, %r12
cmovbeq %rdx, %r12
movq %r14, %rbp
subq %r12, %rbp
addq %rdx, %rbp
je 0x149b58
movq 0x30(%rbx), %rax
subq %r13, %rax
cmpq %rax, %rbp
jbe 0x149b0d
addq %rbp, %r13
movq 0x48(%rbx), %rdi
movq 0x40(%rbx), %rsi
imulq %r13, %rsi
movq %rdx, (%rsp)
leaq 0x1fa1b9(%rip), %rdx    # 0x343caa
movl $0x147, %ecx            # imm = 0x147
callq 0x93472
movq (%rsp), %rdx
movq %rax, 0x48(%rbx)
movq %r13, 0x30(%rbx)
movq 0x38(%rbx), %r13
jmp 0x149b11
movq 0x48(%rbx), %rax
leaq (%rax,%r13,8), %r13
subq %rdx, %r12
cmpb $0x1, 0x28(%rbx)
jne 0x149b3b
cmpq %r12, %r14
je 0x149b54
movq %r15, %rdi
movq %r12, %rsi
callq 0x1af5f2
movq %rax, (%r13)
incq %r12
addq $0x8, %r13
jmp 0x149b1e
leaq (%r15,%r12,8), %rax
xorl %ecx, %ecx
cmpq %rcx, %rbp
je 0x149b54
movq (%rax,%rcx,8), %rdx
movq %rdx, (%r13,%rcx,8)
incq %rcx
jmp 0x149b41
addq %rbp, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2ee3fa(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x19b49b(%rip), %rsi    # 0x2e5013
leaq 0x1fa1c6(%rip), %rdx    # 0x343d45
leaq 0x1fa1ee(%rip), %rcx    # 0x343d74
leaq 0x1fa11d(%rip), %r8     # 0x343caa
movl $0x118, %r9d            # imm = 0x118
jmp 0x149bef
movq 0x2ee3cc(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x19b46d(%rip), %rsi    # 0x2e5013
leaq 0x1fa1e0(%rip), %rdx    # 0x343d8d
leaq 0x1fa1c0(%rip), %rcx    # 0x343d74
leaq 0x1fa0ef(%rip), %r8     # 0x343caa
movl $0x11f, %r9d            # imm = 0x11F
jmp 0x149bef
movq 0x2ee39e(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x19b43f(%rip), %rsi    # 0x2e5013
leaq 0x1fa1c8(%rip), %rdx    # 0x343da3
leaq 0x1fa192(%rip), %rcx    # 0x343d74
leaq 0x1fa0c1(%rip), %r8     # 0x343caa
movl $0x126, %r9d            # imm = 0x126
xorl %eax, %eax
callq 0x17a50
callq 0x17390