// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/targetbest_select_stream.c
// Function: targetbest_select_stream_next
static int targetbest_select_stream_next(GtNodeStream *ns, GtGenomeNode **gn,
                                         GtError *err)
{
  GtTargetbestSelectStream *tfs;
  GtGenomeNode *node;
  int had_err = 0;
  gt_error_check(err);
  tfs = targetbest_select_stream_cast(ns);

  if (!tfs->in_stream_processed) {
    while (!(had_err = gt_node_stream_next(tfs->in_stream, &node, err)) &&
           node) {
      if (gt_feature_node_try_cast(node) &&
          gt_feature_node_get_attribute((GtFeatureNode*) node, "Target")) {
        select_targetbest((GtFeatureNode*) node, tfs->trees,
                          tfs->target_to_elem);
      }
      else
        gt_dlist_add(tfs->trees, node);
    }
    tfs->next = gt_dlist_first(tfs->trees);
    tfs->in_stream_processed = true;
  }

  if (!had_err) {
    gt_assert(tfs->in_stream_processed);
    if (tfs->next) {
      *gn = gt_dlistelem_get_data(tfs->next);
      tfs->next = gt_dlistelem_next(tfs->next);
    }
    else
      *gn = NULL;
    return 0;
  }

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
testq %rdx, %rdx
je 0x188db8
movq %r12, %rdi
callq 0x101a9a
testb %al, %al
jne 0x189062
callq 0x188cf4
movq %rax, %rdi
movq %rbx, %rsi
callq 0x16ae64
movq %rax, %r15
xorl %ebx, %ebx
cmpb $0x0, 0x30(%rax)
jne 0x189009
movq %r14, 0x18(%rsp)
movq 0x10(%r15), %rdi
movq %rsp, %r14
movq %r14, %rsi
movq %r12, %rdx
callq 0x16ace8
movl %eax, %ebx
testl %eax, %eax
sete %al
movq (%r14), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x188ff2
movq %rsp, %r14
movq %r15, 0x20(%rsp)
movq %r12, 0x10(%rsp)
callq 0x14aefc
testq %rax, %rax
je 0x188f8f
movq (%rsp), %rdi
leaq 0x1ccb16(%rip), %rsi    # 0x355945
callq 0x14918c
testq %rax, %rax
je 0x188f8f
movq (%rsp), %rbp
testq %rbp, %rbp
je 0x189053
movq 0x18(%r15), %r12
testq %r12, %r12
je 0x189053
movq 0x28(%r15), %r13
movq %rbp, %rdi
leaq 0x1ccae0(%rip), %rsi    # 0x355945
callq 0x14918c
testq %rax, %rax
je 0x18904e
movq %rax, %r14
callq 0x1208f8
movq %rax, %rbx
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x24a9fb(%rip), %r9     # 0x3d3890
pushq $0x0
pushq $0x0
callq 0x14e5b7
addq $0x10, %rsp
testl %eax, %eax
jne 0x189058
cmpq $0x1, 0x30(%rsp)
jne 0x188f9e
callq 0x1208f8
testq %rbx, %rbx
je 0x18905d
movq %rax, %r15
testq %rax, %rax
je 0x18905d
movq %r15, %rdi
callq 0x120db4
movq %rbp, %rdi
callq 0x14b89b
movq %r15, %rdi
movq %rax, %rsi
callq 0x120a43
movq %r15, %rdi
movl $0x9, %esi
callq 0x120ba5
movq %r15, %rdi
movq %rbx, %rsi
callq 0x120a43
movq %r15, %rdi
callq 0x120d23
movq %r13, %rdi
movq %rax, %rsi
callq 0x105a11
testq %rax, %rax
je 0x188f7c
movq %rax, %r14
movq %rax, %rdi
callq 0xea174
movq %rax, 0x28(%rsp)
movq %rbp, %rdi
callq 0x149ef0
movss %xmm0, 0xc(%rsp)
movq 0x28(%rsp), %rdi
callq 0x149ef0
movss 0xc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x188fab
movq %r14, %rdi
callq 0xea174
movq %rax, %rdi
callq 0x14c43a
movq %r12, %rdi
movq %r14, %rsi
callq 0xea2ed
movq %r15, %rdi
callq 0x120d23
movq %r13, %rdi
movq %rax, %rsi
callq 0x105a8a
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x1890eb
jmp 0x188fb3
movq 0x18(%r15), %rdi
movq (%rsp), %rsi
callq 0xea1a1
jmp 0x188fd0
movq %r12, %rdi
movq %rbp, %rsi
callq 0xea1a1
jmp 0x188fc0
movq %rbp, %rdi
callq 0x14c43a
movq %r15, %rdi
callq 0x121b03
movq 0x20(%rsp), %r15
movq 0x10(%rsp), %r12
movq %rsp, %r14
movq %rbx, %rdi
callq 0x121b03
movq 0x10(%r15), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x16ace8
movl %eax, %ebx
testl %eax, %eax
jne 0x188ff2
movq (%rsp), %rdi
testq %rdi, %rdi
jne 0x188e16
movq 0x18(%r15), %rdi
callq 0xea0f8
movq %rax, 0x20(%r15)
movb $0x1, 0x30(%r15)
movq 0x18(%rsp), %r14
testl %ebx, %ebx
jne 0x18903d
cmpb $0x0, 0x30(%r15)
je 0x189067
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x189034
callq 0xea174
movq %rax, (%r14)
movq 0x20(%r15), %rdi
callq 0xea184
movq %rax, 0x20(%r15)
jmp 0x18903b
movq $0x0, (%r14)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x59043
callq 0x58f9e
callq 0x58fd5
callq 0x5900c
callq 0x58f65
callq 0x5907a