// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/sequence_node_add_stream.c
// Function: sequence_node_add_stream_next
static int sequence_node_add_stream_next(GtNodeStream *ns, GtGenomeNode **gn,
                                         GtError *err)
{
  GtSequenceNodeAddStream *s;
  int had_err;
  gt_error_check(err);
  s = gt_sequence_node_add_stream_cast(ns);

  /* stream nodes as long as we have some, record seen seqids */
  if (!(had_err = gt_node_stream_next(s->in_stream, gn, err)) && *gn) {
    had_err = gt_genome_node_accept(*gn, s->collect_vis, err);
  }

  /* if there are no more  */
  if (!had_err && !*gn) {
    if (!s->seqids) {
      s->seqids = gt_cstr_table_get_all(s->seqid_table);
    }
    gt_assert(s->seqids);
    if (s->cur_seqid >= gt_str_array_size(s->seqids)) {
      *gn = NULL;
      return 0;
    } else {
      GtGenomeNode *new_sn;
      GtUword len;
      char *seq = NULL;
      GtStr *seqid = gt_str_new(),
            *seqstr = gt_str_new();
      gt_str_append_cstr(seqid, gt_str_array_get(s->seqids, s->cur_seqid));
      had_err = gt_region_mapping_get_sequence_length(s->rm, &len, seqid, err);
      if (!had_err) {
        had_err = gt_region_mapping_get_sequence(s->rm, &seq, seqid, 1, len,
                                                 err);
      }
      if (!had_err) {
        gt_str_append_cstr_nt(seqstr, seq, len);
        new_sn = gt_sequence_node_new(gt_str_get(seqid), seqstr);
        *gn = new_sn;
      }
      s->cur_seqid++;
      gt_free(seq);
      gt_str_delete(seqid);
      gt_str_delete(seqstr);
    }
  }

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
testq %rdx, %rdx
je 0x17c24d
movq %r15, %rdi
callq 0x101a9a
testb %al, %al
jne 0x17c3b1
callq 0x17c1a8
movq %rax, %rdi
movq %r14, %rsi
callq 0x16ae64
movq %rax, %r14
movq 0x10(%rax), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x16ace8
movl %eax, %ebp
testl %eax, %eax
jne 0x17c28f
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x17c28d
movq 0x18(%r14), %rsi
movq %r15, %rdx
callq 0x14b992
movl %eax, %ebp
jmp 0x17c28f
xorl %ebp, %ebp
testl %ebp, %ebp
jne 0x17c3a0
xorl %ebp, %ebp
cmpq $0x0, (%rbx)
jne 0x17c3a0
cmpq $0x0, 0x28(%r14)
jne 0x17c2b7
movq 0x20(%r14), %rdi
callq 0xe8e8e
movq %rax, 0x28(%r14)
movq 0x28(%r14), %rdi
testq %rdi, %rdi
je 0x17c3b6
movq 0x38(%r14), %r12
callq 0x121e78
cmpq %rax, %r12
jae 0x17c399
movq $0x0, 0x8(%rsp)
callq 0x1208f8
movq %rax, %r12
callq 0x1208f8
movq %rax, %r13
movq 0x28(%r14), %rdi
movq 0x38(%r14), %rsi
callq 0x121cfa
movq %r12, %rdi
movq %rax, %rsi
callq 0x12097f
movq 0x30(%r14), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x1761c0
movl %eax, %ebp
testl %eax, %eax
jne 0x17c341
movq 0x30(%r14), %rdi
movq 0x10(%rsp), %r8
leaq 0x8(%rsp), %rsi
movl $0x1, %ecx
movq %r12, %rdx
movq %r15, %r9
callq 0x175a9d
movl %eax, %ebp
testl %ebp, %ebp
jne 0x17c36d
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r13, %rdi
callq 0x120a9d
movq %r12, %rdi
callq 0x120d23
movq %rax, %rdi
movq %r13, %rsi
callq 0x17c0d8
movq %rax, (%rbx)
incq 0x38(%r14)
movq 0x8(%rsp), %rdi
leaq 0x21ff9d(%rip), %rsi    # 0x39c31a
movl $0x58, %edx
callq 0x109670
movq %r12, %rdi
callq 0x121b03
movq %r13, %rdi
callq 0x121b03
jmp 0x17c3a0
movq $0x0, (%rbx)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x55544
callq 0x5557b