// File: /workspace/github_c_makefile_star2_O3/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 0x180708
movq %r12, %rdi
callq 0xfcc32
testb %al, %al
jne 0x1809b0
callq 0x180644
movq %rax, %rdi
movq %rbx, %rsi
callq 0x162ff7
movq %rax, %r15
cmpb $0x0, 0x30(%rax)
je 0x18072c
jne 0x180962
callq 0x57dfb
movq %r14, 0x18(%rsp)
movq 0x10(%r15), %rdi
movq %rsp, %r14
movq %r14, %rsi
movq %r12, %rdx
callq 0x162e68
movl %eax, %ebx
testl %eax, %eax
sete %al
movq (%r14), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x180947
movq %rsp, %r14
movq %r15, 0x20(%rsp)
movq %r12, 0x10(%rsp)
callq 0x143cab
testq %rax, %rax
je 0x1808e4
movq (%rsp), %rdi
leaq 0x1cc192(%rip), %rsi    # 0x34c916
callq 0x141f50
testq %rax, %rax
je 0x1808e4
movq (%rsp), %rbp
testq %rbp, %rbp
je 0x1809a1
movq 0x18(%r15), %r12
testq %r12, %r12
je 0x1809a1
movq 0x28(%r15), %r13
movq %rbp, %rdi
leaq 0x1cc15c(%rip), %rsi    # 0x34c916
callq 0x141f50
testq %rax, %rax
je 0x18099c
movq %rax, %r14
callq 0x11ac6c
movq %rax, %rbx
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq 0x249986(%rip), %r9     # 0x3ca170
pushq $0x0
pushq $0x0
callq 0x147267
addq $0x10, %rsp
testl %eax, %eax
jne 0x1809a6
cmpq $0x1, 0x30(%rsp)
jne 0x1808f3
callq 0x11ac6c
testq %rbx, %rbx
je 0x1809ab
movq %rax, %r15
testq %rax, %rax
je 0x1809ab
movq %r15, %rdi
callq 0x11b132
movq %rbp, %rdi
callq 0x144635
movq %r15, %rdi
movq %rax, %rsi
callq 0x11adc1
movq %r15, %rdi
movl $0x9, %esi
callq 0x11af23
movq %r15, %rdi
movq %rbx, %rsi
callq 0x11adc1
movq %r15, %rdi
callq 0x11b0a1
movq %r13, %rdi
movq %rax, %rsi
callq 0x100add
testq %rax, %rax
je 0x1808d1
movq %rax, %r14
movq %rax, %rdi
callq 0xe5c10
movq %rax, 0x28(%rsp)
movq %rbp, %rdi
callq 0x142cc3
movss %xmm0, 0xc(%rsp)
movq 0x28(%rsp), %rdi
callq 0x142cc3
movss 0xc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x180900
movq %r14, %rdi
callq 0xe5c10
movq %rax, %rdi
callq 0x1451a0
movq %r12, %rdi
movq %r14, %rsi
callq 0xe5d89
movq %r15, %rdi
callq 0x11b0a1
movq %r13, %rdi
movq %rax, %rsi
callq 0x100b56
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x180a34
jmp 0x180908
movq 0x18(%r15), %rdi
movq (%rsp), %rsi
callq 0xe5c3d
jmp 0x180925
movq %r12, %rdi
movq %rbp, %rsi
callq 0xe5c3d
jmp 0x180915
movq %rbp, %rdi
callq 0x1451a0
movq %r15, %rdi
callq 0x11bdbf
movq 0x20(%rsp), %r15
movq 0x10(%rsp), %r12
movq %rsp, %r14
movq %rbx, %rdi
callq 0x11bdbf
movq 0x10(%r15), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x162e68
movl %eax, %ebx
testl %eax, %eax
jne 0x180947
movq (%rsp), %rdi
testq %rdi, %rdi
jne 0x18076b
movq 0x18(%r15), %rdi
callq 0xe5b94
movq %rax, 0x20(%r15)
movb $0x1, 0x30(%r15)
testl %ebx, %ebx
movq 0x18(%rsp), %r14
jne 0x18098b
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x180982
callq 0xe5c10
movq %rax, (%r14)
movq 0x20(%r15), %rdi
callq 0xe5c20
movq %rax, 0x20(%r15)
jmp 0x180989
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 0x57dc4
callq 0x57d1f
callq 0x57d56
callq 0x57d8d
callq 0x57ce6