// File: /workspace/github_c_makefile_star2_O3/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 0x1152d5
movq %rdx, %r14
testq %rdx, %rdx
je 0x1152da
movq %rcx, %r12
testq %rcx, %rcx
je 0x1152da
movq %r8, %r13
movq %rsi, %rbp
movq %rdi, %rbx
callq 0x114fc2
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1142ab
movq %rax, %r15
movb 0x48(%rax), %al
movq %rbp, 0x10(%rsp)
testq %rbp, %rbp
je 0x1150dc
testb $0x1, %al
jne 0x1150e4
testb $0x1, %al
jne 0x1152df
xorl %ebp, %ebp
cmpb $0x0, 0x49(%r15)
jne 0x1152bf
movq 0x8(%r15), %rdi
leaq 0xf(%rsp), %rsi
movq %r13, %rdx
callq 0x1156aa
testl %eax, %eax
js 0x115203
leaq 0xf(%rsp), %rbx
testl %eax, %eax
je 0x11520d
movq 0x50(%r15), %rax
cmpq 0x58(%r15), %rax
jae 0x115128
incq %rax
movq %rax, 0x50(%r15)
cmpb $-0x1, 0xf(%rsp)
je 0x11525a
movq 0x38(%r15), %rax
cmpb $0x1, 0x48(%r15)
jne 0x115150
movq 0x30(%r15), %rsi
cmpq %rsi, %rax
jae 0x11515c
movq 0x28(%r15), %rax
jmp 0x1151d0
incq %rax
movq %rax, 0x38(%r15)
jmp 0x1151ec
movq %rax, %xmm0
punpckldq 0x232777(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x23277f(%rip), %xmm0   # 0x3478f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x240cc3(%rip), %xmm1   # 0x355e48
movsd 0x25b59b(%rip), %xmm0   # 0x370728
maxsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x232b7b(%rip), %xmm0   # 0x347d20
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
addq %rdx, %rsi
movq %rsi, 0x30(%r15)
movq 0x28(%r15), %rdi
leaq 0x25b59c(%rip), %rdx    # 0x37075e
movl $0xa2, %ecx
callq 0x104461
movq %rax, 0x28(%r15)
testq %rax, %rax
je 0x1152d0
movb 0xf(%rsp), %cl
movq 0x38(%r15), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x38(%r15)
movb %cl, (%rax,%rdx)
movq 0x8(%r15), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x1156aa
testl %eax, %eax
jns 0x11510f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1152bf
movb $0x1, 0x49(%r15)
cmpq $0x0, 0x38(%r15)
je 0x1152bf
movq 0x20(%r15), %rdi
callq 0xe4d8e
movq %rax, (%r12)
cmpb $0x1, 0x48(%r15)
jne 0x115249
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)
movq $0x0, 0x38(%r15)
jmp 0x1152ba
cmpq $0x0, 0x38(%r15)
jne 0x11527f
cmpb $0x1, 0x48(%r15)
jne 0x11527f
movq 0x40(%r15), %rdx
leaq 0x25b5a6(%rip), %rsi    # 0x370819
movq %r13, %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0x115203
movq 0x20(%r15), %rdi
callq 0xe4d8e
movq %rax, (%r12)
movq 0x38(%r15), %rax
movq %rax, (%r14)
cmpb $0x1, 0x48(%r15)
jne 0x1152ae
movq 0x28(%r15), %rcx
movb $0x0, (%rcx,%rax)
movq 0x28(%r15), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq $0x0, 0x38(%r15)
incq 0x40(%r15)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3608f
callq 0x360ff
callq 0x36058
callq 0x360c8