// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/core/sequence_buffer_fastq.c
// Function: gt_sequence_buffer_fastq_advance
static int gt_sequence_buffer_fastq_advance(GtSequenceBuffer *sb, GtError *err)
{
  GtUword currentoutpos = 0, currentfileadd = 0, currentfileread = 0,
                seqlen = 0, desclen, cnt, newfilenum;
  GtSequenceBufferMembers *pvt;
  GtSequenceBufferFastQ *sbfq;
  const GtUchar *seq;
  char *desc;
  int had_err = 0;
  gt_error_check(err);

  sbfq = gt_sequence_buffer_fastq_cast(sb);
  pvt = sb->pvt;

  if (!sbfq->seqit) {
    sbfq->seqit = (GtSeqIteratorFastQ*)
                         gt_seq_iterator_fastq_new(sbfq->sequences, err);
    if (!sbfq->seqit) return -1;
  }

  /* did the last buffer end with a sequence boundary?
     if so, we need to provide an additional separator! */
  if (sbfq->carryseparator) {
    pvt->outbuf[currentoutpos++] = (GtUchar) GT_SEPARATOR;
    currentfileread++;
    pvt->lastspeciallength++;
    currentfileadd++;
    sbfq->carryseparator = false;
  }

  if (gt_str_length(sbfq->overflowbuffer) > 0) {
    /* we still have surplus sequence from the last line, process that first */
    const char *overflowedstring;
    char cc;
    overflowedstring = gt_str_get(sbfq->overflowbuffer);
    while (!had_err && currentoutpos < (GtUword) OUTBUFSIZE
             &&(cc = *(overflowedstring)) != '\0')
    {
      if ((had_err = process_char(sb, currentoutpos, cc, err)))
          return had_err;
      currentoutpos++;
      currentfileadd++;
      currentfileread++;
      overflowedstring++;
    }
    /* still sequence left in overflowbuffer? */
    if (*(overflowedstring) != '\0') {
      gt_str_set(sbfq->overflowbuffer, overflowedstring);
    } else {
      pvt->outbuf[currentoutpos++] = (GtUchar) GT_SEPARATOR;
      currentfileread++;
      pvt->lastspeciallength++;
      gt_str_reset(sbfq->overflowbuffer);
      gt_assert(gt_str_length(sbfq->overflowbuffer) == 0);
    }
  }

  /* we need more than one round to deal with the overflowed sequence */
  if (gt_str_length(sbfq->overflowbuffer) > 0) {
    pvt->nextfree = GT_MIN(currentoutpos, OUTBUFSIZE);
    return had_err;
  }

  gt_assert(gt_str_length(sbfq->overflowbuffer) == 0);
  /* iterate over sequences */
  while (true) {
    had_err = gt_seq_iterator_next((GtSeqIterator*) sbfq->seqit, &seq, &seqlen,
                                  &desc, err);
    newfilenum = gt_seq_iterator_fastq_get_file_index(sbfq->seqit);

    /* update current file info */
    if (pvt->filenum != newfilenum) {
      if (pvt->filelengthtab) {
        pvt->filelengthtab[pvt->filenum].length += (uint64_t) currentfileread;
        pvt->filelengthtab[pvt->filenum].effectivelength += (uint64_t)
                                                               currentfileadd;
      }
      currentfileread = currentfileadd = 0;
      pvt->filenum = newfilenum;
    }

    /* error check! */
    if (had_err < 0) {
      return had_err;
    }

    /* end of iterator reached */
    if (had_err == 0) {
      pvt->complete = true;
      /* remove last separator */
      pvt->outbuf[--currentoutpos] = (GtUchar) '\0';
      currentfileadd--;
      break;
    }

    /* copy sequence */
    for (cnt=0;cnt<seqlen;cnt++) {
      if (currentoutpos >= (GtUword) OUTBUFSIZE) {
        gt_str_append_char(sbfq->overflowbuffer, seq[cnt]);
      } else {
        if ((had_err = process_char(sb, currentoutpos, seq[cnt], err)))
          return had_err;
        currentoutpos++;
        currentfileadd++;
        currentfileread++;
      }
    }

    /* place separator after sequence (or defer) */
    if (gt_str_length(sbfq->overflowbuffer) == 0) {
      if (currentoutpos >= (GtUword) OUTBUFSIZE)
        sbfq->carryseparator = true;
      else {
        pvt->outbuf[currentoutpos++] = (GtUchar) GT_SEPARATOR;
        pvt->lastspeciallength++;
        currentfileadd++;
      }
    }

    desclen = strlen(desc)+1;
    currentfileread += desclen; /* XXX: we cannot know whether the desc was */
    pvt->counter += desclen;    /*      repeated before the qualities line  */

    /* enqueue description */
    if (pvt->descptr) {
      int i;
      for (i = 0; i < strlen(desc); i++) {
        gt_desc_buffer_append_char(pvt->descptr, desc[i]);
      }
      gt_desc_buffer_finish(pvt->descptr);
    }

    /* if buffer is full, return it */
    if (currentoutpos >= (GtUword) OUTBUFSIZE) {
      pvt->nextfree = GT_MIN(currentoutpos, OUTBUFSIZE);
      had_err = 0;
      break;
    }
  }

  /* update information about read characters */
  if (pvt->filelengthtab) {
    pvt->filelengthtab[pvt->filenum].length
      += (uint64_t) currentfileread;
    pvt->filelengthtab[pvt->filenum].effectivelength
      += (uint64_t) currentfileadd;
  }
  pvt->nextfree = GT_MIN(currentoutpos, OUTBUFSIZE);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %r14
andq $0x0, 0x28(%rsp)
testq %rsi, %rsi
je 0x609e7
movq %r15, %rdi
callq 0xc103
testb %al, %al
jne 0x60d14
leaq 0xcbe1a(%rip), %rdi     # 0x12c808
movq %r14, %rsi
callq 0x5e96e
movq %rax, %r13
movq 0x8(%r14), %rbx
cmpq $0x0, 0x10(%rax)
jne 0x60a1d
movq 0x18(%r13), %rdi
movq %r15, %rsi
callq 0x862ff
movq %rax, 0x10(%r13)
testq %rax, %rax
je 0x60cc4
cmpb $0x1, 0x20(%r13)
jne 0x60a3a
movb $-0x1, 0x2079(%rbx)
incq 0x60(%rbx)
movb $0x0, 0x20(%r13)
pushq $0x1
popq %r12
jmp 0x60a3d
xorl %r12d, %r12d
movq 0x28(%r13), %rdi
callq 0x14461
testq %rax, %rax
movq %r13, 0x8(%rsp)
je 0x60a8e
movq 0x28(%r13), %rdi
callq 0x143d2
movq %rax, %r13
movb (%r13), %al
cmpq $0x2000, %r12           # imm = 0x2000
je 0x60a98
testb %al, %al
je 0x60ac3
movzbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rcx
callq 0x60e80
testl %eax, %eax
jne 0x60cc0
incq %r12
incq %r13
jmp 0x60a5c
movq %r14, 0x10(%rsp)
movq %r12, %r14
jmp 0x60afa
testb %al, %al
je 0x60ac3
movq %r14, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
movq %r13, %rsi
movq %rax, %r13
callq 0x13e63
movl $0x2000, %r14d          # imm = 0x2000
movl $0x2000, %r12d          # imm = 0x2000
jmp 0x60afa
movq %r14, 0x10(%rsp)
movb $-0x1, 0x2079(%rbx,%r12)
incq 0x60(%rbx)
movq 0x8(%rsp), %r13
movq 0x28(%r13), %rdi
callq 0x1452f
movq 0x28(%r13), %rdi
callq 0x14461
testq %rax, %rax
jne 0x60d68
leaq 0x1(%r12), %r14
movq 0x28(%r13), %rdi
callq 0x14461
testq %rax, %rax
je 0x60b1f
movl $0x2000, %eax           # imm = 0x2000
cmpq %rax, %r14
cmovbq %r14, %rax
movq %rax, 0x58(%rbx)
xorl %ebp, %ebp
jmp 0x60cc7
movq 0x28(%r13), %rdi
callq 0x14461
testq %rax, %rax
jne 0x60d3e
leaq 0x20(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x18(%rsp), %rcx
movq %r14, %r13
movq %r15, 0x30(%rsp)
movq %rbx, 0x40(%rsp)
movq 0x8(%rsp), %rbx
movq 0x10(%rbx), %rdi
movq %r15, %r8
callq 0x857b1
movl %eax, %ebp
movq 0x10(%rbx), %rdi
movq 0x40(%rsp), %rbx
callq 0x858c4
movl (%rbx), %ecx
cmpq %rcx, %rax
je 0x60b93
movq 0x10(%rbx), %rdx
testq %rdx, %rdx
je 0x60b8b
shlq $0x4, %rcx
addq %r14, (%rdx,%rcx)
addq %r12, 0x8(%rdx,%rcx)
movl %eax, (%rbx)
xorl %r14d, %r14d
xorl %r12d, %r12d
testl %ebp, %ebp
js 0x60cc7
je 0x60cd8
movq %rbx, %r15
xorl %ebx, %ebx
cmpq 0x28(%rsp), %rbx
jae 0x60c00
cmpq $0x2000, %r13           # imm = 0x2000
jb 0x60bcf
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
movq 0x20(%rsp), %rax
movsbl (%rax,%rbx), %esi
callq 0x140b1
jmp 0x60bfb
movq 0x20(%rsp), %rax
movzbl (%rax,%rbx), %edx
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq 0x30(%rsp), %rcx
callq 0x60e80
testl %eax, %eax
jne 0x60cc0
incq %r13
incq %r12
incq %r14
incq %rbx
jmp 0x60ba6
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x14461
testq %rax, %rax
je 0x60c18
movq %r15, %rbx
jmp 0x60c42
cmpq $0x2000, %r13           # imm = 0x2000
movq %r15, %rbx
jb 0x60c2f
movq 0x8(%rsp), %rax
movb $0x1, 0x20(%rax)
jmp 0x60c42
movb $-0x1, 0x2079(%rbx,%r13)
incq %r13
incq 0x60(%rbx)
incq %r12
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0xb260
leaq 0x1(%rax), %rcx
addq %rcx, 0x68(%rbx)
cmpq $0x0, 0x20(%rbx)
je 0x60c97
movq %rax, 0x38(%rsp)
xorl %ebx, %ebx
movq %rbp, %rdi
callq 0xb260
movq 0x20(%r15), %rdi
cmpq %rbx, %rax
jbe 0x60c8a
movsbl (%rbp,%rbx), %esi
callq 0x8396b
incq %rbx
movq 0x18(%rsp), %rbp
jmp 0x60c65
callq 0x83a7f
movq %r15, %rbx
movq 0x38(%rsp), %rax
addq %rax, %r14
incq %r14
cmpq $0x2000, %r13           # imm = 0x2000
movq 0x30(%rsp), %r15
leaq 0x20(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x18(%rsp), %rcx
jb 0x60b4d
jmp 0x60ceb
movl %eax, %ebp
jmp 0x60cc7
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x18(%rbx)
movb $0x0, 0x2078(%rbx,%r13)
decq %r13
decq %r12
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x60d03
movl (%rbx), %ecx
shlq $0x4, %rcx
addq %r14, (%rax,%rcx)
addq %r12, 0x8(%rax,%rcx)
movl $0x2000, %eax           # imm = 0x2000
cmpq %rax, %r13
cmovbq %r13, %rax
jmp 0x60b14
movq 0xcd29d(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x69341(%rip), %rsi     # 0xca066
leaq 0x6992d(%rip), %rdx     # 0xca659
leaq 0x7ba87(%rip), %rcx     # 0xdc7ba
leaq 0x7baa1(%rip), %r8      # 0xdc7db
pushq $0x33
jmp 0x60d90
movq 0xcd273(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x69317(%rip), %rsi     # 0xca066
leaq 0x7baa6(%rip), %rdx     # 0xdc7fc
leaq 0x7ba5d(%rip), %rcx     # 0xdc7ba
leaq 0x7ba77(%rip), %r8      # 0xdc7db
pushq $0x69
jmp 0x60d90
movq 0xcd249(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x692ed(%rip), %rsi     # 0xca066
leaq 0x7ba7c(%rip), %rdx     # 0xdc7fc
leaq 0x7ba33(%rip), %rcx     # 0xdc7ba
leaq 0x7ba4d(%rip), %r8      # 0xdc7db
pushq $0x5f
popq %r9
xorl %eax, %eax
callq 0xb8c0
callq 0xb300