// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/core/seq_iterator_sequence_buffer.c
// Function: gt_seq_iterator_sequence_buffer_next
static int gt_seq_iterator_sequence_buffer_next(GtSeqIterator *si,
                                               const GtUchar **sequence,
                                               GtUword *len,
                                               char **desc,
                                               GtError *err)
{
  GtSeqIteratorSequenceBuffer *seqit;
  GtUchar charcode;
  int retval;
  bool haserr = false, foundseq = false;
  gt_assert(si);
  gt_assert(len && desc);

  seqit = gt_seq_iterator_sequence_buffer_cast(si);
  gt_assert((sequence && seqit->withsequence) || !seqit->withsequence);

  if (seqit->exhausted)
  {
    return 0;
  }
  while (true)
  {
    retval = gt_sequence_buffer_next(seqit->fb,&charcode,err);
    if (retval < 0)
    {
      haserr = true;
      break;
    }
    if (retval == 0)
    {
      seqit->exhausted = true;
      break;
    }
    if (seqit->currentread < seqit->maxread)
    {
      seqit->currentread++;
    }
    if (charcode == (GtUchar) GT_SEPARATOR)
    {
      if (seqit->sequencebuffer.nextfreeGtUchar == 0 && seqit->withsequence)
      {
        gt_error_set(err,"sequence "GT_LLU" is empty", seqit->unitnum);
        haserr = true;
        break;
      }
      *desc = (char*) gt_desc_buffer_get_next(seqit->descptr);
      *len = seqit->sequencebuffer.nextfreeGtUchar;
      if (seqit->withsequence)
      {
        /* make sure the outgoing sequence is '\0' terminated */
        seqit->sequencebuffer.spaceGtUchar
          [seqit->sequencebuffer.nextfreeGtUchar] = (GtUchar) '\0';
        *sequence = seqit->sequencebuffer.spaceGtUchar;
      }
      seqit->sequencebuffer.nextfreeGtUchar = 0;
      foundseq = true;
      seqit->unitnum++;
      break;
    }
    if (seqit->withsequence)
    {
      GT_STOREINARRAY(&seqit->sequencebuffer, GtUchar,
                   GT_MAX(1024UL, seqit->sequencebuffer.nextfreeGtUchar * 0.5),
                   charcode);
    } else
    {
      seqit->sequencebuffer.nextfreeGtUchar++;
    }
  }
  if (!haserr && seqit->sequencebuffer.nextfreeGtUchar > 0)
  {
    *desc = (char*) gt_desc_buffer_get_next(seqit->descptr);
    if (seqit->withsequence)
    {
      /* make sure the outgoing sequence is '\0' terminated */
      seqit->sequencebuffer.spaceGtUchar
        [seqit->sequencebuffer.nextfreeGtUchar] = (GtUchar) '\0';
      *sequence = seqit->sequencebuffer.spaceGtUchar;
    }
    *len = seqit->sequencebuffer.nextfreeGtUchar;
    foundseq = true;
    seqit->sequencebuffer.nextfreeGtUchar = 0;
  }
  if (haserr)
  {
    return -1;
  }
  if (foundseq)
  {
    return 1;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0xa74e8
movq %rdx, %r14
testq %rdx, %rdx
je 0xa7512
movq %rcx, %r12
testq %rcx, %rcx
je 0xa7512
movq %r8, %r13
movq %rsi, %rbp
movq %rdi, %rbx
callq 0xa7178
movq %rax, %rdi
movq %rbx, %rsi
callq 0xa615e
movq %rax, %r15
movb 0x48(%rax), %al
movq %rbp, 0x10(%rsp)
testq %rbp, %rbp
je 0xa72f2
testb $0x1, %al
jne 0xa72fa
testb $0x1, %al
jne 0xa753c
xorl %ebp, %ebp
cmpb $0x0, 0x49(%r15)
jne 0xa74a9
leaq 0xf(%rsp), %rbx
movq 0x8(%r15), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0xa7be1
testl %eax, %eax
js 0xa746a
je 0xa73fd
movq 0x50(%r15), %rax
cmpq 0x58(%r15), %rax
jae 0xa733a
incq %rax
movq %rax, 0x50(%r15)
cmpb $-0x1, 0xf(%rsp)
je 0xa7447
movq 0x38(%r15), %rax
cmpb $0x1, 0x48(%r15)
jne 0xa735f
movq 0x30(%r15), %rsi
cmpq %rsi, %rax
jae 0xa7368
movq 0x28(%r15), %rax
jmp 0xa73dc
incq %rax
movq %rax, 0x38(%r15)
jmp 0xa730c
movq %rax, %xmm0
punpckldq 0x24056b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x240573(%rip), %xmm0   # 0x2e78f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x24eac7(%rip), %xmm1   # 0x2f5e58
movsd 0x26969f(%rip), %xmm0   # 0x310a38
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x24096f(%rip), %xmm0   # 0x2e7d20
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
addq %rdx, %rsi
movq %rsi, 0x30(%r15)
movq 0x28(%r15), %rdi
leaq 0x2696a0(%rip), %rdx    # 0x310a6e
movl $0xa2, %ecx
callq 0x93472
movq %rax, 0x28(%r15)
testq %rax, %rax
je 0xa74ba
movb 0xf(%rsp), %cl
movq 0x38(%r15), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x38(%r15)
movb %cl, (%rax,%rdx)
jmp 0xa730c
movb $0x1, 0x49(%r15)
cmpq $0x0, 0x38(%r15)
je 0xa74a9
movq 0x20(%r15), %rdi
callq 0x6d106
movq %rax, (%r12)
cmpb $0x1, 0x48(%r15)
jne 0xa7439
movq 0x28(%r15), %rax
movq 0x38(%r15), %rcx
movb $0x0, (%rax,%rcx)
movq 0x28(%r15), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq 0x38(%r15), %rax
movq %rax, (%r14)
andq $0x0, 0x38(%r15)
jmp 0xa74a6
cmpq $0x0, 0x38(%r15)
jne 0xa746e
cmpb $0x1, 0x48(%r15)
jne 0xa746e
movq 0x40(%r15), %rdx
leaq 0x2696c9(%rip), %rsi    # 0x310b29
movq %r13, %rdi
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
jmp 0xa74a8
movq 0x20(%r15), %rdi
callq 0x6d106
movq %rax, (%r12)
movq 0x38(%r15), %rax
movq %rax, (%r14)
cmpb $0x1, 0x48(%r15)
jne 0xa749d
movq 0x28(%r15), %rcx
movb $0x0, (%rcx,%rax)
movq 0x28(%r15), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
andq $0x0, 0x38(%r15)
incq 0x40(%r15)
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x390aa7(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x23db48(%rip), %rsi    # 0x2e5013
leaq 0x26966e(%rip), %rdx    # 0x310b40
leaq 0x2695f1(%rip), %rcx    # 0x310aca
leaq 0x26958e(%rip), %r8     # 0x310a6e
movl $0xa2, %r9d
jmp 0xa7566
movq 0x390a79(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x23db1a(%rip), %rsi    # 0x2e5013
leaq 0x268eb4(%rip), %rdx    # 0x3103b4
leaq 0x2695c3(%rip), %rcx    # 0x310aca
leaq 0x269560(%rip), %r8     # 0x310a6e
pushq $0x6d
jmp 0xa7564
movq 0x390a4f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x23daf0(%rip), %rsi    # 0x2e5013
leaq 0x26914e(%rip), %rdx    # 0x310678
leaq 0x269599(%rip), %rcx    # 0x310aca
leaq 0x269536(%rip), %r8     # 0x310a6e
pushq $0x6e
jmp 0xa7564
movq 0x390a25(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x23dac6(%rip), %rsi    # 0x2e5013
leaq 0x26959b(%rip), %rdx    # 0x310aef
leaq 0x26956f(%rip), %rcx    # 0x310aca
leaq 0x26950c(%rip), %r8     # 0x310a6e
pushq $0x71
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390