// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/eis-sequencemultiread.c
// Function: seqReaderSetRead
static size_t
seqReaderSetRead(void *src, void *dest, size_t len)
{
  struct seqReaderState *state = src;
  struct seqReaderSet *readerSet;
  GtUword pos;
  size_t elemsLeft;
  gt_assert(src);
  readerSet = state->readerSet;
  elemsLeft = len;
  pos = seqReaderSetGetConsumerNextPos(state);
  while (elemsLeft)
  {
    if (pos >= readerSet->backlogStartPos + readerSet->backlogLen)
    {
      /* pos is in block that's governed by generator */
      size_t elemsGenerated =
        readerSet->generator(readerSet->generatorState, readerSet,
                             seqReaderSetMove2Backlog, dest, pos, elemsLeft,
                             state->xltor);
      seqReaderSetSetConsumerNextPos(state, pos += elemsGenerated);
      elemsLeft -= elemsGenerated;
      break;
    }
    else if (pos >= readerSet->backlogStartPos
             /* implicit because of above condition
                && pos < readerSet->backlogStartPos + readerSet->backlogLen */
      )
    {
      /* pos is in backlog */
      GtUword subLen, charsWritten;

      subLen = GT_MIN(elemsLeft, readerSet->backlogStartPos - pos
                              + readerSet->backlogLen);
      gt_assert(state->xltor.translateData == NULL);
      /*
      charsWritten = SDRTranslate(state->xltor, dest,
                                  (char *)readerSet->seqDataBacklog
                                  + (pos - readerSet->backlogStartPos)
                                  * readerSet->backlogElemSize,
                                  subLen);
      */
      memcpy(dest, (char *)readerSet->seqDataBacklog
                   + (pos - readerSet->backlogStartPos)
                   * readerSet->backlogElemSize,
             subLen * state->xltor.state.elemSize);
      charsWritten = subLen * state->xltor.state.elemSize;
      elemsLeft -= subLen;
      seqReaderSetSetConsumerNextPos(state, pos += subLen);
      dest = (char *)dest + charsWritten;
    }
    else
    {
      fprintf(stderr, "fatal error at file %s, line %d\n", __FILE__, __LINE__);
      abort();
    }
  }
  return len - elemsLeft;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x1a6eda
testq %rdx, %rdx
je 0x1a6e74
movq %rsi, %r13
movq %rdi, %r14
movq 0x18(%rdi), %rbx
movq 0x8(%rdi), %r15
movq %rdx, 0x20(%rsp)
movq %rdx, %rbp
movq 0x20(%rbx), %r12
movq 0x38(%rbx), %rax
leaq (%rax,%r12), %rcx
cmpq %rcx, %r15
jae 0x1a6e78
movq %r15, %rsi
subq %r12, %rsi
jb 0x1a6ecb
cmpq $0x0, 0x38(%r14)
jne 0x1a6ed5
subq %r15, %r12
addq %rax, %r12
cmpq %r12, %rbp
cmovbq %rbp, %r12
imulq 0x40(%rbx), %rsi
addq 0x48(%rbx), %rsi
movq 0x30(%r14), %rdx
imulq %r12, %rdx
movq %r13, %rdi
callq 0x17660
addq %r12, %r15
cmpq %r15, 0x8(%r14)
ja 0x1a6ed0
movq 0x30(%r14), %rax
imulq %r12, %rax
addq %rax, %r13
movq %r15, 0x8(%r14)
subq %r12, %rbp
jne 0x1a6e04
movq 0x20(%rsp), %rdx
xorl %eax, %eax
jmp 0x1a6eb9
movq 0x50(%rbx), %rdi
movq 0x40(%r14), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x8a(%rip), %rdx        # 0x1a6f1f
movq %rbx, %rsi
movq %r13, %rcx
movq %r15, %r8
movq %rbp, %r9
callq *0x58(%rbx)
addq %rax, %r15
cmpq %r15, 0x8(%r14)
ja 0x1a6edf
movq %r15, 0x8(%r14)
subq %rbp, %rax
movq 0x20(%rsp), %rdx
addq %rdx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x61a2e
callq 0x619f7
callq 0x619be
callq 0x61a58
callq 0x61987