// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: collect_hc_links(ha_ug_index const*, kvec_pe_hit*, hc_links*, bubble_type*, MT*)
void collect_hc_links(const ha_ug_index* idx, kvec_pe_hit* hits, hc_links* link, bubble_type* bub, MT* M)
{
    double index_time = yak_realtime();
    uint64_t k, i, shif = 64 - idx->uID_bits, beg, end, t_d;
    for (k = 0; k < hits->a.n; ++k) 
    {
        beg = ((hits->a.a[k].s<<1)>>shif);
        end = ((hits->a.a[k].e<<1)>>shif);

        if(beg == end) continue;
        if(IF_HOM(beg, *bub)) continue;
        if(IF_HOM(end, *bub)) continue;

        t_d = (uint64_t)-1;
        push_hc_edge(&(link->a.a[beg]), end, 0, 0, &t_d);
        push_hc_edge(&(link->a.a[end]), beg, 0, 0, &t_d);
    }
    asg_t *copy_sg = copy_read_graph(idx->ug->g);


    update_ug_by_trans(copy_sg, &(idx->t_ch->k_trans));
    all_pair_shortest_path(copy_sg, link, M);
    fill_utg_distance_multi(copy_sg, link, M, bub);
    update_containment_distance(copy_sg, &(idx->t_ch->k_trans), link);
    asg_destroy(copy_sg);

    fprintf(stderr, "[M::%s::%.3f] ==> Hi-C linkages have been counted\n", __func__, yak_realtime()-index_time);
    return;





    index_time = yak_realtime();
    for (k = 0; k < link->enzymes.n; k++)
    {
        link->enzymes.a[k] = 0;
        for (i = 0; i < (uint64_t)asm_opt.hic_enzymes->n; i++)
        {
            link->enzymes.a[k] += get_enzyme_occ(idx->ug->u.a[k].s, idx->ug->u.a[k].len, 
                                                asm_opt.hic_enzymes->a[i], asm_opt.hic_enzymes->l[i]);
        }
    }
    fprintf(stderr, "[M::%s::%.3f] ==> Enzymes have been counted\n", __func__, yak_realtime()-index_time);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x18(%rsp)
movq %rcx, %r13
movq %rdx, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, (%rsp)
callq 0x1365ef
movsd %xmm0, 0x20(%rsp)
movq (%rbx), %rax
testq %rax, %rax
je 0x15a07
movq %rbx, %rdi
pushq $0x40
popq %rbp
movq (%rsp), %rcx
subq 0x18(%rcx), %rbp
pushq $0x8
popq %rbx
xorl %r15d, %r15d
movq %r13, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
movq 0x10(%rdi), %rdx
movq -0x8(%rdx,%rbx), %r14
addq %r14, %r14
movl %ebp, %ecx
shrq %cl, %r14
movq (%rdx,%rbx), %r12
addq %r12, %r12
shrq %cl, %r12
cmpq %r12, %r14
je 0x159f7
movq (%r13), %rdx
movq 0x80(%r13), %rcx
movl (%rdx,%r14,4), %esi
incq %rcx
cmpq %rsi, %rcx
jb 0x159f7
movl (%rdx,%r12,4), %edx
cmpq %rdx, %rcx
jb 0x159f7
orq $-0x1, 0x10(%rsp)
imulq $0x30, %r14, %rdi
movq 0x8(%rsp), %r13
addq 0x10(%r13), %rdi
xorpd %xmm0, %xmm0
movq %r12, %rsi
xorl %edx, %edx
leaq 0x10(%rsp), %rcx
callq 0x1416e0
imulq $0x30, %r12, %rdi
addq 0x10(%r13), %rdi
movq 0x30(%rsp), %r13
xorpd %xmm0, %xmm0
movq %r14, %rsi
xorl %edx, %edx
leaq 0x10(%rsp), %rcx
callq 0x1416e0
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
incq %r15
addq $0x20, %rbx
cmpq %rax, %r15
jb 0x15969
movq (%rsp), %r15
movq (%r15), %rax
movq 0x18(%rax), %rdi
callq 0xc8dad
movq %rax, %r14
movl $0x138, %r12d           # imm = 0x138
movq 0x10(%r15), %rsi
addq %r12, %rsi
movq %rax, %rdi
callq 0x1433a3
movq %r14, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
movq 0x18(%rsp), %rbp
movq %rbp, %rdx
callq 0x141dcb
movq %r14, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x142ce3
addq 0x10(%r15), %r12
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x144248
movq %r14, %rdi
callq 0xa0494
movq 0x27f567(%rip), %rax    # 0x294fe0
movq (%rax), %rbx
callq 0x1365ef
subsd 0x20(%rsp), %xmm0
leaq 0x225ccc(%rip), %rsi    # 0x23b75a
leaq 0x225cf8(%rip), %rdx    # 0x23b78d
movq %rbx, %rdi
movb $0x1, %al
callq 0x22b0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq