// File: /workspace/github_cpp_makefile_star2_O3/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, 0x10(%rsp)
movq %rsi, 0x18(%rsp)
movq 0x100(%rsp), %rax
movq $0x0, (%rax)
testl %r9d, %r9d
je 0x16630f
movq %r8, %rbx
movq %rdi, %r12
movl %r9d, %r13d
xorl %ebp, %ebp
xorpd %xmm1, %xmm1
fldl 0xcb5d2(%rip)           # 0x2315c0
fstpt 0x8c(%rsp)
flds 0xd5279(%rip)           # 0x23b274
fstpt 0x80(%rsp)
fld1
fchs
fstpt 0x74(%rsp)
fldl 0xd5238(%rip)           # 0x23b248
fstpt 0x68(%rsp)
xorl %r14d, %r14d
xorl %eax, %eax
movq %r14, %rdi
shlq $0x5, %rdi
cmpq $-0x1, 0x10(%rbx,%rdi)
je 0x166301
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 0x166301
cmpl 0xd8(%rsp), %ecx
jb 0x166301
incl %r9d
cmpl 0xe0(%rsp), %r9d
ja 0x166301
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 0x166301
cmpl 0xf0(%rsp), %esi
jb 0x166301
incl %ecx
cmpl 0xf8(%rsp), %ecx
ja 0x166301
movq 0x18(%rsp), %rsi
movq %r12, %rdx
leaq 0x64(%rsp), %rcx
movsd %xmm1, 0x20(%rsp)
callq 0x14a518
movsd 0x20(%rsp), %xmm1
movsd 0xcb1d2(%rip), %xmm0    # 0x231310
cmpq $0x0, 0x10(%rsp)
je 0x1662ec
fldt 0x8c(%rsp)
cmpq $-0x1, %rax
movq 0x10(%rsp), %rcx
je 0x16627f
fstp %st(0)
cmpq %rax, 0x18(%rcx)
jbe 0x1661d9
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
je 0x166191
movq (%rcx), %rcx
addq $0x20, %rcx
cmpq %rax, -0x18(%rcx)
jbe 0x166188
cmpq %rax, -0x20(%rcx)
jbe 0x166228
addq $0x28, %rcx
decq %rdx
jne 0x166178
fldt 0x80(%r12)
movq %rax, 0x40(%rsp)
xorl %ecx, %ecx
testq %rax, %rax
sets %cl
fildll 0x40(%rsp)
leaq 0xd5087(%rip), %rax     # 0x23b238
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
jmp 0x166275
fldt 0x80(%r12)
movq %rax, 0x58(%rsp)
xorl %ecx, %ecx
testq %rax, %rax
sets %cl
fildll 0x58(%rsp)
leaq 0xd503f(%rip), %rax     # 0x23b238
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 0x16627f
movq (%rcx), %rax
movq %rax, %xmm1
movq 0xcb048(%rip), %xmm2    # 0x231280
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xcb04c(%rip), %xmm3    # 0x231290
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
movsd %xmm0, 0x30(%rsp)
fldl 0x30(%rsp)
fldz
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
faddl 0xd4f31(%rip)           # 0x23b1c0
fldt 0x80(%rsp)
fxch %st(1)
fucomi %st(1), %st
fcmovnbe %st(1), %st
fstp %st(1)
faddl 0xd4f9c(%rip)           # 0x23b240
fld1
fdivp %st, %st(1)
fldt 0x74(%rsp)
faddp %st, %st(1)
fstpt (%rsp)
callq 0x20b0
fmuls 0xd4fbc(%rip)           # 0x23b278
fldt 0x68(%rsp)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fldl 0xd4f82(%rip)           # 0x23b250
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
movsd (%rax), %xmm1
addsd %xmm0, %xmm1
movq 0x100(%rsp), %rax
movsd %xmm1, (%rax)
movl $0x1, %eax
incq %r14
cmpq %r13, %r14
jne 0x166019
jmp 0x166311
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq