// File: /workspace/github_c_makefile_star2_O3/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 0x173e59
movq %r15, %rdi
callq 0xfcc32
testb %al, %al
jne 0x173fc5
callq 0x173db4
movq %rax, %rdi
movq %r14, %rsi
callq 0x162ff7
movq %rax, %r14
movq 0x10(%rax), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x162e68
testl %eax, %eax
je 0x173e92
movl %eax, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x173eb2
movq 0x18(%r14), %rsi
movq %r15, %rdx
callq 0x14472c
testl %eax, %eax
jne 0x173e7f
xorl %ebp, %ebp
cmpq $0x0, (%rbx)
jne 0x173e81
movq 0x28(%r14), %rdi
testq %rdi, %rdi
jne 0x173ed4
movq 0x20(%r14), %rdi
callq 0xe49c2
movq %rax, %rdi
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x173fca
movq 0x38(%r14), %r12
callq 0x11c131
cmpq %rax, %r12
jae 0x173f31
movq $0x0, 0x8(%rsp)
callq 0x11ac6c
movq %rax, %r12
callq 0x11ac6c
movq %rax, %r13
movq 0x28(%r14), %rdi
movq 0x38(%r14), %rsi
callq 0x11bfb3
movq %r12, %rdi
movq %rax, %rsi
callq 0x11acf3
movq 0x30(%r14), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x16de81
testl %eax, %eax
je 0x173f3f
movl %eax, %ebp
xorl %eax, %eax
jmp 0x173f98
movq $0x0, (%rbx)
xorl %ebp, %ebp
jmp 0x173e81
movq 0x30(%r14), %rdi
movq 0x10(%rsp), %r8
leaq 0x8(%rsp), %rsi
movl $0x1, %ecx
movq %r12, %rdx
movq %r15, %r9
callq 0x16d815
movl %eax, %ebp
leaq 0x8(%rsp), %rax
movq (%rax), %rax
testl %ebp, %ebp
jne 0x173f98
movq 0x10(%rsp), %rdx
movq %r13, %rdi
movq %rax, %rsi
callq 0x11ae1b
movq %r12, %rdi
callq 0x11b0a1
movq %rax, %rdi
movq %r13, %rsi
callq 0x173ce4
movq %rax, (%rbx)
xorl %ebp, %ebp
movq 0x8(%rsp), %rax
incq 0x38(%r14)
leaq 0x21ef0e(%rip), %rsi    # 0x392eb1
movq %rax, %rdi
movl $0x58, %edx
callq 0x1045eb
movq %r12, %rdi
callq 0x11bdbf
movq %r13, %rdi
callq 0x11bdbf
jmp 0x173e81
callq 0x54454
callq 0x5448b