// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/rcut.cpp
// Function: clean_ovlp_by_mc(mc_g_t*, hap_overlaps_list*)
void clean_ovlp_by_mc(mc_g_t *mg, hap_overlaps_list* ha)
{
	uint32_t v, i, k, qn, tn, types[4];
    types[X2Y] = Y2X; types[Y2X] = X2Y; types[XCY] = YCX; types[YCX] = XCY;
	int index;
	hap_overlaps *x = NULL, *y = NULL;
	for (i = 0; i < mg->e->n_seq; ++i) 
	{
		filter_ovlp_by_mc(mg->ug, mg->rg, i, ha, mg->e, mg->s.a);
	}

	for (v = 0; v < ha->num; v++)
	{
		for (i = 0; i < ha->x[v].a.n; i++)
		{
			qn = ha->x[v].a.a[i].xUid;
			tn = ha->x[v].a.a[i].yUid;
			x = &(ha->x[v].a.a[i]);
			if(x->status != FLIP) continue;
			index = get_specific_hap_overlap(&(ha->x[tn]), tn, qn);
			if(index != -1)
			{
				y = &(ha->x[tn].a.a[index]);
				set_reverse_hap_overlap(y, x, types);
				y->status = FLIP;
			}
			if(index == -1) fprintf(stderr, "ERROR\n");
		}
	}

	for (v = 0; v < ha->num; v++)
    {
        for (i = k = 0; i < ha->x[v].a.n; i++)
        {
            if(ha->x[v].a.a[i].status != FLIP) continue;

            ha->x[v].a.a[k] = ha->x[v].a.a[i];
            k++;
        }
        ha->x[v].a.n = k;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movaps 0xca0b8(%rip), %xmm0    # 0x239690
movaps %xmm0, 0x10(%rsp)
movq 0x28(%rdi), %r8
cmpl $0x0, 0x38(%r8)
je 0x16f607
movq %rdi, %r14
xorl %ebp, %ebp
movq 0x10(%r14), %r9
movl %ebp, %edx
movq %rbx, %rcx
callq 0x16f498
incl %ebp
movq 0x28(%r14), %r8
cmpl 0x38(%r8), %ebp
jb 0x16f5ed
movl 0x8(%rbx), %ecx
testl %ecx, %ecx
je 0x16f746
movq (%rbx), %rax
xorl %esi, %esi
leaq (%rsi,%rsi,2), %r13
cmpq $0x0, (%rax,%r13,8)
je 0x16f6a0
movq %rsi, 0x8(%rsp)
movl $0x1, %ebp
xorl %ecx, %ecx
movq 0x10(%rax,%r13,8), %r15
shlq $0x6, %rcx
cmpb $0x4, 0x2(%r15,%rcx)
jne 0x16f682
addq %rcx, %r15
movl 0x24(%r15), %edx
movl 0x28(%r15), %esi
leaq (%rsi,%rsi,2), %r14
leaq (%rax,%r14,8), %rdi
callq 0x1111f4
cmpl $-0x1, %eax
je 0x16f691
movq (%rbx), %rcx
movq 0x10(%rcx,%r14,8), %r14
movslq %eax, %r12
shlq $0x6, %r12
leaq (%r14,%r12), %rdi
movq %r15, %rsi
leaq 0x10(%rsp), %rdx
callq 0x11122f
movb $0x4, 0x2(%r14,%r12)
movl %ebp, %ecx
movq (%rbx), %rax
incl %ebp
cmpq %rcx, (%rax,%r13,8)
ja 0x16f62e
jmp 0x16f698
callq 0x1f5a5
jmp 0x16f682
movl 0x8(%rbx), %ecx
movq 0x8(%rsp), %rsi
incq %rsi
movl %ecx, %edx
cmpq %rdx, %rsi
jb 0x16f617
testl %ecx, %ecx
je 0x16f746
movq (%rbx), %rdx
xorl %eax, %eax
leaq (%rax,%rax,2), %rsi
cmpq $0x0, (%rdx,%rsi,8)
je 0x16f72f
xorl %r8d, %r8d
movl $0x1, %ecx
xorl %edi, %edi
movq 0x10(%rdx,%rsi,8), %r9
shlq $0x6, %r8
cmpb $0x4, 0x2(%r9,%r8)
jne 0x16f719
addq %r9, %r8
movl %edi, %edx
shlq $0x6, %rdx
movups (%r8), %xmm0
movups 0x10(%r8), %xmm1
movups 0x20(%r8), %xmm2
movups 0x30(%r8), %xmm3
movups %xmm3, 0x30(%r9,%rdx)
movups %xmm2, 0x20(%r9,%rdx)
movups %xmm1, 0x10(%r9,%rdx)
movups %xmm0, (%r9,%rdx)
incl %edi
movq (%rbx), %rdx
movl %ecx, %r8d
incl %ecx
cmpq %r8, (%rdx,%rsi,8)
ja 0x16f6d0
leaq (%rdx,%rsi,8), %rsi
movl 0x8(%rbx), %ecx
movl %edi, %edi
jmp 0x16f735
leaq (%rdx,%rsi,8), %rsi
xorl %edi, %edi
movq %rdi, (%rsi)
incq %rax
movl %ecx, %esi
cmpq %rsi, %rax
jb 0x16f6bb
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq