// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/core/sequence_buffer_embl.c
// Function: gt_sequence_buffer_embl_advance
static int gt_sequence_buffer_embl_advance(GtSequenceBuffer *sb, GtError *err)
{
  GtUword currentoutpos = 0, currentfileadd = 0, currentfileread = 0,
                linelen = 0;
  GtSequenceBufferMembers *pvt;
  GtSequenceBufferEMBL *sbe;
  GtEMBLParserLineCode lc = OTHER;
  const char *line = "";
  int had_err = 0;

  gt_error_check(err);

  sbe = gt_sequence_buffer_embl_cast(sb);
  pvt = sb->pvt;
  /* open first stream */
  if (!pvt->inputstream) {
    sbe->firstentryinfile = true;
    sbe->state = EMBL_UNDEFINED;
    pvt->linenum = (uint64_t) 0;
    pvt->inputstream = gt_file_xopen(gt_str_array_get(pvt->filenametab,
                                                  (GtUword) pvt->filenum),
                                         "rb");
    pvt->currentinpos = 0;
    pvt->currentfillpos = 0;
  }

  if (gt_str_length(sbe->overflowbuffer) > 0) {
    /* we still have surplus sequence from the last line, process that first */
    GtUword i, len;
    const char *overflowedstring;
    overflowedstring = gt_str_get_mem(sbe->overflowbuffer);
    len = gt_str_length(sbe->overflowbuffer);
    for (i=0;i<len;i++)
    {
      process_char(sb, currentoutpos, overflowedstring[i], err);
      currentoutpos++;
      currentfileadd++;
    }
    gt_str_reset(sbe->overflowbuffer);
    gt_assert(gt_str_length(sbe->overflowbuffer) == 0);
  }

  /* parse file line-by-line */
  while (true) {
    had_err = parse_next_line(sb, &lc, sbe->overflowbuffer, &line, &linelen,
                              &currentfileread, &currentfileadd, &currentoutpos,
                              err);

    if (had_err && had_err != EOF) {
      break;
    }
    if (currentoutpos >= (GtUword) OUTBUFSIZE) {
      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 0; /* buffer full, finished */
    }
    if (lc == TERMINATOR) {
      pvt->outbuf[currentoutpos++] = (GtUchar) GT_SEPARATOR;
      currentfileadd++;
      pvt->lastspeciallength++;
      sbe->state = EMBL_UNDEFINED;
      sbe->desc_spacer_was_set = false;
      if (!sbe->description_set && pvt->descptr)
          gt_desc_buffer_finish(pvt->descptr);
      sbe->description_set = false;
    }
    /* FSM transitions begin here */
    switch (sbe->state) {
      case EMBL_IN_DESCRIPTION:
        if (lc != DESCRIPTION) {
          /* save description */
          if (pvt->descptr) {
            gt_desc_buffer_finish(pvt->descptr);
          }
          sbe->description_set = true;
          /* gt_str_reset(sbe->headerbuffer); */
          sbe->state = EMBL_UNDEFINED;
        }
        break;
      case EMBL_IN_SEQUENCE:
        /* only a terminator may come after a sequence */
        if (lc != SEQUENCE) {
          gt_error_set(err, "unterminated sequence in line "GT_WU" of file %s",
                            (GtUword) pvt->linenum,
                            gt_str_array_get(pvt->filenametab,
                                                (GtUword) pvt->filenum));
          return -1;
        }
        break;
      case EMBL_UNDEFINED:
        switch (lc) {
          case DESCRIPTION:
            sbe->state = EMBL_IN_DESCRIPTION;
            if (pvt->descptr && gt_desc_buffer_length(pvt->descptr) > 0) {
              gt_desc_buffer_append_char(pvt->descptr, ' ');
            }
            break;
          case SEQUENCE:
            sbe->state = EMBL_IN_SEQUENCE;
            break;
          default:
            break;
        }
        break;
    }
    if (had_err == EOF) {
      /* save length table entries if needed */
      if (pvt->filelengthtab) {
        pvt->filelengthtab[pvt->filenum].length
          += (uint64_t) currentfileread;
        pvt->filelengthtab[pvt->filenum].effectivelength
          += (uint64_t) currentfileadd;
      }
      if (pvt->filenum+1 < gt_str_array_size(pvt->filenametab)) {
        pvt->filenum++;
        /* still files left, open next one */
        gt_file_delete(pvt->inputstream);
        sbe->state = EMBL_UNDEFINED;
        pvt->linenum = (uint64_t) 0;
        pvt->inputstream = gt_file_xopen(gt_str_array_get(pvt->filenametab,
                                                (GtUword) pvt->filenum),
                                            "rb");
        if (pvt->filelengthtab) {
          pvt->filelengthtab[pvt->filenum].length = 0;
          pvt->filelengthtab[pvt->filenum].effectivelength = 0;
        }
        pvt->currentinpos = 0;
        pvt->currentfillpos = 0;
        currentfileread = currentfileadd = 0;
      } else {
        /* all files exhausted */
        pvt->complete = true;
        /* remove last separator */
        gt_assert(pvt->outbuf[currentoutpos-1] == GT_SEPARATOR);
        pvt->outbuf[--currentoutpos] = (GtUchar) '\0';
        if (pvt->filelengthtab) {
          pvt->filelengthtab[pvt->filenum].effectivelength--;
        }
        had_err = 0;
        break;
      }
    }
  }
  pvt->nextfree = GT_MIN(currentoutpos, OUTBUFSIZE);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, %r12
testq %rsi, %rsi
je 0x5fcb1
movq %r14, %rdi
callq 0xc103
testb %al, %al
jne 0x602e4
leaq 0xccb10(%rip), %rdi     # 0x12c7c8
movq %r12, %rsi
callq 0x5e96e
movq %rax, %rbp
movq 0x8(%r12), %rbx
cmpq $0x0, 0x28(%rbx)
jne 0x5fd01
movb $0x1, 0x20(%rbp)
andl $0x0, 0x28(%rbp)
andq $0x0, 0x8(%rbx)
movq 0x70(%rbx), %rdi
movl (%rbx), %esi
callq 0x1555e
leaq 0x76eb0(%rip), %rsi     # 0xd6b9e
movq %rax, %rdi
callq 0x540ec
movq %rax, 0x28(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movq 0x18(%rbp), %rdi
callq 0x14461
testq %rax, %rax
movq %rbp, 0x8(%rsp)
movq %r14, 0x40(%rsp)
je 0x5fda2
movq 0x18(%rbp), %rdi
callq 0x1441f
movq %rax, %r13
movq 0x18(%rbp), %rdi
callq 0x14461
movq %rax, %r15
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x5fd55
movzbl (%r13,%rbp), %edx
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rcx
callq 0x60457
incq %rbp
jmp 0x5fd37
movq 0x8(%rsp), %rbp
movq 0x18(%rbp), %rdi
callq 0x1452f
movq 0x18(%rbp), %rdi
callq 0x14461
testq %rax, %rax
je 0x5fda5
movq 0xce240(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x6a2e4(%rip), %rsi     # 0xca066
leaq 0x7c858(%rip), %rdx     # 0xdc5e1
leaq 0x7c811(%rip), %rcx     # 0xdc5a1
leaq 0x7c82a(%rip), %r8      # 0xdc5c1
movl $0xe1, %r9d
jmp 0x6033e
xorl %r15d, %r15d
leaq 0x40(%rbx), %rax
movq %rax, 0x50(%rsp)
xorl %r14d, %r14d
movq %r15, 0x30(%rsp)
movq %r12, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %r15, 0x38(%rsp)
movq 0x18(%rbp), %r13
movq 0x8(%r12), %r15
incq 0x8(%r15)
movq 0x28(%r15), %rsi
movq %r12, %rdi
callq 0x604f5
cmpl $-0x1, %eax
je 0x5fdfc
movq %r13, 0x48(%rsp)
movq %r14, %rbx
incq %r14
xorl %r13d, %r13d
cmpl $0xa, %eax
jne 0x5fe09
pushq $0x5
popq %r12
jmp 0x5fe7b
pushq $0x5
popq %r12
pushq $-0x1
popq %r13
jmp 0x60061
movb %al, 0x6(%rsp)
movq 0x28(%r15), %rsi
movq %r12, %rdi
callq 0x604f5
cmpl $-0x1, %eax
je 0x5fe73
cmpl $0xa, %eax
je 0x602d0
leaq 0x2(%rbx), %rbp
movb %al, 0x7(%rsp)
cmpw $0x4544, 0x6(%rsp)      # imm = 0x4544
je 0x5fe85
cmpw $0x2020, 0x6(%rsp)      # imm = 0x2020
pushq $0x2
popq %r12
je 0x5fe88
cmpw $0x5858, 0x6(%rsp)      # imm = 0x5858
je 0x5feee
cmpw $0x4449, 0x6(%rsp)      # imm = 0x4449
pushq $0x1
popq %r12
je 0x5fe88
xorl %r12d, %r12d
cmpw $0x2f2f, 0x6(%rsp)      # imm = 0x2F2F
sete %r12b
xorl $0x5, %r12d
jmp 0x5fe88
pushq $0x5
popq %r12
pushq $-0x1
popq %r13
movq 0x10(%rsp), %rbx
jmp 0x60061
xorl %r12d, %r12d
addq $0x5, %rbx
movq %rbx, 0x20(%rsp)
pushq $0x3
popq %r14
movq 0x10(%rsp), %rbx
subl $0x1, %r14d
jb 0x5fed9
movq 0x28(%r15), %rsi
movq 0x18(%rsp), %rdi
callq 0x604f5
cmpl $-0x1, %eax
je 0x60055
movl %eax, %r13d
cmpl $0xa, %eax
je 0x5fee0
callq 0xb6e0
movq (%rax), %rax
movl %r13d, %ecx
incq %rbp
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x5fe9a
jmp 0x60203
movq 0x20(%rsp), %rbp
jmp 0x5fef7
incq %rbp
xorl %r13d, %r13d
movq %rbp, %r14
jmp 0x6005c
pushq $0x3
popq %r12
movq 0x10(%rsp), %rbx
movq 0x28(%r15), %rsi
movq 0x18(%rsp), %rdi
callq 0x604f5
cmpl $-0x1, %eax
je 0x60055
movl %eax, %r13d
incq %rbp
movq $0x0, 0x28(%rsp)
movq %rbp, %r14
cmpl $0xa, %r13d
je 0x601ce
testl %r12d, %r12d
je 0x5ff96
cmpl $0x1, %r12d
je 0x5ff8c
cmpl $0x2, %r12d
jne 0x5fff8
movq 0x28(%rsp), %rax
leal 0x1(%rax), %ebp
cmpl $0x40, %eax
jg 0x5ffd5
callq 0xb6e0
movq (%rax), %rax
movl %r13d, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x5ffd5
movq %r14, 0x20(%rsp)
movq 0x38(%rsp), %r14
cmpq $0x2000, %r14           # imm = 0x2000
jb 0x60018
movsbl %r13b, %esi
movq 0x48(%rsp), %rdi
callq 0x140b1
jmp 0x60043
cmpl $0x3b, %r13d
jne 0x5ffe2
pushq $0x5
jmp 0x5fff6
movq 0x20(%r15), %rdi
xorl %r12d, %r12d
testq %rdi, %rdi
je 0x5fff8
movq %r14, %rbx
movq 0x18(%rsp), %r14
cmpb $0x0, 0x24(%r14)
jne 0x5ffc2
pushq $0x20
popq %rsi
callq 0x8396b
movb $0x1, 0x24(%r14)
movq 0x20(%r15), %rdi
movq %rbx, %r14
movsbl %r13b, %esi
callq 0x8396b
movq 0x10(%rsp), %rbx
jmp 0x5fff8
pushq $0x2
popq %r12
movl %ebp, %eax
movq %rax, 0x28(%rsp)
jmp 0x5fff8
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x5fff4
movsbl %r13b, %esi
callq 0x8396b
pushq $0x1
popq %r12
movq 0x28(%r15), %rsi
movq 0x18(%rsp), %rdi
callq 0x604f5
movl %eax, %r13d
leaq 0x1(%r14), %rbp
cmpl $-0x1, %eax
jne 0x5ff1d
jmp 0x60058
movzbl %r13b, %edx
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movq 0x40(%rsp), %rcx
callq 0x60457
testl %eax, %eax
jne 0x601e0
incq %r14
movq %r14, 0x38(%rsp)
incq 0x30(%rsp)
pushq $0x2
popq %r12
movl %ebp, %eax
movq %rax, 0x28(%rsp)
movq 0x20(%rsp), %r14
jmp 0x5fff8
movq %rbp, %r14
pushq $-0x1
popq %r13
movq 0x8(%rsp), %rbp
movq 0x38(%rsp), %r15
cmpq $0x2000, %r15           # imm = 0x2000
jae 0x60224
cmpl $0x4, %r12d
jne 0x600b2
movb $-0x1, 0x2079(%rbx,%r15)
incq 0x60(%rbx)
andl $0x0, 0x28(%rbp)
movb $0x0, 0x24(%rbp)
cmpb $0x0, 0x25(%rbp)
jne 0x600a2
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x600a2
callq 0x83a7f
incq %r15
incq 0x30(%rsp)
movb $0x0, 0x25(%rbp)
pushq $0x4
popq %r12
movl 0x28(%rbp), %eax
testl %eax, %eax
je 0x600eb
cmpl $0x1, %eax
je 0x600e0
cmpl $0x2, %eax
jne 0x60125
testl %r12d, %r12d
je 0x60125
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x600d6
callq 0x83a7f
movb $0x1, 0x25(%rbp)
andl $0x0, 0x28(%rbp)
jmp 0x60125
cmpl $0x2, %r12d
je 0x60125
jmp 0x602a3
cmpl $0x2, %r12d
je 0x6011e
testl %r12d, %r12d
jne 0x60125
movl $0x2, 0x28(%rbp)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x60125
callq 0x83ae2
testq %rax, %rax
je 0x60125
movq 0x20(%rbx), %rdi
pushq $0x20
popq %rsi
callq 0x8396b
jmp 0x60125
movl $0x1, 0x28(%rbp)
cmpl $-0x1, %r13d
movq 0x18(%rsp), %r12
jne 0x5fdc0
movq %r14, %rdx
movq 0x10(%rbx), %rax
movl (%rbx), %r14d
testq %rax, %rax
je 0x60158
movq %r14, %rcx
shlq $0x4, %rcx
addq %rdx, (%rax,%rcx)
movq 0x30(%rsp), %rdx
addq %rdx, 0x8(%rax,%rcx)
incl %r14d
movq 0x70(%rbx), %rdi
callq 0x157f4
cmpq %r14, %rax
jbe 0x6024d
incl (%rbx)
movq 0x28(%rbx), %rdi
callq 0x548ae
andl $0x0, 0x28(%rbp)
andq $0x0, 0x8(%rbx)
movq 0x70(%rbx), %rdi
movl (%rbx), %esi
callq 0x1555e
movq %rax, %rdi
leaq 0x76a08(%rip), %rsi     # 0xd6b9e
callq 0x540ec
movq %rax, 0x28(%rbx)
movq 0x10(%rbx), %rax
testq %rax, %rax
xorps %xmm0, %xmm0
je 0x601b5
movl (%rbx), %ecx
shlq $0x4, %rcx
movups %xmm0, (%rax,%rcx)
movq 0x50(%rsp), %rax
movups %xmm0, (%rax)
movq $0x0, 0x30(%rsp)
xorl %r14d, %r14d
jmp 0x5fdc0
movq 0x48(%rsp), %rdi
callq 0x143d2
xorl %r13d, %r13d
jmp 0x6005c
pushq $-0x1
popq %r13
pushq $0x2
popq %r12
cmpl $-0x1, %eax
movq %r14, %r15
movq 0x8(%rsp), %rbp
movq 0x20(%rsp), %r14
je 0x600b2
pushq $-0x2
popq %rbp
jmp 0x60282
leaq 0x7c4b5(%rip), %rsi     # 0xdc6bf
pushq $-0x2
popq %rbp
movq 0x8(%r15), %rdx
movq 0x40(%rsp), %rdi
xorl %eax, %eax
callq 0xc007
movq 0x38(%rsp), %r15
jmp 0x60282
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x60241
movl (%rbx), %ecx
shlq $0x4, %rcx
addq %r14, (%rax,%rcx)
movq 0x30(%rsp), %rdx
addq %rdx, 0x8(%rax,%rcx)
movq $0x2000, 0x58(%rbx)     # imm = 0x2000
xorl %ebp, %ebp
jmp 0x60292
movb $0x1, 0x18(%rbx)
cmpb $-0x1, 0x2078(%rbx,%r15)
jne 0x60312
decq %r15
movb $0x0, 0x2079(%rbx,%r15)
movq 0x10(%rbx), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0x60282
movl (%rbx), %ecx
shlq $0x4, %rcx
decq 0x8(%rax,%rcx)
movl $0x2000, %eax           # imm = 0x2000
cmpq %rax, %r15
cmovbq %r15, %rax
movq %rax, 0x58(%rbx)
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbx), %r14
movq 0x70(%rbx), %rdi
movl (%rbx), %esi
callq 0x1555e
leaq 0x7c350(%rip), %rsi     # 0xdc609
movq 0x40(%rsp), %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xc007
pushq $-0x1
popq %rbp
jmp 0x60292
pushq $-0x2
popq %rbp
leaq 0x7c3b6(%rip), %rsi     # 0xdc690
movq 0x10(%rsp), %rbx
jmp 0x6020d
movq 0xcdccd(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x69d71(%rip), %rsi     # 0xca066
leaq 0x6a35d(%rip), %rdx     # 0xca659
leaq 0x7c29e(%rip), %rcx     # 0xdc5a1
leaq 0x7c2b7(%rip), %r8      # 0xdc5c1
movl $0xc4, %r9d
jmp 0x6033e
movq 0xcdc9f(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x69d43(%rip), %rsi     # 0xca066
leaq 0x7c30c(%rip), %rdx     # 0xdc636
leaq 0x7c270(%rip), %rcx     # 0xdc5a1
leaq 0x7c289(%rip), %r8      # 0xdc5c1
movl $0x144, %r9d            # imm = 0x144
xorl %eax, %eax
callq 0xb8c0
callq 0xb300