// File: /workspace/github_c_makefile_star2_O2/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 0x955a7
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
movq (%rbx,%rcx,8), %r15
testq %r15, %r15
je 0x1c1f0d
movq %r15, %rdi
callq 0x586a4
testq %rax, %rax
je 0x1c1dbb
movq %rax, %r12
cmpq $0x1, %rax
jne 0x1c1dcc
leaq 0x10(%rsp), %r12
andq $0x0, (%r12)
movq %r15, %rdi
xorl %esi, %esi
callq 0x581aa
movq (%rax), %r15
movq 0x40(%r15), %rdi
pushq $0x8
popq %rdx
movq %r12, %rsi
callq 0x5851d
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1c200d
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, 0x8(%rsp)
imulq $0x30, %r12, %rdi
leaq 0x19e906(%rip), %rsi    # 0x3606e2
movl $0x28e, %edx            # imm = 0x28E
callq 0x93160
movq %rax, %rbp
movq %rax, (%rsp)
addq $0x28, %rbp
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x1c1e4d
movq %r15, %rdi
movq %r13, %rsi
callq 0x581aa
movq (%rax), %rax
testq %rax, %rax
je 0x1c1ed5
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
cvtsi2sd %rdx, %xmm0
mulsd 0x30(%rax), %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, -0x8(%rbp)
movq %rax, (%rbp)
incq %r13
addq $0x30, %rbp
jmp 0x1c1df4
leaq 0xe7(%rip), %rcx        # 0x1c1f3b
pushq $0x30
popq %rdx
movq (%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x17ed0
leaq 0x19ef55(%rip), %rdi    # 0x360dc2
xorl %r13d, %r13d
movq 0x8(%rsp), %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x92a82
movl 0x60(%r14), %edx
leaq 0xcf(%rip), %rcx        # 0x1c1f59
leaq 0x10(%rsp), %r8
movq %rbp, %rdi
movq %r12, %rsi
callq 0x29be18
leaq 0x19e841(%rip), %rsi    # 0x3606e2
movq %rbp, %rdi
movl $0x29f, %edx            # imm = 0x29F
callq 0x936f9
cmpq %r13, %r12
je 0x1c1dbb
movq %r15, %rdi
movq %r13, %rsi
callq 0x581aa
movq (%rax), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1c200d
incq %r13
jmp 0x1c1eae
movq 0x27608c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x12312d(%rip), %rsi    # 0x2e5013
leaq 0x18ab23(%rip), %rdx    # 0x34ca10
leaq 0x19eea8(%rip), %rcx    # 0x360d9c
leaq 0x19e7e7(%rip), %r8     # 0x3606e2
movl $0x291, %r9d            # imm = 0x291
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x276054(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1230f5(%rip), %rsi    # 0x2e5013
leaq 0x1277bb(%rip), %rdx    # 0x2e96e0
leaq 0x19ee70(%rip), %rcx    # 0x360d9c
leaq 0x19e7af(%rip), %r8     # 0x3606e2
movl $0x288, %r9d            # imm = 0x288
jmp 0x1c1f01