// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: normalize_hap_overlaps(hap_overlaps_list*, hap_overlaps_list*)
void normalize_hap_overlaps(hap_overlaps_list* all_ovlp, hap_overlaps_list* back_all_ovlp)
{
    hap_overlaps *x = NULL, *y = NULL;
    uint32_t v, i, uId, qn, tn;
    uint32_t types[4];
    types[X2Y] = Y2X; types[Y2X] = X2Y; types[XCY] = YCX; types[YCX] = XCY;
    int index;
    for (v = 0; v < all_ovlp->num; v++)
    {
        uId = v;
        for (i = 0; i < all_ovlp->x[uId].a.n; i++)
        {
            qn = all_ovlp->x[uId].a.a[i].xUid;
            tn = all_ovlp->x[uId].a.a[i].yUid;
            x = &(all_ovlp->x[uId].a.a[i]);
            index = get_specific_hap_overlap(&(all_ovlp->x[tn]), tn, qn);
            if(index != -1)
            {
                y = &(all_ovlp->x[tn].a.a[index]);
                if(x->rev == y->rev && types[x->type]==y->type) continue;
                if(x->weight >= y->weight)
                {
                    kv_push(hap_overlaps, back_all_ovlp->x[tn].a, (*y));
                    set_reverse_hap_overlap(y, x, types);
                }
                else
                {
                    kv_push(hap_overlaps, back_all_ovlp->x[qn].a, (*x));
                    set_reverse_hap_overlap(x, y, types);
                }
            }
            else
            {
                kv_pushp(hap_overlaps, all_ovlp->x[tn].a, &y);
                set_reverse_hap_overlap(y, x, types);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, 0x8(%rsp)
movaps 0x1283f9(%rip), %xmm0   # 0x239690
movaps %xmm0, 0x10(%rsp)
movl 0x8(%rdi), %eax
testl %eax, %eax
je 0x111513
movq %rdi, %r14
movq (%rdi), %rcx
xorl %esi, %esi
leaq (%rsi,%rsi,2), %rbx
cmpq $0x0, (%rcx,%rbx,8)
je 0x111505
movq %rsi, 0x20(%rsp)
xorl %edx, %edx
xorl %ebp, %ebp
movq 0x10(%rcx,%rbx,8), %rsi
shlq $0x6, %rdx
leaq (%rsi,%rdx), %r12
movl 0x28(%rsi,%rdx), %eax
leaq (%rax,%rax,2), %r15
leaq (%rcx,%r15,8), %r8
movq (%r8), %rdi
testq %rdi, %rdi
je 0x111320
movl 0x24(%rsi,%rdx), %edx
movq 0x10(%r8), %rsi
movl $0x1, %r9d
xorl %r10d, %r10d
shlq $0x6, %r10
cmpl %eax, 0x24(%rsi,%r10)
jne 0x11130d
addq %rsi, %r10
cmpl %edx, 0x28(%r10)
je 0x11131a
movl %r9d, %r10d
incl %r9d
cmpq %r10, %rdi
ja 0x1112f9
jmp 0x111320
subl $0x1, %r9d
jae 0x111391
cmpq 0x8(%r8), %rdi
jne 0x11135c
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
movl $0x2, %edx
cmoveq %rdx, %rsi
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
movq %rsi, 0x8(%rcx,%r13)
movq 0x10(%r8), %rdi
shlq $0x6, %rsi
callq 0x2370
movq (%r14), %rcx
movq %rax, 0x10(%rcx,%r13)
movq (%rcx,%r13), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%rcx,%r15,8)
shlq $0x6, %rdi
addq 0x10(%rcx,%r15,8), %rdi
movq %r12, %rsi
leaq 0x10(%rsp), %rdx
callq 0x11122f
incl %ebp
movq (%r14), %rcx
movq %rbp, %rdx
cmpq %rbp, (%rcx,%rbx,8)
ja 0x1112c7
jmp 0x1114fc
movslq %r9d, %rcx
shlq $0x6, %rcx
leaq (%rsi,%rcx), %r13
movb (%r12), %dil
cmpb (%rsi,%rcx), %dil
jne 0x1113b7
movzbl 0x1(%r12), %ecx
movzbl 0x1(%r13), %esi
cmpl %esi, 0x10(%rsp,%rcx,4)
je 0x11137a
movl 0x2c(%r12), %esi
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
cmpl 0x2c(%r13), %esi
jae 0x11146a
leaq (%rdx,%rdx,2), %r15
movq (%rcx,%r15,8), %rax
cmpq 0x8(%rcx,%r15,8), %rax
jne 0x111424
leaq (%rcx,%r15,8), %rdi
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rax
movq %rax, (%rsp)
movq %rsi, 0x8(%rcx,%rax)
movq 0x10(%rdi), %rdi
shlq $0x6, %rsi
callq 0x2370
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rsp), %rdx
movq %rax, 0x10(%rcx,%rdx)
movq (%rcx,%rdx), %rax
movq 0x10(%rcx,%r15,8), %rdx
leaq 0x1(%rax), %rsi
movq %rsi, (%rcx,%r15,8)
shlq $0x6, %rax
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups 0x30(%r12), %xmm3
movups %xmm3, 0x30(%rdx,%rax)
movups %xmm2, 0x20(%rdx,%rax)
movups %xmm1, 0x10(%rdx,%rax)
movups %xmm0, (%rdx,%rax)
movq %r12, %rdi
movq %r13, %rsi
jmp 0x111370
movq (%rcx,%r15,8), %rdx
cmpq 0x8(%rcx,%r15,8), %rdx
jne 0x1114bc
leaq (%rcx,%r15,8), %rdi
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %edx
cmoveq %rdx, %rsi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rax
movq %rax, (%rsp)
movq %rsi, 0x8(%rcx,%rax)
movq 0x10(%rdi), %rdi
shlq $0x6, %rsi
callq 0x2370
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rsp), %rdx
movq %rax, 0x10(%rcx,%rdx)
movq (%rcx,%rdx), %rdx
movq 0x10(%rcx,%r15,8), %rax
leaq 0x1(%rdx), %rsi
movq %rsi, (%rcx,%r15,8)
shlq $0x6, %rdx
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups 0x30(%r13), %xmm3
movups %xmm3, 0x30(%rax,%rdx)
movups %xmm2, 0x20(%rax,%rdx)
movups %xmm1, 0x10(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
movq %r13, %rdi
jmp 0x11136d
movl 0x8(%r14), %eax
movq 0x20(%rsp), %rsi
incq %rsi
movl %eax, %edx
cmpq %rdx, %rsi
jb 0x1112af
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq