// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/gff3_linesorted_out_stream.c
// Function: gff3_linesorted_out_stream_next
static int gff3_linesorted_out_stream_next(GtNodeStream *ns, GtGenomeNode **gn,
                                           GtError *err)
{
  GtGFF3LinesortedOutStream *lsos;
  int had_err = 0;
  GtGenomeNode *node;
  GtFeatureNode *fn = NULL;
  gt_error_check(err);
  lsos = gt_gff3_linesorted_out_stream_cast(ns);

  /* we do not need to pass on any nodes, this is an output stream */
  *gn = NULL;

  while (!(had_err = gt_node_stream_next(lsos->in_stream, &node,
                                          err))) {
     if (node == NULL) {
       /* do not forget to finish last cluster */
       if (!had_err) {
         had_err = gff3_linesorted_out_stream_process_current_cluster(lsos, err);
       }
       break;
     }
     if ((fn = gt_feature_node_try_cast(node))) {
       if (lsos->last_seqid == NULL) {
         lsos->last_seqid = gt_str_clone(gt_genome_node_get_seqid(node));
       }
       if (gt_str_cmp(lsos->last_seqid, gt_genome_node_get_seqid(node)) != 0) {
         /* new sequence reached, finish old cluster and update current seqid;
            we can do this as GenomeTools enforces all features within a CC to
            share the same seqid */
         had_err = gff3_linesorted_out_stream_process_current_cluster(lsos, err);
         if (had_err) {
           return had_err;
         }
         gt_str_reset(lsos->last_seqid);
         gt_str_append_str(lsos->last_seqid, gt_genome_node_get_seqid(node));
       }
       gt_array_add(lsos->cur_node_set, fn);
     } else {
       if (!had_err) {
        gt_str_reset(lsos->buf);
        had_err = gt_genome_node_accept(node, lsos->gff3vis, err);
      }
      if (!had_err) {
        gt_file_xprintf(lsos->outfp, "%s", gt_str_get(lsos->buf));
        gt_genome_node_delete(node);
      } else {
        return had_err;
      }
    }
  }

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq $0x0, 0x10(%rsp)
testq %rdx, %rdx
je 0x14d9c5
movq %rbx, %rdi
callq 0x101a9a
testb %al, %al
jne 0x14db2c
callq 0x14d8bc
movq %rax, %rdi
movq %r14, %rsi
callq 0x16ae64
movq %rax, %r14
movq $0x0, (%r15)
movq 0x10(%rax), %rdi
leaq 0x8(%rsp), %rsi
movq %rbx, %rdx
callq 0x16ace8
testl %eax, %eax
je 0x14da03
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2847c7(%rip), %r15    # 0x3d21d1
leaq 0x8(%rsp), %r12
leaq 0x10(%rsp), %r13
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x14db1c
callq 0x14aefc
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x14dab7
cmpq $0x0, 0x40(%r14)
jne 0x14da52
movq 0x8(%rsp), %rdi
callq 0x14b89b
movq %rax, %rdi
callq 0x120e13
movq %rax, 0x40(%r14)
movq 0x40(%r14), %rbp
movq 0x8(%rsp), %rdi
callq 0x14b89b
movq %rbp, %rdi
movq %rax, %rsi
callq 0x120dc8
testl %eax, %eax
je 0x14daa4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x14dc00
testl %eax, %eax
jne 0x14d9f4
movq 0x40(%r14), %rdi
callq 0x120db4
movq 0x40(%r14), %rbp
movq 0x8(%rsp), %rdi
callq 0x14b89b
movq %rbp, %rdi
movq %rax, %rsi
callq 0x120a43
movq 0x18(%r14), %rdi
movl $0x8, %edx
movq %r13, %rsi
callq 0xd49ce
jmp 0x14db00
movq 0x28(%r14), %rdi
callq 0x120db4
movq 0x8(%rsp), %rdi
movq 0x38(%r14), %rsi
movq %rbx, %rdx
callq 0x14b992
testl %eax, %eax
jne 0x14d9f4
movq 0x20(%r14), %rbp
movq 0x28(%r14), %rdi
callq 0x120d23
movq %rbp, %rdi
movq %r15, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x103d21
movq 0x8(%rsp), %rdi
callq 0x14c43a
movq 0x10(%r14), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x16ace8
testl %eax, %eax
je 0x14da14
jmp 0x14d9f4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x14dc00
jmp 0x14d9f4
callq 0x45493