// File: 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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x252ce
movq -0x8(%rbp), %rax
imulq $0xa8, -0x20(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movq -0x78(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x78(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movq -0x78(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x25212
movq -0x8(%rbp), %rax
imulq $0xa8, -0x28(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movq -0x80(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x80(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
movq -0x80(%rbp), %rcx
subl 0x14(%rcx), %eax
movl %eax, %eax
movq %rax, -0x50(%rbp)
movq -0x78(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x80(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0x25057
movq -0x78(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x12c(%rbp)
jmp 0x25064
movq -0x80(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x12c(%rbp)
movl -0x12c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x68(%rbp)
movq -0x78(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x80(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0x2508f
movq -0x78(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x130(%rbp)
jmp 0x2509c
movq -0x80(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x130(%rbp)
movl -0x130(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jle 0x250c6
movq -0x70(%rbp), %rax
subq -0x68(%rbp), %rax
movq %rax, -0x138(%rbp)
jmp 0x250d1
xorl %eax, %eax
movq %rax, -0x138(%rbp)
jmp 0x250d1
movq -0x138(%rbp), %rax
movq %rax, -0x58(%rbp)
cvtsi2sdq -0x58(%rbp), %xmm0
cvtsi2sdq -0x38(%rbp), %xmm1
movsd 0x359f28(%rip), %xmm2   # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
ja 0x25118
cvtsi2sdq -0x58(%rbp), %xmm0
cvtsi2sdq -0x48(%rbp), %xmm1
movsd 0x359f0a(%rip), %xmm2   # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2511d
jmp 0x25212
movq -0x78(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x80(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jb 0x2513c
movq -0x78(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x13c(%rbp)
jmp 0x25149
movq -0x80(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x68(%rbp)
movq -0x78(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x80(%rbp), %rcx
cmpl 0x18(%rcx), %eax
ja 0x25174
movq -0x78(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x140(%rbp)
jmp 0x25181
movq -0x80(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x140(%rbp)
movl -0x140(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jle 0x251ab
movq -0x70(%rbp), %rax
subq -0x68(%rbp), %rax
movq %rax, -0x148(%rbp)
jmp 0x251b6
xorl %eax, %eax
movq %rax, -0x148(%rbp)
jmp 0x251b6
movq -0x148(%rbp), %rax
movq %rax, -0x60(%rbp)
cvtsi2sdq -0x60(%rbp), %xmm0
cvtsi2sdq -0x40(%rbp), %xmm1
movsd 0x359e43(%rip), %xmm2   # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
ja 0x251fd
cvtsi2sdq -0x60(%rbp), %xmm0
cvtsi2sdq -0x50(%rbp), %xmm1
movsd 0x359e25(%rip), %xmm2   # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x251ff
jmp 0x25212
jmp 0x25201
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x24fe9
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x25221
jmp 0x252bd
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x25293
movq -0x8(%rbp), %rsi
imulq $0xa8, -0x20(%rbp), %rax
addq %rax, %rsi
leaq -0x128(%rbp), %rdi
movl $0xa8, %edx
callq 0x2180
movq -0x8(%rbp), %rsi
imulq $0xa8, -0x30(%rbp), %rax
addq %rax, %rsi
movq -0x8(%rbp), %rdi
imulq $0xa8, -0x20(%rbp), %rax
addq %rax, %rdi
movl $0xa8, %edx
callq 0x2180
movq -0x8(%rbp), %rdi
imulq $0xa8, -0x30(%rbp), %rax
addq %rax, %rdi
leaq -0x128(%rbp), %rsi
movl $0xa8, %edx
callq 0x2180
movq -0x8(%rbp), %rax
imulq $0xa8, -0x30(%rbp), %rcx
addq %rcx, %rax
movl 0x28(%rax), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x24f92
movq -0x30(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopl (%rax,%rax)