// File: chhylp123[P]hifiasm/Correct.cpp
// Function: cal_lindel_dd(ul_ov_t*, ul_ov_t*, double, unsigned long, double, unsigned long)
double cal_lindel_dd(ul_ov_t *a, ul_ov_t *b, double ol_r, uint64_t ol_w, double err_dif, uint64_t c_sz)
{
    if(a->tn == b->tn) return -1;
    uint64_t os, oe, ol; int64_t ea, eb, ed;
    os = MAX(a->qs, b->qs); oe = MIN(a->qe, b->qe);
    if(oe <= os + ol_w) return -1;
    ol = oe - os;
    // if((ol < ((a->qe - a->qs)*ol_r)) || (ol < ((b->qe - b->qs)*ol_r))) return -1;
    if((ol < ((a->qe - a->qs)*ol_r)) && (ol < ((b->qe - b->qs)*ol_r))) return -1;

    ea = a->qn; eb = b->qn;
    ed = ((ea >= eb)?(ea - eb):(eb - ea));
    if((ed > (ea * err_dif)) || (ed > (eb * err_dif))) return -1;

    double sc;
    sc = ((double)(ea - ed + eb - ed))/((double)(ea + eb));
    sc += ((double)(ol + ol)) / ((double)(a->qe - a->qs + b->qe - b->qs));
    return sc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movsd %xmm1, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x766a0
movsd 0x30bbe2(%rip), %xmm0   # 0x382278
movsd %xmm0, -0x8(%rbp)
jmp 0x768db
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0x766bc
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x74(%rbp)
jmp 0x766c6
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0x766eb
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x78(%rbp)
jmp 0x766f5
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
addq -0x28(%rbp), %rcx
cmpq %rcx, %rax
ja 0x76721
movsd 0x30bb61(%rip), %xmm0   # 0x382278
movsd %xmm0, -0x8(%rbp)
jmp 0x768db
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
movaps 0x30b8d9(%rip), %xmm0   # 0x382010
movq -0x50(%rbp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x30b8d8(%rip), %xmm0   # 0x382020
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm0
mulsd -0x20(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x767c8
movaps 0x30b896(%rip), %xmm0   # 0x382010
movq -0x50(%rbp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x30b895(%rip), %xmm0   # 0x382020
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm0
mulsd -0x20(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x767c8
movsd 0x30baba(%rip), %xmm0   # 0x382278
movsd %xmm0, -0x8(%rbp)
jmp 0x768db
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jl 0x767f4
movq -0x58(%rbp), %rax
subq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x76800
movq -0x60(%rbp), %rax
subq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x68(%rbp)
cvtsi2sdq -0x68(%rbp), %xmm0
cvtsi2sdq -0x58(%rbp), %xmm1
mulsd -0x30(%rbp), %xmm1
ucomisd %xmm1, %xmm0
ja 0x76836
cvtsi2sdq -0x68(%rbp), %xmm0
cvtsi2sdq -0x60(%rbp), %xmm1
mulsd -0x30(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x76848
movsd 0x30ba3a(%rip), %xmm0   # 0x382278
movsd %xmm0, -0x8(%rbp)
jmp 0x768db
movq -0x58(%rbp), %rax
movq -0x68(%rbp), %rsi
movq %rax, %rdx
subq %rsi, %rdx
movq -0x60(%rbp), %rcx
addq %rcx, %rdx
subq %rsi, %rdx
cvtsi2sd %rdx, %xmm0
addq %rcx, %rax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x50(%rbp), %rax
addq %rax, %rax
movq %rax, %xmm0
movaps 0x30b787(%rip), %xmm1   # 0x382010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x30b78b(%rip), %xmm1   # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movl 0x8(%rax), %eax
subl %ecx, %eax
movq -0x18(%rbp), %rdx
movl 0x4(%rdx), %ecx
movl 0x8(%rdx), %edx
addl %edx, %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
popq %rbp
retq
nopw %cs:(%rax,%rax)