// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/add_ids_stream.c
// Function: add_ids_stream_next
static int add_ids_stream_next(GtNodeStream *ns, GtGenomeNode **gn,
                               GtError *err)
{
  GtAddIDsStream *ais;
  int had_err;
  gt_error_check(err);
  ais = gt_add_ids_stream_cast(ns);

  /* we still have nodes in the buffer */
  if (gt_add_ids_visitor_node_buffer_size(ais->add_ids_visitor)) {
    /* return one of them */
    *gn = gt_add_ids_visitor_get_node(ais->add_ids_visitor);
    return 0;
  }

  /* handle disabled stream */
  if (!ais->add_ids)
    return gt_node_stream_next(ais->in_stream, gn, err);

  /* no nodes in the buffer -> get new nodes */
  for (;;) {
    had_err = gt_node_stream_next(ais->in_stream, gn, err);
    /* end of the stream */
    if (!*gn)
      break;
    if (had_err)
      break;
    else {
      had_err = gt_genome_node_accept(*gn, ais->add_ids_visitor, err);
      if (had_err) {
        /* we own the node -> delete it */
        gt_genome_node_delete(*gn);
        *gn = NULL;
        break;
      }
      else {
        /* the node is now in the buffer -> reset to avoid double free */
        *gn = NULL;
      }
      if (gt_add_ids_visitor_node_buffer_size(ais->add_ids_visitor)) {
        *gn = gt_add_ids_visitor_get_node(ais->add_ids_visitor);
        return 0;
      }
    }
  }

  if (!had_err) {
    gt_add_ids_visitor_finalize(ais->add_ids_visitor);
    if (gt_add_ids_visitor_node_buffer_size(ais->add_ids_visitor)) {
      *gn = gt_add_ids_visitor_get_node(ais->add_ids_visitor);
      return 0;
    }
  }

  /* either we have an error or no new node */
  gt_assert(had_err || !*gn);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
testq %rdx, %rdx
je 0x62a06
movq %r14, %rdi
callq 0xc103
testb %al, %al
jne 0x62b0f
callq 0x6297c
movq %rax, %rdi
movq %r15, %rsi
callq 0x25ec1
movq %rax, %r15
movq 0x18(%rax), %rdi
callq 0x632ec
testq %rax, %rax
je 0x62a42
movq 0x18(%r15), %rdi
callq 0x6330a
movq %rax, (%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x1, 0x20(%r15)
jne 0x62a8e
movq 0x10(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x25c62
movl %eax, %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x62aa7
testl %ebp, %ebp
jne 0x62aa7
movq 0x18(%r15), %rsi
movq %r14, %rdx
callq 0x1c56c
testl %eax, %eax
jne 0x62afc
andq $0x0, (%rbx)
movq 0x18(%r15), %rdi
callq 0x632ec
testq %rax, %rax
je 0x62a49
jmp 0x62a27
movq 0x10(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x25c62
testl %ebp, %ebp
jne 0x62a35
movq 0x18(%r15), %rdi
callq 0x63328
movq 0x18(%r15), %rdi
callq 0x632ec
testq %rax, %rax
jne 0x62a27
xorl %ebp, %ebp
cmpq $0x0, (%rbx)
je 0x62a35
movq 0xcb4df(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x67583(%rip), %rsi     # 0xca066
leaq 0x7a53a(%rip), %rdx     # 0xdd024
leaq 0x7a51f(%rip), %rcx     # 0xdd010
leaq 0x7a4fa(%rip), %r8      # 0xdcff2
pushq $0x59
jmp 0x62b37
movl %eax, %ebp
movq (%rbx), %rdi
callq 0x1d1e3
andq $0x0, (%rbx)
jmp 0x62a35
movq 0xcb4a2(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x67546(%rip), %rsi     # 0xca066
leaq 0x67b32(%rip), %rdx     # 0xca659
leaq 0x7a4e2(%rip), %rcx     # 0xdd010
leaq 0x7a4bd(%rip), %r8      # 0xdcff2
pushq $0x27
popq %r9
xorl %eax, %eax
callq 0xb8c0
callq 0xb300