// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/ltr/ltrdigest_pdom_visitor.c
// Function: gt_ltrdigest_pdom_visitor_process_hit
static int gt_ltrdigest_pdom_visitor_process_hit(GT_UNUSED void *key, void *val,
                                                 void *data,
                                                 GT_UNUSED GtError *err)
{
  GtHMMERModelHit *mh = (GtHMMERModelHit*) val;
  GtLTRdigestPdomVisitor *lv = (GtLTRdigestPdomVisitor*) data;
  const char *mdl = (const char*) key;
  GtArray *hits = NULL;
  GtUword nof_hits;
  GtFragment *frags;

  if (gt_double_compare(mh->best_fwd, mh->best_rev) <= 0)
    hits = mh->fwd_hits;
  else
    hits = mh->rev_hits;
  gt_assert(hits);
  nof_hits = gt_array_size(hits);
  if (nof_hits == 0) return 0;

  if (nof_hits > 1UL) {
    GtUword i, chainno;
    frags = gt_malloc((size_t) nof_hits * sizeof (GtFragment));
    for (i = 0; i < nof_hits; i++) {
      GtHMMERSingleHit *h = *(GtHMMERSingleHit**) gt_array_get(hits, i);
      gt_assert(h);
      frags[i].startpos1 = h->hmmfrom;
      frags[i].endpos1   = h->hmmto;
      frags[i].startpos2 = h->alifrom;
      frags[i].endpos2   = h->alito;
      frags[i].weight    = (GtWord) (h->alito - h->alifrom + 1) * h->score;
      frags[i].data      = h;
    }
    qsort(frags, (size_t) nof_hits, sizeof (GtFragment),
          gt_ltrdigest_pdom_visitor_fragcmp);
    gt_log_log("%s: chaining "GT_WU" frags", mdl, nof_hits);
    gt_globalchaining_max(frags, nof_hits,
                         (GtUword) lv->chain_max_gap_length,
                         gt_ltrdigest_pdom_visitor_chainproc, &chainno);
    gt_free(frags);
    for (i = 0; i < nof_hits; i++) {
      GtHMMERSingleHit *h = *(GtHMMERSingleHit**) gt_array_get(hits, i);
      (void) gt_ltrdigest_pdom_visitor_attach_hit(lv, mh, h);
    }
  } else {
    GtUword chainno = 0UL;
    GtHMMERSingleHit *h = *(GtHMMERSingleHit**) gt_array_get(hits, 0);
    gt_array_add(h->chains, chainno);
    (void) gt_ltrdigest_pdom_visitor_attach_hit(lv, mh, h);
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r13
movsd 0x20(%rsi), %xmm1
movsd 0x28(%rsi), %xmm0
callq 0x105c1c
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
movq (%rbx,%rcx,8), %r15
testq %r15, %r15
je 0x20d97c
movq %r15, %rdi
callq 0xd24e0
testq %rax, %rax
je 0x20d966
movq %rax, %r12
cmpq $0x1, %rax
jne 0x20d859
leaq 0x10(%rsp), %r12
movq $0x0, (%r12)
movq %r15, %rdi
xorl %esi, %esi
callq 0xd2207
movq (%rax), %r15
movq 0x40(%r15), %rdi
movl $0x8, %edx
movq %r12, %rsi
callq 0xd2410
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x20da63
jmp 0x20d966
movq %r13, 0x8(%rsp)
movq %r12, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdi
leaq 0x1b2a5c(%rip), %rsi    # 0x3c02cc
movl $0x28e, %edx            # imm = 0x28E
callq 0x104226
movq %rax, %rbp
movq %rax, (%rsp)
addq $0x28, %rbp
xorl %r13d, %r13d
movq %r15, %rdi
movq %r13, %rsi
callq 0xd2207
movq (%rax), %rax
testq %rax, %rax
je 0x20d977
movups (%rax), %xmm0
movups %xmm0, -0x28(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x18(%rbp)
movq 0x18(%rax), %rdx
movq %rdx, -0x10(%rbp)
subq %rcx, %rdx
incq %rdx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
mulsd 0x30(%rax), %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, -0x8(%rbp)
movq %rax, (%rbp)
incq %r13
addq $0x30, %rbp
cmpq %r13, %r12
jne 0x20d888
leaq 0x98(%rip), %rcx        # 0x20d981
movl $0x30, %edx
movq (%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x17f60
leaq 0x1b30a8(%rip), %rdi    # 0x3c09ac
xorl %r13d, %r13d
movq 0x8(%rsp), %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x103d72
movl 0x60(%r14), %edx
leaq 0x7e(%rip), %rcx        # 0x20d99f
leaq 0x10(%rsp), %r8
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2feaa8
leaq 0x1b2994(%rip), %rsi    # 0x3c02cc
movq %rbp, %rdi
movl $0x29f, %edx            # imm = 0x29F
callq 0x1045eb
movq %r15, %rdi
movq %r13, %rsi
callq 0xd2207
movq (%rax), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20da63
incq %r13
cmpq %r13, %r12
jne 0x20d945
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x813c8
callq 0x81401