// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0xa36d3
movq 0x18(%rsp), %rdi
callq 0xc270
testb $0x1, %al
jne 0xa369b
jmp 0xa36d3
movq 0x110936(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0xba9ba(%rip), %rsi     # 0x15e066
leaq 0xbaf95(%rip), %rdx     # 0x15e648
leaq 0xce80a(%rip), %rcx     # 0x171ec4
leaq 0xce7e5(%rip), %r8      # 0x171ea6
movl $0x27, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xa36d5
callq 0xa35e0
movq %rax, %rdi
movq 0x28(%rsp), %rsi
callq 0x34af0
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xa4440
cmpq $0x0, %rax
je 0xa3726
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xa4480
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x34(%rsp)
jmp 0xa38be
movq 0x10(%rsp), %rax
testb $0x1, 0x20(%rax)
jne 0xa3752
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x34790
movl %eax, 0x34(%rsp)
jmp 0xa38be
jmp 0xa3754
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x34790
movl %eax, 0xc(%rsp)
movq 0x20(%rsp), %rax
cmpq $0x0, (%rax)
jne 0xa3780
jmp 0xa381a
cmpl $0x0, 0xc(%rsp)
je 0xa378c
jmp 0xa381a
movq 0x20(%rsp), %rax
movq (%rax), %rdi
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0x18(%rsp), %rdx
callq 0x25cc0
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0xa37cd
movq 0x20(%rsp), %rax
movq (%rax), %rdi
callq 0x26eb0
movq 0x20(%rsp), %rax
movq $0x0, (%rax)
jmp 0xa381a
movq 0x20(%rsp), %rax
movq $0x0, (%rax)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xa4440
cmpq $0x0, %rax
je 0xa3813
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xa4480
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x34(%rsp)
jmp 0xa38be
jmp 0xa3815
jmp 0xa3754
cmpl $0x0, 0xc(%rsp)
jne 0xa3868
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xa44c0
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xa4440
cmpq $0x0, %rax
je 0xa3866
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xa4480
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x34(%rsp)
jmp 0xa38be
jmp 0xa3868
jmp 0xa386a
cmpl $0x0, 0xc(%rsp)
jne 0xa38b4
movq 0x20(%rsp), %rax
cmpq $0x0, (%rax)
je 0xa38b4
movq 0x110755(%rip), %rax    # 0x1b3fd8
movq (%rax), %rdi
leaq 0xba7d9(%rip), %rsi     # 0x15e066
leaq 0xce644(%rip), %rdx     # 0x171ed8
leaq 0xce629(%rip), %rcx     # 0x171ec4
leaq 0xce604(%rip), %r8      # 0x171ea6
movl $0x59, %r9d
movb $0x0, %al
callq 0xb890
callq 0xb2e0
jmp 0xa38b6
movl 0xc(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw (%rax,%rax)