// File: chhylp123[P]hifiasm/Correct.cpp
// Function: dedup_ul_ov_t(kv_ul_ov_t*)
void dedup_ul_ov_t(kv_ul_ov_t *in)
{
    ul_ov_t *a = in->a; int64_t k, l, m, z, r, a_n = in->n; uint64_t qo, to; double rr = 0.95;
    for (k = 0; k < a_n; k++) a[k].tn = ((uint32_t)(a[k].tn<<1))|((uint32_t)(a[k].rev));
    radix_sort_ul_ov_srt_tn1(a, a + a_n);
    for (k = 1, l = m = 0; k <= a_n; k++) {
        if(k == a_n || a[k].tn != a[l].tn) {
            for (z = l; z < k; z++) {
                for (r=m-1; (r>=0) && (a[r].tn==(a[z].tn>>1)) && (a[r].rev==a[z].rev); r--) {
                    qo = ((MIN(a[z].qe, a[r].qe) > MAX(a[z].qs, a[r].qs))? 
															MIN(a[z].qe, a[r].qe) - MAX(a[z].qs, a[r].qs):0);
                    to = ((MIN(a[z].te, a[r].te) > MAX(a[z].ts, a[r].ts))?
                                                        MIN(a[z].te, a[r].te) - MAX(a[z].ts, a[r].ts):0);
                    if(qo >= ((a[r].qe - a[r].qs)*rr) && qo >= ((a[z].qe - a[z].qs)*rr) && 
						   to >= ((a[r].te - a[r].ts)*rr) && to >= ((a[z].te - a[z].ts)*rr)) {
                            break;
                    }
                }
                if(r >= 0 && (a[r].tn==(a[z].tn>>1)) && (a[r].rev==a[z].rev)) {
                    if(a[z].sec < a[r].sec) {
                        a[r] = a[z]; a[r].tn >>= 1; 
                    }
                    continue;
                }
                a[m] = a[z]; a[m].tn >>= 1; m++;
            }
            l = k;
        }
    }
    // fprintf(stderr, "[M::%s::] in->n0::%ld, in->n::%ld\n", __func__, (int64_t)in->n, m);
    in->n = m;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movsd 0x2e9852(%rip), %xmm0   # 0x382220
movsd %xmm0, -0x58(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x98a27
movq -0x10(%rbp), %rax
imulq $0x1c, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
shll %ecx
movq -0x10(%rbp), %rax
imulq $0x1c, -0x18(%rbp), %rdx
addq %rdx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
orl %eax, %ecx
movq -0x10(%rbp), %rax
imulq $0x1c, -0x18(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x989db
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
imulq $0x1c, -0x40(%rbp), %rax
addq %rax, %rsi
callq 0x30c90
movq $0x1, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x40(%rbp), %rax
jg 0x990a6
movq -0x18(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x98a90
movq -0x10(%rbp), %rax
imulq $0x1c, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x20(%rbp), %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
je 0x99093
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x9908b
movq -0x28(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x38(%rbp)
movb %al, -0x59(%rbp)
jl 0x98b13
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rdx
addq %rdx, %rax
movl 0xc(%rax), %edx
shrl %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x59(%rbp)
jne 0x98b13
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x98b1f
jmp 0x98f54
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
ja 0x98b53
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x60(%rbp)
jmp 0x98b65
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jb 0x98b9f
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x68(%rbp)
jmp 0x98bb1
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %eax
movl -0x68(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x98c5e
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
ja 0x98bf3
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0x98c05
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jb 0x98c3f
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x74(%rbp)
jmp 0x98c51
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x74(%rbp)
movl -0x70(%rbp), %eax
movl -0x74(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x78(%rbp)
jmp 0x98c65
xorl %eax, %eax
movl %eax, -0x78(%rbp)
jmp 0x98c65
movl -0x78(%rbp), %eax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
ja 0x98ca2
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x7c(%rbp)
jmp 0x98cb4
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x80(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
jb 0x98cf1
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x84(%rbp)
jmp 0x98d06
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x84(%rbp)
movl -0x80(%rbp), %eax
movl -0x84(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x98dd1
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x14(%rcx), %eax
ja 0x98d4e
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x88(%rbp)
jmp 0x98d63
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x88(%rbp)
movl -0x88(%rbp), %eax
movl %eax, -0x8c(%rbp)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
jb 0x98da6
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x90(%rbp)
jmp 0x98dbb
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x90(%rbp)
movl -0x8c(%rbp), %eax
movl -0x90(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x94(%rbp)
jmp 0x98ddb
xorl %eax, %eax
movl %eax, -0x94(%rbp)
jmp 0x98ddb
movl -0x94(%rbp), %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movaps 0x2e9222(%rip), %xmm1   # 0x382010
movq -0x48(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2e9221(%rip), %xmm1   # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0x4(%rax,%rdx), %ecx
movl 0x8(%rax,%rdx), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
mulsd -0x58(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x98f41
movaps 0x2e91ca(%rip), %xmm1   # 0x382010
movq -0x48(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2e91c9(%rip), %xmm1   # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0x4(%rax,%rdx), %ecx
movl 0x8(%rax,%rdx), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
mulsd -0x58(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x98f41
movaps 0x2e9172(%rip), %xmm1   # 0x382010
movq -0x50(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2e9171(%rip), %xmm1   # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0x10(%rax,%rdx), %ecx
movl 0x14(%rax,%rdx), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
mulsd -0x58(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x98f41
movaps 0x2e911e(%rip), %xmm1   # 0x382010
movq -0x50(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2e911d(%rip), %xmm1   # 0x382020
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0x10(%rax,%rdx), %ecx
movl 0x14(%rax,%rdx), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
mulsd -0x58(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x98f41
jmp 0x98f54
jmp 0x98f43
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x98ab2
cmpq $0x0, -0x38(%rbp)
jl 0x99026
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
shrl %ecx
cmpl %ecx, %eax
jne 0x99026
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x30(%rbp), %rdx
addq %rdx, %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
cmpl %ecx, %eax
jne 0x99026
movq -0x10(%rbp), %rax
imulq $0x1c, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rcx
movl 0x18(%rcx), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
cmpl %ecx, %eax
jge 0x99024
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x30(%rbp), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movl 0x18(%rcx), %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
shrl %ecx
movl %ecx, 0xc(%rax)
jmp 0x9907a
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x30(%rbp), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
imulq $0x1c, -0x28(%rbp), %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movl 0x18(%rcx), %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
imulq $0x1c, -0x28(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
shrl %ecx
movl %ecx, 0xc(%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x98a98
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x99095
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x98a54
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)