// File: /workspace/github_cpp_makefile_star2_O1/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 0xc48e4(%rip), %xmm0    # 0x22d480
movaps %xmm0, 0x10(%rsp)
movq 0x28(%rdi), %r8
cmpl $0x0, 0x38(%r8)
je 0x168bcb
movq %rdi, %r14
xorl %ebp, %ebp
movq 0x10(%r14), %r9
movl %ebp, %edx
movq %rbx, %rcx
callq 0x168a1c
incl %ebp
movq 0x28(%r14), %r8
cmpl 0x38(%r8), %ebp
jb 0x168bb1
cmpl $0x0, 0x8(%rbx)
je 0x168c6f
xorl %ecx, %ecx
movq (%rbx), %rax
movq %rcx, 0x8(%rsp)
leaq (%rcx,%rcx,2), %r13
cmpq $0x0, (%rax,%r13,8)
je 0x168c5b
movl $0x1, %ebp
xorl %ecx, %ecx
movq 0x10(%rax,%r13,8), %r15
shlq $0x6, %rcx
cmpb $0x4, 0x2(%r15,%rcx)
jne 0x168c45
addq %rcx, %r15
movl 0x24(%r15), %edx
movl 0x28(%r15), %esi
leaq (%rsi,%rsi,2), %r14
leaq (%rax,%r14,8), %rdi
callq 0x10c0b9
cmpl $-0x1, %eax
je 0x168c54
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 0x10c0f4
movb $0x4, 0x2(%r14,%r12)
movl %ebp, %ecx
movq (%rbx), %rax
incl %ebp
cmpq %rcx, (%rax,%r13,8)
ja 0x168bf1
jmp 0x168c5b
callq 0x2024e
jmp 0x168c45
movq 0x8(%rsp), %rcx
incq %rcx
movl 0x8(%rbx), %eax
cmpq %rax, %rcx
jb 0x168bd7
cmpl $0x0, 0x8(%rbx)
je 0x168d02
xorl %eax, %eax
movq (%rbx), %r8
leaq (%rax,%rax,2), %rcx
cmpq $0x0, (%r8,%rcx,8)
je 0x168cea
xorl %edi, %edi
movl $0x1, %edx
xorl %esi, %esi
movq 0x10(%r8,%rcx,8), %r8
shlq $0x6, %rdi
cmpb $0x4, 0x2(%r8,%rdi)
jne 0x168cd5
addq %r8, %rdi
movl %esi, %r9d
shlq $0x6, %r9
movups (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
movups 0x20(%rdi), %xmm2
movups 0x30(%rdi), %xmm3
movups %xmm3, 0x30(%r8,%r9)
movups %xmm2, 0x20(%r8,%r9)
movups %xmm1, 0x10(%r8,%r9)
movups %xmm0, (%r8,%r9)
incl %esi
movl %edx, %edi
movq (%rbx), %r8
incl %edx
cmpq %rdi, (%r8,%rcx,8)
ja 0x168c92
leaq (%r8,%rcx,8), %rcx
movl %esi, %edx
jmp 0x168cf0
leaq (%r8,%rcx,8), %rcx
xorl %edx, %edx
movq %rdx, (%rcx)
incq %rax
movl 0x8(%rbx), %ecx
cmpq %rcx, %rax
jb 0x168c7b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq