// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Hash_Table.cpp
// Function: filter_non_ovlp_chains(overlap_region*, long, long*)
int64_t filter_non_ovlp_chains(overlap_region *a, int64_t a_n, int64_t *n_v)
{
    int64_t k, i, n_mchain, omx, omy, opx, opy, ovx, ovy, os, oe; overlap_region *m, *p, t;
    for (k = n_mchain = (*n_v) = 0; k < a_n; k++) {
		m = &(a[k]); 
        omx = m->x_pos_e + 1 - m->x_pos_s;
        omy = m->y_pos_e + 1 - m->y_pos_s;
		for (i = 0; i < n_mchain; i++) {
			p = &(a[i]);
            opx = p->x_pos_e + 1 - p->x_pos_s;
            opy = p->y_pos_e + 1 - p->y_pos_s;

            os = ((m->x_pos_s>=p->x_pos_s)? m->x_pos_s:p->x_pos_s);
            oe = ((m->x_pos_e<=p->x_pos_e)? m->x_pos_e:p->x_pos_e) + 1;
			ovx = oe>os?oe-os:0;
            if((ovx > omx*0.1) || (ovx > opx*0.1)) break;

            os = ((m->y_pos_s>=p->y_pos_s)? m->y_pos_s:p->y_pos_s);
            oe = ((m->y_pos_e<=p->y_pos_e)? m->y_pos_e:p->y_pos_e) + 1;
			ovy = oe>os?oe-os:0;
			if((ovy > omy*0.1) || (ovy > opy*0.1)) break;
		}
		if(i < n_mchain) continue;

        if (n_mchain != k) {
            t = a[k]; a[k] = a[n_mchain]; a[n_mchain] = t;
        }
        (*n_v) += a[n_mchain].align_length;
		n_mchain++;
	}
	return n_mchain;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdx, 0x8(%rsp)
movq $0x0, (%rdx)
movq %rsi, 0x18(%rsp)
testq %rsi, %rsi
jle 0x40b5f
movq %rdi, %r15
leaq 0x18(%rdi), %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movsd 0x1f0255(%rip), %xmm4   # 0x230c10
xorl %ebx, %ebx
xorl %r12d, %r12d
imulq $0xa8, %rbx, %rbp
testq %r12, %r12
jle 0x40ade
movl 0x4(%r15,%rbp), %ecx
movl 0x8(%r15,%rbp), %edx
movl 0x18(%r15,%rbp), %esi
movl 0x14(%r15,%rbp), %edi
movl %esi, %r8d
subl %edi, %r8d
incl %r8d
movl %edx, %r9d
subl %ecx, %r9d
incl %r9d
xorps %xmm0, %xmm0
cvtsi2sd %r9, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r8, %xmm1
mulsd %xmm4, %xmm0
mulsd %xmm4, %xmm1
movq 0x10(%rsp), %r8
movq %r12, %r9
movl -0x14(%r8), %r10d
cmpl %r10d, %ecx
movl %r10d, %r13d
cmoval %ecx, %r13d
movl -0x10(%r8), %r14d
cmpl %r14d, %edx
movl %r14d, %r11d
cmovbl %edx, %r11d
incl %r11d
cmpl %r13d, %r11d
ja 0x40a40
xorpd %xmm2, %xmm2
jmp 0x40a4b
subq %r13, %r11
xorps %xmm2, %xmm2
cvtsi2sd %r11, %xmm2
ucomisd %xmm0, %xmm2
ja 0x40b4f
subl %r10d, %r14d
incl %r14d
xorps %xmm3, %xmm3
cvtsi2sd %r14, %xmm3
mulsd %xmm4, %xmm3
ucomisd %xmm3, %xmm2
ja 0x40b4f
movl -0x4(%r8), %r10d
cmpl %r10d, %edi
movl %r10d, %r13d
cmoval %edi, %r13d
movl (%r8), %r11d
cmpl %r11d, %esi
movl %r11d, %r14d
cmovbl %esi, %r14d
incl %r14d
cmpl %r13d, %r14d
ja 0x40a9a
xorpd %xmm2, %xmm2
jmp 0x40aa5
subq %r13, %r14
xorps %xmm2, %xmm2
cvtsi2sd %r14, %xmm2
ucomisd %xmm1, %xmm2
ja 0x40b4f
subl %r10d, %r11d
incl %r11d
movl %r11d, %r10d
xorps %xmm3, %xmm3
cvtsi2sd %r10, %xmm3
mulsd %xmm4, %xmm3
ucomisd %xmm3, %xmm2
ja 0x40b4f
addq $0xa8, %r8
decq %r9
jne 0x40a16
cmpq %rbx, %r12
je 0x40b35
addq %r15, %rbp
movl $0xa8, %edx
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2160
imulq $0xa8, %r12, %r13
addq %r15, %r13
movl $0xa8, %edx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2160
movl $0xa8, %edx
movq %r13, %rdi
movq %r14, %rsi
callq 0x2160
movsd 0x1f00e3(%rip), %xmm4   # 0x230c10
movq 0x8(%rsp), %rax
movq (%rax), %rax
imulq $0xa8, %r12, %rcx
movl 0x28(%r15,%rcx), %ecx
addq %rcx, %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
incq %r12
incq %rbx
cmpq 0x18(%rsp), %rbx
jne 0x409c0
jmp 0x40b62
xorl %r12d, %r12d
movq %r12, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq