// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/ltr/ltrdigest_pdom_visitor.c
// Function: gt_ltrdigest_pdom_visitor_choose_strand
static int gt_ltrdigest_pdom_visitor_choose_strand(GtLTRdigestPdomVisitor *lv)
{
  int had_err = 0;
  double log_eval_fwd = 0.0,
         log_eval_rev = 0.0;
  GtFeatureNodeIterator *fni;
  GtStrand strand;
  double score;
  bool seen_fwd = false,
       seen_rev = false;
  GtFeatureNode *curnode = NULL;
  GtUword i;
  GtArray *to_delete;

  fni = gt_feature_node_iterator_new(lv->ltr_retrotrans);
  while (!had_err && (curnode = gt_feature_node_iterator_next(fni))) {
    if (strcmp(gt_feature_node_get_type(curnode),
               gt_ft_protein_match) == 0) {
      strand = gt_feature_node_get_strand(curnode);
      score = (double) gt_feature_node_get_score(curnode);
      if (strand == GT_STRAND_FORWARD) {
        log_eval_fwd += log(score);
        seen_fwd = true;
      } else if (strand == GT_STRAND_REVERSE) {
        log_eval_rev += log(score);
        seen_rev = true;
      }
    }
  }
  gt_feature_node_iterator_delete(fni);

  if (seen_rev && !seen_fwd)
    gt_feature_node_set_strand(lv->ltr_retrotrans, GT_STRAND_REVERSE);
  else if (!seen_rev && seen_fwd)
    gt_feature_node_set_strand(lv->ltr_retrotrans, GT_STRAND_FORWARD);
  else if (!seen_rev && !seen_fwd)
    return had_err;
  else {
    gt_assert(seen_rev && seen_fwd);
    if (gt_double_compare(log_eval_fwd, log_eval_rev) < 0)
      strand = GT_STRAND_FORWARD;
    else
      strand = GT_STRAND_REVERSE;
    gt_feature_node_set_strand(lv->ltr_retrotrans, strand);

    to_delete = gt_array_new(sizeof (GtFeatureNode*));
    fni = gt_feature_node_iterator_new(lv->ltr_retrotrans);
    while (!had_err && (curnode = gt_feature_node_iterator_next(fni))) {
      if (strcmp(gt_feature_node_get_type(curnode),
                 gt_ft_protein_match) == 0) {
        if (strand != gt_feature_node_get_strand(curnode)) {
          gt_array_add(to_delete, curnode);
        }
      }
    }
    gt_feature_node_iterator_delete(fni);
    gt_assert(gt_array_size(to_delete) > 0);
    for (i = 0; i < gt_array_size(to_delete); i++) {
      gt_feature_node_remove_leaf(lv->ltr_retrotrans,
                                  *(GtFeatureNode**) gt_array_get(to_delete,
                                                                  i));
    }
    gt_array_delete(to_delete);
  }
  return had_err;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
movb $0x0, 0x37(%rsp)
movb $0x0, 0x36(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x170b00
movq %rax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x64(%rsp)
movb %al, 0x17(%rsp)
jne 0x3088d0
movq 0x48(%rsp), %rdi
callq 0x170e30
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
setne %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x3088dd
jmp 0x30896e
movq 0x28(%rsp), %rdi
callq 0x16d430
movq %rax, %rdi
leaq 0x24a941(%rip), %rsi    # 0x553232
callq 0x19980
cmpl $0x0, %eax
jne 0x308969
movq 0x28(%rsp), %rdi
callq 0x16cc70
movl %eax, 0x44(%rsp)
movq 0x28(%rsp), %rdi
callq 0x16df90
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
cmpl $0x0, 0x44(%rsp)
jne 0x308942
movsd 0x38(%rsp), %xmm0
callq 0x195c0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movb $0x1, 0x37(%rsp)
jmp 0x308967
cmpl $0x1, 0x44(%rsp)
jne 0x308965
movsd 0x38(%rsp), %xmm0
callq 0x195c0
addsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movb $0x1, 0x36(%rsp)
jmp 0x308967
jmp 0x308969
jmp 0x3088a9
movq 0x48(%rsp), %rdi
callq 0x170f50
testb $0x1, 0x36(%rsp)
je 0x30899e
testb $0x1, 0x37(%rsp)
jne 0x30899e
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rdi
movl $0x1, %esi
callq 0x16e0f0
jmp 0x308bcc
testb $0x1, 0x36(%rsp)
jne 0x3089c1
testb $0x1, 0x37(%rsp)
je 0x3089c1
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rdi
xorl %esi, %esi
callq 0x16e0f0
jmp 0x308bca
testb $0x1, 0x36(%rsp)
jne 0x3089dc
testb $0x1, 0x37(%rsp)
jne 0x3089dc
movl 0x64(%rsp), %eax
movl %eax, 0x74(%rsp)
jmp 0x308bd4
jmp 0x3089de
testb $0x1, 0x36(%rsp)
je 0x3089ec
testb $0x1, 0x37(%rsp)
jne 0x308a24
movq 0x3335ad(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x20d616(%rip), %rsi    # 0x516013
leaq 0x28b2d1(%rip), %rdx    # 0x593cd5
leaq 0x28b2df(%rip), %rcx    # 0x593cea
leaq 0x28aae7(%rip), %r8     # 0x5934f9
movl $0x2e6, %r9d            # imm = 0x2E6
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x308a26
movsd 0x58(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
callq 0xec290
cmpl $0x0, %eax
jge 0x308a46
movl $0x0, 0x44(%rsp)
jmp 0x308a4e
movl $0x1, 0x44(%rsp)
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rdi
movl 0x44(%rsp), %esi
callq 0x16e0f0
movl $0x8, %edi
callq 0x80990
movq %rax, 0x18(%rsp)
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x170b00
movq %rax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x64(%rsp)
movb %al, 0x16(%rsp)
jne 0x308aa9
movq 0x48(%rsp), %rdi
callq 0x170e30
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
setne %al
movb %al, 0x16(%rsp)
movb 0x16(%rsp), %al
testb $0x1, %al
jne 0x308ab3
jmp 0x308b08
movq 0x28(%rsp), %rdi
callq 0x16d430
movq %rax, %rdi
leaq 0x24a76b(%rip), %rsi    # 0x553232
callq 0x19980
cmpl $0x0, %eax
jne 0x308b03
movl 0x44(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x28(%rsp), %rdi
callq 0x16cc70
movl %eax, %ecx
movl 0x10(%rsp), %eax
cmpl %ecx, %eax
je 0x308b01
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
jmp 0x308b03
jmp 0x308a82
movq 0x48(%rsp), %rdi
callq 0x170f50
movq 0x18(%rsp), %rdi
callq 0x81370
cmpq $0x0, %rax
ja 0x308b5a
movq 0x333477(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x20d4e0(%rip), %rsi    # 0x516013
leaq 0x28b1d8(%rip), %rdx    # 0x593d12
leaq 0x28b1a9(%rip), %rcx    # 0x593cea
leaq 0x28a9b1(%rip), %r8     # 0x5934f9
movl $0x2f8, %r9d            # imm = 0x2F8
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x308b5c
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x308bbe
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x80b60
movq (%rsp), %rdi
movq (%rax), %rsi
callq 0x16fd20
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x308b65
movq 0x18(%rsp), %rdi
callq 0x81f80
jmp 0x308bca
jmp 0x308bcc
movl 0x64(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax)