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

  gt_assert(!ms->second_node); /* the second buffer is always empty when this
                                  function is called */
  if (!ms->first_node) {
    /* both buffers are empty */
    had_err = merge_stream_next_in_order(ns, &ms->first_node, err);
    if (had_err)
      return had_err;
    if (!ms->first_node) {
      *gn = NULL;
      return 0;
    }
  }

  while (!had_err) {
    gt_assert(ms->first_node && !ms->second_node);
    had_err = merge_stream_next_in_order(ns, &ms->second_node, err);
    if (!had_err && ms->second_node) {
      if (!merge_stream_consolidate(&ms->first_node, &ms->second_node))
        break;
    }
    else
      break;
  }

  if (!had_err) {
    gt_assert(ms->first_node);
    *gn = ms->first_node;
    ms->first_node = ms->second_node;
    ms->second_node = NULL;
  }

  return had_err;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
testq %rdx, %rdx
je 0x100b80
movq %r14, %rdi
callq 0x89eb7
testb %al, %al
jne 0x100cfa
callq 0x100a94
movq %rax, %rdi
movq %r15, %rsi
callq 0x102c81
cmpq $0x0, 0x20(%rax)
jne 0x100ccc
movq %rax, %r12
leaq 0x18(%rax), %r13
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x100c3a
addq $0x20, %r12
testq %rax, %rax
je 0x100c68
cmpq $0x0, (%r12)
jne 0x100c68
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x100f56
testl %eax, %eax
jne 0x100c4c
movq (%r12), %rsi
testq %rsi, %rsi
je 0x100c19
movq (%r13), %rdi
testq %rdi, %rdi
je 0x100c96
callq 0xdd708
testb %al, %al
je 0x100c19
movq (%r13), %rdi
movq (%r12), %rsi
callq 0x111199
movq (%r12), %rdi
callq 0xde013
andq $0x0, (%r12)
movq (%r13), %rax
jmp 0x100bb3
movq (%r13), %rax
testq %rax, %rax
je 0x100d28
movq %rax, (%rbx)
movq (%r12), %rax
movq %rax, (%r13)
andq $0x0, (%r12)
xorl %eax, %eax
jmp 0x100c4c
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x100f56
testl %eax, %eax
je 0x100c56
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq (%r13), %rax
testq %rax, %rax
jne 0x100baf
movq %rbx, %r12
jmp 0x100c31
movq 0x3372f9(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1e439a(%rip), %rsi    # 0x2e5013
leaq 0x22c12d(%rip), %rdx    # 0x32cdad
leaq 0x22c114(%rip), %rcx    # 0x32cd9b
leaq 0x22c0a7(%rip), %r8     # 0x32cd35
movl $0x9d, %r9d
jmp 0x100cc0
movq 0x3372cb(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1e436c(%rip), %rsi    # 0x2e5013
leaq 0x22c165(%rip), %rdx    # 0x32ce13
leaq 0x22c17a(%rip), %rcx    # 0x32ce2f
leaq 0x22c079(%rip), %r8     # 0x32cd35
pushq $0x79
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x337295(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1e4336(%rip), %rsi    # 0x2e5013
leaq 0x22c0db(%rip), %rdx    # 0x32cdbf
leaq 0x22c0b0(%rip), %rcx    # 0x32cd9b
leaq 0x22c043(%rip), %r8     # 0x32cd35
movl $0x8f, %r9d
jmp 0x100cc0
movq 0x337267(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1e4308(%rip), %rsi    # 0x2e5013
leaq 0x1e44ad(%rip), %rdx    # 0x2e51bf
leaq 0x22c082(%rip), %rcx    # 0x32cd9b
leaq 0x22c015(%rip), %r8     # 0x32cd35
movl $0x8c, %r9d
jmp 0x100cc0
movq 0x337239(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1e42da(%rip), %rsi    # 0x2e5013
leaq 0x22c090(%rip), %rdx    # 0x32cdd0
leaq 0x22c054(%rip), %rcx    # 0x32cd9b
leaq 0x22bfe7(%rip), %r8     # 0x32cd35
movl $0xa8, %r9d
jmp 0x100cc0