// File: /workspace/github_cpp_makefile_star2_O1/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, 0x10(%rsp)
movq $0x0, (%rdx)
testq %rsi, %rsi
jle 0x41375
movq %rsi, %r14
movq %rdi, %r15
leaq 0x18(%rdi), %rax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movsd 0x1e39f3(%rip), %xmm4   # 0x224bd0
xorl %r12d, %r12d
movq %rsi, 0x8(%rsp)
imulq $0xa8, %rbx, %rbp
testq %r12, %r12
jle 0x412fc
movl 0x4(%r15,%rbp), %eax
movl 0x8(%r15,%rbp), %ecx
movl 0x18(%r15,%rbp), %edx
movl 0x14(%r15,%rbp), %esi
movl %edx, %edi
subl %esi, %edi
incl %edi
movl %ecx, %r8d
subl %eax, %r8d
incl %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %rdi, %xmm1
mulsd %xmm4, %xmm0
mulsd %xmm4, %xmm1
movq 0x18(%rsp), %rdi
movq %r12, %r8
movl -0x14(%rdi), %r9d
cmpl %r9d, %eax
movl %r9d, %r11d
cmoval %eax, %r11d
movl -0x10(%rdi), %r10d
cmpl %r10d, %ecx
movl %r10d, %r13d
cmovbl %ecx, %r13d
incl %r13d
cmpl %r11d, %r13d
ja 0x41262
xorpd %xmm2, %xmm2
jmp 0x4126d
subq %r11, %r13
xorps %xmm2, %xmm2
cvtsi2sd %r13, %xmm2
ucomisd %xmm0, %xmm2
ja 0x41367
subl %r9d, %r10d
incl %r10d
xorps %xmm3, %xmm3
cvtsi2sd %r10, %xmm3
mulsd %xmm4, %xmm3
ucomisd %xmm3, %xmm2
ja 0x41367
movl -0x4(%rdi), %r9d
cmpl %r9d, %esi
movl %r9d, %r11d
cmoval %esi, %r11d
movl (%rdi), %r10d
cmpl %r10d, %edx
movl %r10d, %r13d
cmovbl %edx, %r13d
incl %r13d
cmpl %r11d, %r13d
ja 0x412bc
xorpd %xmm2, %xmm2
jmp 0x412c7
subq %r11, %r13
xorps %xmm2, %xmm2
cvtsi2sd %r13, %xmm2
ucomisd %xmm1, %xmm2
ja 0x41367
subl %r9d, %r10d
incl %r10d
movl %r10d, %r9d
xorps %xmm3, %xmm3
cvtsi2sd %r9, %xmm3
mulsd %xmm4, %xmm3
ucomisd %xmm3, %xmm2
ja 0x41367
addq $0xa8, %rdi
decq %r8
jne 0x41238
cmpq %rbx, %r12
je 0x41350
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
movq 0x8(%rsp), %r14
callq 0x2160
movsd 0x1e3880(%rip), %xmm4   # 0x224bd0
imulq $0xa8, %r12, %rax
movl 0x28(%r15,%rax), %eax
movq 0x10(%rsp), %rcx
addq %rax, (%rcx)
incq %r12
incq %rbx
cmpq %r14, %rbx
jne 0x411e5
jmp 0x41378
xorl %r12d, %r12d
movq %r12, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq