// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movq 0x100(%rsp), %rax
movq $0x0, (%rax)
testl %r9d, %r9d
je 0x15f996
movq %r8, %rbx
movq %rdi, %r12
movl %r9d, %r13d
xorl %ebp, %ebp
fldl 0xc5e63(%rip)           # 0x2254c0
fstpt 0x8c(%rsp)
flds 0xcf9ba(%rip)           # 0x22f024
fstpt 0x80(%rsp)
fld1
fchs
fstpt 0x74(%rsp)
fldl 0xcf979(%rip)           # 0x22eff8
fstpt 0x68(%rsp)
xorl %r14d, %r14d
xorl %eax, %eax
movq %r14, %rdi
shlq $0x5, %rdi
cmpq $-0x1, 0x10(%rbx,%rdi)
je 0x15f988
addq %rbx, %rdi
movq (%rdi), %r11
movq 0x18(%rdi), %rsi
movq %rsi, %r9
shrq $0x20, %r9
leaq (%r11,%r11), %r10
movq 0x18(%r12), %r8
movq %r8, %rcx
negq %rcx
shrq %cl, %r10
movq 0x30(%r12), %r15
movq %r15, %rdx
andq %r11, %rdx
movq %rdx, %rcx
subq %r9, %rcx
decq %r9
incq %rcx
testq %r11, %r11
cmovsq %rbp, %r9
cmovnsq %rdx, %rcx
addq %rdx, %r9
testq %r9, %r9
cmovleq %rbp, %r9
testq %rcx, %rcx
cmovleq %rbp, %rcx
cmpl 0xd0(%rsp), %r10d
jne 0x15f988
cmpl 0xd8(%rsp), %ecx
jb 0x15f988
incl %r9d
cmpl 0xe0(%rsp), %r9d
ja 0x15f988
movl $0x40, %ecx
subq %r8, %rcx
movq 0x8(%rdi), %rdx
leaq (%rdx,%rdx), %r8
shrq %cl, %r8
andq %rdx, %r15
movl %esi, %ecx
movq %r15, %rsi
subq %rcx, %rsi
decq %rcx
incq %rsi
testq %rdx, %rdx
cmovsq %rbp, %rcx
cmovnsq %r15, %rsi
addq %r15, %rcx
testq %rcx, %rcx
cmovleq %rbp, %rcx
testq %rsi, %rsi
cmovleq %rbp, %rsi
cmpl 0xe8(%rsp), %r8d
jne 0x15f988
cmpl 0xf0(%rsp), %esi
jb 0x15f988
incl %ecx
cmpl 0xf8(%rsp), %ecx
ja 0x15f988
movq 0x20(%rsp), %rsi
movq %r12, %rdx
leaq 0x64(%rsp), %rcx
callq 0x143e3e
movsd 0xc5acf(%rip), %xmm0    # 0x225270
cmpq $0x0, 0x18(%rsp)
je 0x15f973
fldt 0x8c(%rsp)
cmpq $-0x1, %rax
je 0x15f912
fstp %st(0)
movq 0x18(%rsp), %rcx
cmpq %rax, 0x18(%rcx)
jbe 0x15f81e
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
je 0x15f8c5
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movq %rdx, %rsi
negq %rsi
addq $0x20, %rcx
movb $0x1, %r8b
movl $0x1, %edi
cmpq %rax, -0x18(%rcx)
jbe 0x15f7fe
cmpq %rax, -0x20(%rcx)
jbe 0x15f870
cmpq %rdx, %rdi
setb %r8b
leaq (%rsi,%rdi), %r9
incq %r9
incq %rdi
addq $0x28, %rcx
cmpq $0x1, %r9
jne 0x15f7f2
jmp 0x15f8c5
fldt 0x80(%r12)
movq %rax, 0x58(%rsp)
xorl %ecx, %ecx
testq %rax, %rax
sets %cl
fildll 0x58(%rsp)
leaq 0xcf7aa(%rip), %rax     # 0x22efe8
fadds (%rax,%rcx,4)
fldt 0xa0(%r12)
fdivrp %st, %st(1)
fmulp %st, %st(1)
fldt 0x90(%r12)
faddp %st, %st(1)
fstpl 0x50(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
fldl 0x48(%rsp)
jmp 0x15f912
testb $0x1, %r8b
je 0x15f8c5
movq (%rcx), %rax
movq %rax, %xmm1
movq 0xc59ba(%rip), %xmm2    # 0x225240
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xc59be(%rip), %xmm3    # 0x225250
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addq -0x8(%rcx), %rax
addsd %xmm1, %xmm0
movq %rax, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
jmp 0x15f908
fldt 0x80(%r12)
movq %rax, 0x40(%rsp)
xorl %ecx, %ecx
testq %rax, %rax
sets %cl
fildll 0x40(%rsp)
leaq 0xcf703(%rip), %rax     # 0x22efe8
fadds (%rax,%rcx,4)
fldt 0xa0(%r12)
fdivrp %st, %st(1)
fmulp %st, %st(1)
fldt 0x90(%r12)
faddp %st, %st(1)
fstpl 0x38(%rsp)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
fldl 0x30(%rsp)
fldz
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
faddl 0xcf68e(%rip)           # 0x22efb0
fldt 0x80(%rsp)
fxch %st(1)
fucomi %st(1), %st
fcmovnbe %st(1), %st
fstp %st(1)
faddl 0xcf6b9(%rip)           # 0x22eff0
fld1
fdivp %st, %st(1)
fldt 0x74(%rsp)
faddp %st, %st(1)
fstpt (%rsp)
callq 0x20b0
fmuls 0xcf6d9(%rip)           # 0x22f028
fldt 0x68(%rsp)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fldl 0xcf69f(%rip)           # 0x22f000
fxch %st(1)
fucomi %st(1), %st
fcmovnbe %st(1), %st
fstp %st(1)
fstpl 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movq 0x100(%rsp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl $0x1, %eax
incq %r14
cmpq %r13, %r14
jne 0x15f688
jmp 0x15f998
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq