// File: /workspace/github_c_makefile_star2_O1/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 0x11aa4a
movq %rdx, %rbx
testq %rdx, %rdx
je 0x11aa4f
movq %rcx, %r15
testq %rcx, %rcx
je 0x11aa4f
movq %r8, %r13
movq %rsi, %r14
movq %rdi, %r12
callq 0x11a6fa
movq %rax, %rdi
movq %r12, %rsi
callq 0x11997f
movq %rax, %r12
testq %r14, %r14
je 0x11a810
cmpb $0x0, 0x48(%r12)
jne 0x11a81c
cmpb $0x1, 0x48(%r12)
je 0x11aa54
xorl %eax, %eax
cmpb $0x0, 0x49(%r12)
jne 0x11a9b8
movq %r14, 0x10(%rsp)
movq 0x8(%r12), %rdi
leaq 0xf(%rsp), %rsi
movq %r13, %rdx
callq 0x11ae1e
movb $0x1, %r14b
testl %eax, %eax
js 0x11a957
leaq 0xf(%rsp), %rbp
testl %eax, %eax
je 0x11a94e
movq 0x50(%r12), %rax
cmpq 0x58(%r12), %rax
jae 0x11a86d
incq %rax
movq %rax, 0x50(%r12)
cmpb $-0x1, 0xf(%rsp)
je 0x11a9c7
cmpb $0x1, 0x48(%r12)
jne 0x11a92f
movq 0x30(%r12), %rsi
movq 0x38(%r12), %rax
cmpq %rsi, %rax
jb 0x11a90a
movq %rax, %xmm0
punpckldq 0x236040(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x236048(%rip), %xmm0   # 0x3508f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x2445bc(%rip), %xmm1   # 0x35ee78
movsd 0x25f0d4(%rip), %xmm0   # 0x379998
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x236444(%rip), %xmm0   # 0x350d20
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
addq %rdx, %rsi
movq %rsi, 0x30(%r12)
movq 0x28(%r12), %rdi
leaq 0x25f0d3(%rip), %rdx    # 0x3799ce
movl $0xa2, %ecx
callq 0x1094e6
movq %rax, 0x28(%r12)
movq 0x28(%r12), %rax
testq %rax, %rax
je 0x11aa45
movb 0xf(%rsp), %cl
movq 0x38(%r12), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x38(%r12)
movb %cl, (%rax,%rdx)
jmp 0x11a934
incq 0x38(%r12)
movq 0x8(%r12), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x11ae1e
testl %eax, %eax
jns 0x11a851
jmp 0x11a957
movb $0x1, 0x49(%r12)
xorl %r14d, %r14d
xorl %ebp, %ebp
testb %r14b, %r14b
jne 0x11a9aa
cmpq $0x0, 0x38(%r12)
je 0x11a9aa
movq 0x20(%r12), %rdi
callq 0xe926a
movq %rax, (%r15)
cmpb $0x1, 0x48(%r12)
jne 0x11a996
movq 0x28(%r12), %rax
movq 0x38(%r12), %rcx
movb $0x0, (%rax,%rcx)
movq 0x28(%r12), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq 0x38(%r12), %rax
movq %rax, (%rbx)
movq $0x0, 0x38(%r12)
movb $0x1, %bpl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %r14b, %r14b
jne 0x11a9b8
movzbl %bpl, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x38(%r12)
jne 0x11a9f4
cmpb $0x1, 0x48(%r12)
jne 0x11a9f4
movq 0x40(%r12), %rdx
leaq 0x25f0a6(%rip), %rsi    # 0x379a89
xorl %ebp, %ebp
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0x11a959
movq 0x20(%r12), %rdi
callq 0xe926a
movq %rax, (%r15)
movq 0x38(%r12), %rax
movq %rax, (%rbx)
cmpb $0x1, 0x48(%r12)
jne 0x11aa2c
movq 0x28(%r12), %rax
movq 0x38(%r12), %rcx
movb $0x0, (%rax,%rcx)
movq 0x28(%r12), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq $0x0, 0x38(%r12)
incq 0x40(%r12)
movb $0x1, %bpl
xorl %r14d, %r14d
jmp 0x11a959
callq 0x369f4
callq 0x36a64
callq 0x369bd
callq 0x36a2d