// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: dedup_sort_ul_ov_t(ul_ov_t*, long)
int64_t dedup_sort_ul_ov_t(ul_ov_t *a, int64_t a_n)
{
	int64_t k, l, z, r, i, qo, to; float rr = 0.9;
	for (k = 1, l = i = 0; k <= a_n; k++) {
		if(k == a_n || a[k].tn != a[l].tn) {///remove the duplicated contained alignments
			for (z = l; z < k; z++) {
				for (r = i-1; r >= 0 && a[r].tn == a[z].tn; r--){
					/**
                	if(a[z].qn == a[r].qn && a[z].qs == a[r].qs && a[z].qe == a[r].qe && 
					   a[z].tn == a[r].tn && a[z].ts == a[r].ts && a[z].te == a[r].te && 
					   a[z].sec == a[r].sec && a[z].el == a[r].el && a[z].rev == a[r].rev) {
						   break;
					}
					**/
					if(a[z].qn == a[r].qn && a[z].tn == a[r].tn && a[z].rev == a[r].rev) {
						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) {
					if(a[z].el) a[r].el = 1;
					continue;
				}
				a[i++] = a[z];
			}
			l = k;
		}
	}
	return i;
}

// Assembly:
testq %rsi, %rsi
jle 0x1a9fdc
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq -0x4(%rdi), %rax
movq %rax, -0x10(%rsp)
movl $0x1, %edx
xorl %r9d, %r9d
movss 0x8bffe(%rip), %xmm0    # 0x235db4
xorl %eax, %eax
movq %rsi, -0x18(%rsp)
movq %rdi, -0x40(%rsp)
cmpq %rsi, %rdx
je 0x1a9ded
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
movl 0xc(%rdi,%rcx), %r8d
leaq (%r9,%r9,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %r9, %rcx
cmpl 0xc(%rdi,%rcx), %r8d
je 0x1a9fc1
cmpq %rdx, %r9
jge 0x1a9fb4
movq %rdx, -0x8(%rsp)
movq %r9, -0x38(%rsp)
leaq (%r9,%r9,8), %rcx
movq %rcx, -0x20(%rsp)
movq %rax, -0x30(%rsp)
testq %rax, %rax
jle 0x1a9f42
movq -0x20(%rsp), %rax
leaq (%rax,%rax,2), %rax
addq -0x38(%rsp), %rax
movq -0x40(%rsp), %rcx
leaq (%rcx,%rax), %r11
movl 0xc(%rcx,%rax), %edx
movq -0x30(%rsp), %rcx
leaq 0x1(%rcx), %r14
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %r10
movq -0x10(%rsp), %rax
addq %rcx, %rax
addq %rax, %r10
movl %edx, -0x24(%rsp)
cmpl %edx, -0xc(%r10)
jne 0x1a9f42
movl (%r11), %eax
cmpl -0x18(%r10), %eax
jne 0x1a9f31
movl 0x18(%r11), %r15d
movl (%r10), %ebp
movl %ebp, %eax
xorl %r15d, %eax
js 0x1a9f31
movl 0x4(%r11), %r13d
movl 0x8(%r11), %r12d
movl -0x14(%r10), %r9d
movl -0x10(%r10), %edx
cmpl %edx, %r12d
movl %edx, %ecx
cmovbl %r12d, %ecx
cmpl %r9d, %r13d
movl %r9d, %eax
cmoval %r13d, %eax
xorps %xmm1, %xmm1
subl %eax, %ecx
ja 0x1a9eaa
xorps %xmm2, %xmm2
jmp 0x1a9eb2
xorps %xmm2, %xmm2
cvtsi2ss %rcx, %xmm2
movl 0x14(%r11), %ecx
movl -0x4(%r10), %eax
cmpl %eax, %ecx
movl %eax, %r8d
cmovbl %ecx, %r8d
movl 0x10(%r11), %esi
movl -0x8(%r10), %ebx
cmpl %ebx, %esi
movl %ebx, %edi
cmoval %esi, %edi
subl %edi, %r8d
jbe 0x1a9edf
xorps %xmm1, %xmm1
cvtsi2ss %r8, %xmm1
subl %r9d, %edx
xorps %xmm3, %xmm3
cvtsi2ss %rdx, %xmm3
mulss %xmm0, %xmm3
ucomiss %xmm3, %xmm2
movl -0x24(%rsp), %edx
jb 0x1a9f31
subl %r13d, %r12d
xorps %xmm3, %xmm3
cvtsi2ss %r12, %xmm3
mulss %xmm0, %xmm3
ucomiss %xmm3, %xmm2
jb 0x1a9f31
subl %ebx, %eax
xorps %xmm2, %xmm2
cvtsi2ss %rax, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm2, %xmm1
jb 0x1a9f31
subl %esi, %ecx
xorps %xmm2, %xmm2
cvtsi2ss %rcx, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm2, %xmm1
jae 0x1a9f93
decq %r14
addq $-0x1c, %r10
cmpq $0x1, %r14
ja 0x1a9e52
movq -0x20(%rsp), %rax
leaq (%rax,%rax,2), %rax
movq -0x38(%rsp), %r9
addq %r9, %rax
movq -0x30(%rsp), %rdx
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
incq %rdx
movq -0x40(%rsp), %rdi
movups (%rdi,%rax), %xmm1
movups 0xc(%rdi,%rax), %xmm2
movups %xmm2, 0xc(%rdi,%rcx)
movups %xmm1, (%rdi,%rcx)
movq %rdx, %rax
incq %r9
movq -0x8(%rsp), %rdx
cmpq %rdx, %r9
jne 0x1a9dfb
jmp 0x1a9fb9
btl $0x1e, %r15d
jae 0x1a9fa3
orl $0x40000000, %ebp       # imm = 0x40000000
movl %ebp, (%r10)
movq -0x40(%rsp), %rdi
movq -0x30(%rsp), %rax
movq -0x38(%rsp), %r9
jmp 0x1a9f80
movq %rdx, %r9
jmp 0x1a9fc1
movq %rdx, %r9
movq -0x18(%rsp), %rsi
leaq 0x1(%rdx), %rcx
cmpq %rsi, %rdx
movq %rcx, %rdx
jne 0x1a9dc2
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq