// File: /workspace/github_c_makefile_star2_O2/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 0x117f6f
movq %r15, %rdi
callq 0x89eb7
testb %al, %al
jne 0x1180d1
callq 0x117ecc
movq %rax, %rdi
movq %r14, %rsi
callq 0x102c81
movq %rax, %r14
movq 0x10(%rax), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x102a22
testl %eax, %eax
je 0x117fa8
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 0x117fc8
movq 0x18(%r14), %rsi
movq %r15, %rdx
callq 0xdd39c
testl %eax, %eax
jne 0x117f95
xorl %ebp, %ebp
cmpq $0x0, (%rbx)
jne 0x117f97
movq 0x28(%r14), %rdi
testq %rdi, %rdi
jne 0x117fea
movq 0x20(%r14), %rdi
callq 0x6cbf8
movq %rax, %rdi
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x118107
movq 0x38(%r14), %r12
callq 0xae61c
cmpq %rax, %r12
jae 0x118044
andq $0x0, 0x8(%rsp)
callq 0xacb84
movq %rax, %r12
callq 0xacb84
movq %rax, %r13
movq 0x28(%r14), %rdi
movq 0x38(%r14), %rsi
callq 0xae386
movq %r12, %rdi
movq %rax, %rsi
callq 0xacbfb
movq 0x30(%r14), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x110368
testl %eax, %eax
je 0x11804f
movl %eax, %ebp
xorl %eax, %eax
jmp 0x1180a6
andq $0x0, (%rbx)
xorl %ebp, %ebp
jmp 0x117f97
movq 0x30(%r14), %rdi
movq 0x10(%rsp), %r8
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rcx
movq %r12, %rdx
movq %r15, %r9
callq 0x10fad0
movl %eax, %ebp
leaq 0x8(%rsp), %rax
movq (%rax), %rax
testl %ebp, %ebp
jne 0x1180a6
movq 0x10(%rsp), %rdx
movq %r13, %rdi
movq %rax, %rsi
callq 0xacd9e
movq %r12, %rdi
callq 0xad1fa
movq %rax, %rdi
movq %r13, %rsi
callq 0x117d40
movq %rax, (%rbx)
xorl %ebp, %ebp
movq 0x8(%rsp), %rax
incq 0x38(%r14)
leaq 0x21b159(%rip), %rsi    # 0x33320a
pushq $0x58
popq %rdx
movq %rax, %rdi
callq 0x936f9
movq %r12, %rdi
callq 0xae103
movq %r13, %rdi
callq 0xae103
jmp 0x117f97
movq 0x31fe90(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1ccf31(%rip), %rsi    # 0x2e5013
leaq 0x1cd0d6(%rip), %rdx    # 0x2e51bf
leaq 0x21b142(%rip), %rcx    # 0x333232
leaq 0x21b113(%rip), %r8     # 0x33320a
pushq $0x35
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x31fe5a(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1ccefb(%rip), %rsi    # 0x2e5013
leaq 0x21b131(%rip), %rdx    # 0x333250
leaq 0x21b10c(%rip), %rcx    # 0x333232
leaq 0x21b0dd(%rip), %r8     # 0x33320a
pushq $0x42
jmp 0x1180f9