// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/gff3_in_stream_plain.c
// Function: gff3_in_stream_plain_next
static int gff3_in_stream_plain_next(GtNodeStream *ns, GtGenomeNode **gn,
                                     GtError *err)
{
  GtGFF3InStreamPlain *is = gff3_in_stream_plain_cast(ns);
  GtStr *filenamestr;
  int had_err = 0, status_code;

  gt_error_check(err);

  if (gt_queue_size(is->genome_node_buffer) > 1) {
    /* we still have at least two nodes in the buffer -> serve from there */
    *gn = gt_queue_get(is->genome_node_buffer);
    return 0;
  }

  /* the buffer is empty or has one element */
  gt_assert(gt_queue_size(is->genome_node_buffer) <= 1);

  for (;;) {
    /* open file if necessary */
    if (!is->file_is_open) {
      if (gt_str_array_size(is->files) &&
          is->next_file == gt_str_array_size(is->files)) {
        break;
      }
      if (gt_str_array_size(is->files)) {
        if (strcmp(gt_str_array_get(is->files, is->next_file), "-") == 0) {
          if (is->stdin_argument) {
            gt_error_set(err, "multiple specification of argument file \"-\"");
            had_err = -1;
            break;
          }
          is->fpin = gt_file_xopen(NULL, "r");
          is->file_is_open = true;
          is->stdin_argument = true;
        }
        else {
          is->fpin = gt_file_xopen(gt_str_array_get(is->files,
                                                       is->next_file), "r");
          is->file_is_open = true;
        }
        is->next_file++;
      }
      else {
        if (is->stdin_processed)
          break;
        is->fpin = NULL;
        is->file_is_open = true;
      }
      is->line_number = 0;

      if (!had_err && is->progress_bar) {
        printf("processing file \"%s\"\n", gt_str_array_size(is->files)
               ? gt_str_array_get(is->files, is->next_file-1) : "stdin");
      }
      if (!had_err && is->fpin && is->progress_bar) {
        gt_progressbar_start(&is->line_number,
                            gt_file_number_of_lines(gt_str_array_get(is->files,
                                                             is->next_file-1)));
      }
    }

    gt_assert(is->file_is_open);

    filenamestr = gt_str_array_size(is->files)
                  ? gt_str_array_get_str(is->files, is->next_file-1)
                  : is->stdinstr;
    /* read two nodes */
    had_err = gt_gff3_parser_parse_genome_nodes(is->gff3_parser, &status_code,
                                                is->genome_node_buffer,
                                                is->used_types, filenamestr,
                                                &is->line_number, is->fpin,
                                                err);
    if (had_err)
      break;
    if (status_code != EOF) {
      had_err = gt_gff3_parser_parse_genome_nodes(is->gff3_parser, &status_code,
                                                  is->genome_node_buffer,
                                                  is->used_types, filenamestr,
                                                  &is->line_number, is->fpin,
                                                  err);
      if (had_err)
        break;
    }

    if (status_code == EOF) {
      /* end of current file */
      if (is->progress_bar) gt_progressbar_stop();
      gt_file_delete(is->fpin);
      is->fpin = NULL;
      is->file_is_open = false;
      gt_gff3_parser_reset(is->gff3_parser);
      if (!gt_str_array_size(is->files)) {
        is->stdin_processed = true;
        break;
      }
      continue;
    }

    gt_assert(gt_queue_size(is->genome_node_buffer));

    /* make sure the parsed nodes are sorted */
    if (is->ensure_sorting && gt_queue_size(is->genome_node_buffer) > 1) {
      GtGenomeNode *last_node = NULL;
      /* a sorted stream can have at most one input file */
      gt_assert(gt_str_array_size(is->files) == 0 ||
                gt_str_array_size(is->files) == 1);
      had_err = gt_queue_iterate(is->genome_node_buffer, buffer_is_sorted,
                                 &last_node, err);
    }
    if (!had_err) {
      *gn = gt_queue_get(is->genome_node_buffer);
    }
    return had_err;
  }
  gt_assert(!gt_queue_size(is->genome_node_buffer));
  *gn = NULL;
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
callq 0x1da74
movq %rax, %rdi
movq %rbx, %rsi
callq 0x25ec1
movq %rax, %r14
testq %r15, %r15
je 0x1db59
movq %r15, %rdi
callq 0xc103
testb %al, %al
jne 0x1deb8
movq 0x40(%r14), %rdi
callq 0x5b20f
movq 0x40(%r14), %rdi
cmpq $0x2, %rax
jb 0x1db78
callq 0x5b195
xorl %ebp, %ebp
jmp 0x1ddda
movq %r12, 0x10(%rsp)
callq 0x5b20f
cmpq $0x1, %rax
ja 0x1dee2
leaq 0x2b(%r14), %r13
leaq 0x29(%r14), %rax
movq %rax, 0x18(%rsp)
movq %r14, %r12
addq $0x38, %r12
cmpb $0x0, (%r13)
jne 0x1dcb1
movq 0x18(%r14), %rdi
callq 0x157f4
testq %rax, %rax
je 0x1dbcf
movq 0x10(%r14), %rbx
movq 0x18(%r14), %rdi
callq 0x157f4
cmpq %rax, %rbx
je 0x1ddbf
movq 0x18(%r14), %rdi
callq 0x157f4
testq %rax, %rax
je 0x1dc25
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
callq 0x1555e
cmpb $0x2d, (%rax)
jne 0x1dbf9
cmpb $0x0, 0x1(%rax)
je 0x1dd89
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
callq 0x1555e
movq %rax, %rdi
leaq 0xba1f5(%rip), %rsi     # 0xd7e05
callq 0x540ec
movq %rax, 0x30(%r14)
movq %r13, %rcx
movb $0x1, (%rcx)
incq 0x10(%r14)
jmp 0x1dc3c
cmpb $0x0, 0x2a(%r14)
jne 0x1ddbf
andq $0x0, 0x30(%r14)
movb $0x1, 0x2b(%r14)
xorl %eax, %eax
andq $0x0, 0x38(%r14)
cmpb $0x1, 0x2c(%r14)
jne 0x1dc82
movq 0x18(%r14), %rdi
callq 0x157f4
leaq 0xb8f3c(%rip), %rsi     # 0xd6b94
testq %rax, %rax
je 0x1dc70
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
decq %rsi
callq 0x1555e
movq %rax, %rsi
leaq 0xb1727(%rip), %rdi     # 0xcf39e
xorl %eax, %eax
callq 0xb070
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x1dcb1
cmpb $0x1, 0x2c(%r14)
jne 0x1dcb1
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
decq %rsi
callq 0x1555e
movq %rax, %rdi
callq 0x54aa9
movq %r12, %rdi
movq %rax, %rsi
callq 0x5a560
cmpb $0x0, (%r13)
je 0x1de87
movq 0x18(%r14), %rdi
callq 0x157f4
testq %rax, %rax
je 0x1dcdf
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
decq %rsi
callq 0x155ca
movq %rax, %rbx
jmp 0x1dce3
movq 0x20(%r14), %rbx
movq 0x48(%r14), %rdi
movq 0x40(%r14), %rdx
movq 0x50(%r14), %rcx
leaq 0xc(%rsp), %rsi
movq %rbx, %r8
movq %r12, %r9
pushq %r15
pushq 0x30(%r14)
callq 0x1f0f9
addq $0x10, %rsp
testl %eax, %eax
jne 0x1ddb6
cmpl $-0x1, 0xc(%rsp)
je 0x1dd4d
movq 0x48(%r14), %rdi
movq 0x40(%r14), %rdx
movq 0x50(%r14), %rcx
leaq 0xc(%rsp), %rsi
movq %rbx, %r8
movq %r12, %r9
pushq %r15
pushq 0x30(%r14)
callq 0x1f0f9
addq $0x10, %rsp
testl %eax, %eax
jne 0x1ddb6
cmpl $-0x1, 0xc(%rsp)
jne 0x1ddef
cmpb $0x1, 0x2c(%r14)
jne 0x1dd59
callq 0x5aaad
movq 0x30(%r14), %rdi
callq 0x548ae
andq $0x0, 0x30(%r14)
movb $0x0, 0x2b(%r14)
movq 0x48(%r14), %rdi
callq 0x22625
movq 0x18(%r14), %rdi
callq 0x157f4
testq %rax, %rax
jne 0x1dba0
jmp 0x1ddba
movq 0x18(%rsp), %rbx
cmpb $0x1, (%rbx)
je 0x1de6e
xorl %edi, %edi
leaq 0xba065(%rip), %rsi     # 0xd7e05
callq 0x540ec
movq %rax, 0x30(%r14)
movb $0x1, 0x2b(%r14)
movq %rbx, %rcx
jmp 0x1dc1c
movl %eax, %ebp
jmp 0x1ddc1
movb $0x1, 0x2a(%r14)
xorl %ebp, %ebp
movq 0x40(%r14), %rdi
callq 0x5b20f
testq %rax, %rax
movq 0x10(%rsp), %r12
jne 0x1df0e
xorl %eax, %eax
movq %rax, (%r12)
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%r14), %rdi
callq 0x5b20f
testq %rax, %rax
je 0x1df46
cmpb $0x1, 0x28(%r14)
movq 0x10(%rsp), %r12
jne 0x1de65
movq 0x40(%r14), %rdi
callq 0x5b20f
cmpq $0x2, %rax
jb 0x1de65
andq $0x0, 0x20(%rsp)
movq 0x18(%r14), %rdi
callq 0x157f4
testq %rax, %rax
je 0x1de43
movq 0x18(%r14), %rdi
callq 0x157f4
cmpq $0x1, %rax
jne 0x1df74
movq 0x40(%r14), %rdi
leaq 0x617(%rip), %rsi       # 0x1e465
leaq 0x20(%rsp), %rdx
movq %r15, %rcx
callq 0x5b494
movl %eax, %ebp
testl %eax, %eax
jne 0x1ddde
movq 0x40(%r14), %rdi
jmp 0x1db6c
leaq 0xb14fd(%rip), %rsi     # 0xcf372
movq %r15, %rdi
xorl %eax, %eax
callq 0xc007
pushq $-0x1
popq %rbp
jmp 0x1ddc1
movq 0x11012a(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xac1ce(%rip), %rsi     # 0xca066
leaq 0xb1515(%rip), %rdx     # 0xcf3b4
leaq 0xb1487(%rip), %rcx     # 0xcf32d
leaq 0xb12b5(%rip), %r8      # 0xcf162
movl $0x88, %r9d
jmp 0x1df3a
movq 0x1100f9(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xac19d(%rip), %rsi     # 0xca066
leaq 0xac789(%rip), %rdx     # 0xca659
leaq 0xb1456(%rip), %rcx     # 0xcf32d
leaq 0xb1284(%rip), %r8      # 0xcf162
pushq $0x51
jmp 0x1df0a
movq 0x1100cf(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xac173(%rip), %rsi     # 0xca066
leaq 0xb144d(%rip), %rdx     # 0xcf347
leaq 0xb142c(%rip), %rcx     # 0xcf32d
leaq 0xb125a(%rip), %r8      # 0xcf162
pushq $0x5a
popq %r9
jmp 0x1df3a
movq 0x1100a3(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xac147(%rip), %rsi     # 0xca066
leaq 0xb14e6(%rip), %rdx     # 0xcf40c
leaq 0xb1400(%rip), %rcx     # 0xcf32d
leaq 0xb122e(%rip), %r8      # 0xcf162
movl $0xbd, %r9d
xorl %eax, %eax
callq 0xb8c0
callq 0xb300
movq 0x11006b(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xac10f(%rip), %rsi     # 0xca066
leaq 0xb14af(%rip), %rdx     # 0xcf40d
leaq 0xb13c8(%rip), %rcx     # 0xcf32d
leaq 0xb11f6(%rip), %r8      # 0xcf162
movl $0xad, %r9d
jmp 0x1df3a
movq 0x11003d(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xac0e1(%rip), %rsi     # 0xca066
leaq 0xb1439(%rip), %rdx     # 0xcf3c5
leaq 0xb139a(%rip), %rcx     # 0xcf32d
leaq 0xb11c8(%rip), %r8      # 0xcf162
movl $0xb4, %r9d
jmp 0x1df3a