// File: chhylp123[P]hifiasm/hic.cpp
// Function: get_trans_interval_weight(ha_ug_index*, hc_links*, bubble_type*, trans_idx*, pe_hit*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, double*)
inline uint32_t get_trans_interval_weight(ha_ug_index* idx, hc_links* link, bubble_type* bub, 
trans_idx* dis, pe_hit *hit, uint32_t hit_n, uint32_t qn, uint32_t qs, uint32_t qe, uint32_t tn, 
uint32_t ts, uint32_t te, double *w_a) 
{
    uint32_t i, s_uid, s_beg, s_end, e_uid, e_beg, e_end, found, is_cc;
    uint64_t t_d;
    double weight;
    (*w_a) = 0; found = 0;
    for (i = 0; i < hit_n; i++)///all hits already have the same qn and tn
    {
        if(is_hom_hit(hit[i])) continue;
        interpr_hit(idx, hit[i].s, hit[i].len>>32, &s_uid, &s_beg, &s_end);
        if(s_uid != qn) continue;
        if(!(qs <= s_beg && qe >= s_end)) continue;

        interpr_hit(idx, hit[i].e, (uint32_t)hit[i].len, &e_uid, &e_beg, &e_end);
        if(e_uid != tn) continue;
        if(!(ts <= e_beg && te >= e_end)) continue;

        t_d = get_hic_distance(&hit[i], link, idx, &is_cc);
        // if(t_d == (uint64_t)-1) continue;
        // if(t_d == (uint64_t)-1 && is_cc == 0) continue;
        // if(t_d == (uint64_t)-1 && !dis) continue;

        weight = 1;
        if(dis) weight = get_trans_weight_advance(idx, t_d, dis);

        (*w_a) += weight;
        found = 1;
    }

    return found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x40(%rbp), %rax
movl 0x38(%rbp), %eax
movl 0x30(%rbp), %eax
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq 0x40(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x214f2f
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $-0x1, 0x10(%rax)
jne 0x214e05
jmp 0x214f21
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, %edx
leaq -0x34(%rbp), %rcx
leaq -0x38(%rbp), %r8
leaq -0x3c(%rbp), %r9
callq 0x201880
movl -0x34(%rbp), %eax
cmpl 0x10(%rbp), %eax
je 0x214e50
jmp 0x214f21
movl 0x18(%rbp), %eax
cmpl -0x38(%rbp), %eax
ja 0x214e60
movl 0x20(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x214e65
jmp 0x214f21
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, %edx
leaq -0x40(%rbp), %rcx
leaq -0x44(%rbp), %r8
leaq -0x48(%rbp), %r9
callq 0x201880
movl -0x40(%rbp), %eax
cmpl 0x28(%rbp), %eax
je 0x214eaa
jmp 0x214f21
movl 0x30(%rbp), %eax
cmpl -0x44(%rbp), %eax
ja 0x214eba
movl 0x38(%rbp), %eax
cmpl -0x48(%rbp), %eax
jae 0x214ebc
jmp 0x214f21
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %eax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x1db730
movq %rax, -0x58(%rbp)
movsd 0x16d119(%rip), %xmm0   # 0x382000
movsd %xmm0, -0x60(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x214f09
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x2148a0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
movq 0x40(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl $0x1, -0x4c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x214ddf
movl -0x4c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)