// File: /workspace/github_c_makefile_star2_O3/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 0x4270c
movq %rax, %rdi
movq %rbx, %rsi
callq 0x48f0b
movq %rax, %r14
testq %r15, %r15
je 0x427f7
movq %r15, %rdi
callq 0x34fea
testb %al, %al
jne 0x42b34
movq 0x40(%r14), %rdi
callq 0x7c5d0
movq 0x40(%r14), %rdi
cmpq $0x2, %rax
jb 0x42816
callq 0x7c56e
xorl %ebp, %ebp
jmp 0x42a81
movq %r12, 0x10(%rsp)
callq 0x7c5d0
cmpq $0x1, %rax
ja 0x42b39
leaq 0x2b(%r14), %r13
leaq 0x29(%r14), %rax
movq %rax, 0x18(%rsp)
movq %r14, %r12
addq $0x38, %r12
cmpb $0x0, (%r13)
jne 0x42955
movq 0x18(%r14), %rdi
callq 0x3cbed
testq %rax, %rax
je 0x4286d
movq 0x10(%r14), %rbx
movq 0x18(%r14), %rdi
callq 0x3cbed
cmpq %rax, %rbx
je 0x42a66
movq 0x18(%r14), %rdi
callq 0x3cbed
testq %rax, %rax
je 0x428c3
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
callq 0x3ca6f
cmpb $0x2d, (%rax)
jne 0x42897
cmpb $0x0, 0x1(%rax)
je 0x42a30
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
callq 0x3ca6f
movq %rax, %rdi
leaq 0xac5af(%rip), %rsi     # 0xeee5d
callq 0x75bec
movq %rax, 0x30(%r14)
movq %r13, %rcx
movb $0x1, (%rcx)
incq 0x10(%r14)
jmp 0x428dd
cmpb $0x0, 0x2a(%r14)
jne 0x42a66
movq $0x0, 0x30(%r14)
movb $0x1, 0x2b(%r14)
xorl %eax, %eax
movq $0x0, 0x38(%r14)
cmpb $0x1, 0x2c(%r14)
jne 0x42926
movq 0x18(%r14), %rdi
callq 0x3cbed
leaq 0xab2f0(%rip), %rsi     # 0xedbec
testq %rax, %rax
je 0x42914
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
decq %rsi
callq 0x3ca6f
movq %rax, %rsi
leaq 0xa3a83(%rip), %rdi     # 0xe639e
xorl %eax, %eax
callq 0xb070
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x42955
cmpb $0x1, 0x2c(%r14)
jne 0x42955
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
decq %rsi
callq 0x3ca6f
movq %rax, %rdi
callq 0x76227
movq %r12, %rdi
movq %rax, %rsi
callq 0x7b5d0
cmpb $0x0, (%r13)
je 0x42b2f
movq 0x18(%r14), %rdi
callq 0x3cbed
testq %rax, %rax
je 0x42983
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdi
decq %rsi
callq 0x3caaa
movq %rax, %rbx
jmp 0x42987
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 0x43708
addq $0x10, %rsp
testl %eax, %eax
jne 0x42a5d
cmpl $-0x1, 0xc(%rsp)
je 0x429f1
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 0x43708
addq $0x10, %rsp
testl %eax, %eax
jne 0x42a5d
cmpl $-0x1, 0xc(%rsp)
jne 0x42a96
cmpb $0x1, 0x2c(%r14)
jne 0x429fd
callq 0x7bb32
movq 0x30(%r14), %rdi
callq 0x760c0
movq $0x0, 0x30(%r14)
movb $0x0, 0x2b(%r14)
movq 0x48(%r14), %rdi
callq 0x46538
movq 0x18(%r14), %rdi
callq 0x3cbed
testq %rax, %rax
jne 0x4283e
jmp 0x42a61
movq 0x18(%rsp), %rbx
cmpb $0x1, (%rbx)
je 0x42b14
xorl %edi, %edi
leaq 0xac416(%rip), %rsi     # 0xeee5d
callq 0x75bec
movq %rax, 0x30(%r14)
movb $0x1, 0x2b(%r14)
movq %rbx, %rcx
jmp 0x428ba
movl %eax, %ebp
jmp 0x42a68
movb $0x1, 0x2a(%r14)
xorl %ebp, %ebp
movq 0x40(%r14), %rdi
callq 0x7c5d0
testq %rax, %rax
movq 0x10(%rsp), %r12
jne 0x42b3e
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 0x7c5d0
testq %rax, %rax
je 0x42b43
cmpb $0x1, 0x28(%r14)
movq 0x10(%rsp), %r12
jne 0x42b0b
movq 0x40(%r14), %rdi
callq 0x7c5d0
cmpq $0x2, %rax
jb 0x42b0b
movq $0x0, 0x20(%rsp)
movq 0x18(%r14), %rdi
callq 0x3cbed
testq %rax, %rax
je 0x42ae9
movq 0x18(%r14), %rdi
callq 0x3cbed
cmpq $0x1, %rax
jne 0x42b48
movq 0x40(%r14), %rdi
leaq 0x2e7(%rip), %rsi       # 0x42ddb
leaq 0x20(%rsp), %rdx
movq %r15, %rcx
callq 0x7c7fe
movl %eax, %ebp
testl %eax, %eax
jne 0x42a85
movq 0x40(%r14), %rdi
jmp 0x4280a
leaq 0xa3857(%rip), %rsi     # 0xe6372
movq %r15, %rdi
xorl %eax, %eax
callq 0x34f1f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x42a68
callq 0x1175c
callq 0x116ee
callq 0x11725
callq 0x11807
callq 0x117ce
callq 0x11795