// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/merge_stream.c
// Function: merge_stream_next_in_order
static int merge_stream_next_in_order(GtNodeStream *ns, GtGenomeNode **gn,
                                      GtError *err)
{
  GtMergeStream *ms;
  GtGenomeNode *min_node = NULL;
  GtUword i;
  int had_err = 0;
  gt_error_check(err);
  ms = gt_merge_stream_cast(ns);

  /* initially fill the queue with first nodes from input streams */
  if (!ms->filled) {
    for (i = 0; !had_err && i < gt_array_size(ms->node_streams); i++) {
      GtGenomeNode *firstnode = NULL;
      ms->items[i].input_index = i;
      had_err = gt_node_stream_next(*(GtNodeStream**)
                                      gt_array_get(ms->node_streams, i),
                                    &firstnode, err);
      /* only add start of non-empty input streams */
      if (!had_err && firstnode) {
        if (!gt_eof_node_try_cast(firstnode)) {
          ms->items[i].gn = firstnode;
          ms->items[i].input_index = i;
          gt_priority_queue_add(ms->pq, ms->items+i);
        } else {
          gt_genome_node_delete(firstnode);
        }
      }
    }
    ms->filled = true;
  }

  /* stream the queue contents */
  if (!had_err && !gt_priority_queue_is_empty(ms->pq)) {
    GtMergeStreamItem *min_item = gt_priority_queue_extract_min(ms->pq);
    GtGenomeNode *nextnode = NULL;
    gt_assert(min_item && min_item->gn);
    min_node = min_item->gn;
    /* get next element from the last stream queried */
    had_err = gt_node_stream_next(*(GtNodeStream**)
                                    gt_array_get(ms->node_streams,
                                                 min_item->input_index),
                                  &nextnode, err);
    /* add node to queue if still non-EOF nodes left in that stream */
    if (!had_err && nextnode) {
      if (!gt_eof_node_try_cast(nextnode)) {
        min_item->gn = nextnode;
        gt_priority_queue_add(ms->pq, min_item);
      } else {
        min_item->gn = NULL;
        gt_genome_node_delete(nextnode);
      }
    }
  }

  *gn = min_node;
  return had_err;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq $0x0, 0x40(%rsp)
movl $0x0, 0x34(%rsp)
cmpq $0x0, 0x50(%rsp)
je 0x1aeed4
movq 0x50(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x1aee9c
jmp 0x1aeed4
movq 0x48d0fd(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x367166(%rip), %rsi    # 0x516013
leaq 0x36730b(%rip), %rdx    # 0x5161bf
leaq 0x3b0334(%rip), %rcx    # 0x55f1ef
leaq 0x3b0283(%rip), %r8     # 0x55f145
movl $0x42, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1aeed6
callq 0x1ae7c0
movq %rax, %rdi
movq 0x60(%rsp), %rsi
callq 0x1b20f0
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
testb $0x1, 0x38(%rax)
jne 0x1af046
movq $0x0, 0x38(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x34(%rsp)
movb %al, 0x17(%rsp)
jne 0x1aef3c
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x1aef49
jmp 0x1af03d
movq $0x0, 0x28(%rsp)
movq 0x38(%rsp), %rcx
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x38(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x38(%rsp), %rsi
callq 0x80b60
movq (%rax), %rdi
movq 0x50(%rsp), %rdx
leaq 0x28(%rsp), %rsi
callq 0x1b1d90
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jne 0x1af028
cmpq $0x0, 0x28(%rsp)
je 0x1af028
movq 0x28(%rsp), %rdi
callq 0x48f4c0
cmpq $0x0, %rax
jne 0x1af01c
movq 0x28(%rsp), %rcx
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x38(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq 0x38(%rsp), %rcx
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x38(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0x48(%rsp), %rax
movq 0x30(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x28(%rax), %rsi
movq 0x38(%rsp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x1b6120
jmp 0x1af026
movq 0x28(%rsp), %rdi
callq 0x173180
jmp 0x1af028
jmp 0x1af02a
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0x1aef05
movq 0x48(%rsp), %rax
movb $0x1, 0x38(%rax)
cmpl $0x0, 0x34(%rsp)
jne 0x1af165
movq 0x48(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0x1b6040
testb $0x1, %al
jne 0x1af165
movq 0x48(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0x1b6360
movq %rax, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x1af096
movq 0x20(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x1af0ce
movq 0x48cf03(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x366f6c(%rip), %rsi    # 0x516013
leaq 0x3b015c(%rip), %rdx    # 0x55f20a
leaq 0x3b013a(%rip), %rcx    # 0x55f1ef
leaq 0x3b0089(%rip), %r8     # 0x55f145
movl $0x5f, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1af0d0
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x80b60
movq (%rax), %rdi
movq 0x50(%rsp), %rdx
leaq 0x18(%rsp), %rsi
callq 0x1b1d90
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jne 0x1af163
cmpq $0x0, 0x18(%rsp)
je 0x1af163
movq 0x18(%rsp), %rdi
callq 0x48f4c0
cmpq $0x0, %rax
jne 0x1af14b
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movq 0x48(%rsp), %rax
movq 0x30(%rax), %rdi
movq 0x20(%rsp), %rsi
callq 0x1b6120
jmp 0x1af161
movq 0x20(%rsp), %rax
movq $0x0, (%rax)
movq 0x18(%rsp), %rdi
callq 0x173180
jmp 0x1af163
jmp 0x1af165
movq 0x40(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, (%rax)
movl 0x34(%rsp), %eax
addq $0x68, %rsp
retq
nopl (%rax,%rax)