// File: chhylp123[P]hifiasm/Correct.cpp
// Function: ovlp_win_check(overlap_region*, unsigned int, unsigned int, long, double, long)
inline uint32_t ovlp_win_check(overlap_region *z, uint32_t id0, uint32_t id1, int64_t max_lgap, double small_bw_rate, int64_t min_small_bw)
{
    if(id0 == (uint32_t)-1 || id1 == (uint32_t)-1) return 1;
    int64_t qs0, qe0, ts0, te0, qs1, qe1, ts1, te1, err, dd, dm, dq, dr;
    if(!get_win_aln(z, id0, &ts0, &te0, &err)) return 1; 
    qs0 = z->w_list.a[id0].x_start; qe0 = z->w_list.a[id0].x_end+1;
    if(!get_win_aln(z, id1, &ts1, &te1, &err)) return 1; 
    qs1 = z->w_list.a[id1].x_start; qe1 = z->w_list.a[id1].x_end+1;

    if(qs1 < qs0 || qe1 < qe0) return 0; 
    if(ts1 < ts0 || te1 < te0) return 0; 
    dq = qe1 - qs0; dr = te1 - ts0; dd = dq>=dr? ((dq)-(dr)): ((dr)-(dq));
    if((ts1 < te0) && (qe0 == qs1)) {//has overlap in y
        dm = dq>=dr?dr:dq;
        if((dd > (dm*small_bw_rate)) && (dd > min_small_bw)) return 0;
    } else {
        if(dd > max_lgap) return 0;
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movq %r8, -0x30(%rbp)
cmpl $-0x1, -0x14(%rbp)
je 0xc1bbe
cmpl $-0x1, -0x18(%rbp)
jne 0xc1bca
movl $0x1, -0x4(%rbp)
jmp 0xc1dd0
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0x78(%rbp), %r8
callq 0xc1de0
cmpq $0x0, %rax
jne 0xc1bf6
movl $0x1, -0x4(%rbp)
jmp 0xc1dd0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl -0x14(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl -0x14(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %esi
leaq -0x68(%rbp), %rdx
leaq -0x70(%rbp), %rcx
leaq -0x78(%rbp), %r8
callq 0xc1de0
cmpq $0x0, %rax
jne 0xc1c59
movl $0x1, -0x4(%rbp)
jmp 0xc1dd0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl -0x18(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl -0x18(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x38(%rbp), %rax
jl 0xc1ca4
movq -0x60(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0xc1cb0
movl $0x0, -0x4(%rbp)
jmp 0xc1dd0
movq -0x68(%rbp), %rax
cmpq -0x48(%rbp), %rax
jl 0xc1cc4
movq -0x70(%rbp), %rax
cmpq -0x50(%rbp), %rax
jge 0xc1cd0
movl $0x0, -0x4(%rbp)
jmp 0xc1dd0
movq -0x60(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x70(%rbp), %rax
subq -0x48(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x98(%rbp), %rax
jl 0xc1d15
movq -0x90(%rbp), %rax
subq -0x98(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0xc1d2a
movq -0x98(%rbp), %rax
subq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x50(%rbp), %rax
jge 0xc1db4
movq -0x40(%rbp), %rax
cmpq -0x58(%rbp), %rax
jne 0xc1db4
movq -0x90(%rbp), %rax
cmpq -0x98(%rbp), %rax
jl 0xc1d69
movq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0xc1d77
movq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x88(%rbp)
cvtsi2sdq -0x80(%rbp), %xmm0
cvtsi2sdq -0x88(%rbp), %xmm1
mulsd -0x28(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xc1db2
movq -0x80(%rbp), %rax
cmpq -0x30(%rbp), %rax
jle 0xc1db2
movl $0x0, -0x4(%rbp)
jmp 0xc1dd0
jmp 0xc1dc9
movq -0x80(%rbp), %rax
cmpq -0x20(%rbp), %rax
jle 0xc1dc7
movl $0x0, -0x4(%rbp)
jmp 0xc1dd0
jmp 0xc1dc9
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)