// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: filter_ovlp_scg(hap_overlaps_list*, unsigned long*, R_to_U*, ma_ug_t*, spg_t*)
void filter_ovlp_scg(hap_overlaps_list* ha, uint64_t* ps_idx, R_to_U* ruIndex, ma_ug_t *rug, spg_t *scg)
{
    uint32_t i, k, v, *ma = NULL, mn, luid;
    ma_utg_v *pp = &(scg->ug->u);
    kvec_t(uint32_t) vv; kv_init(vv);
    for (i = 0; i < scg->idx.n; i++){
        ma = scg->dst.a + (scg->idx.a[i]>>32);
        mn = (uint64_t)scg->idx.a[i];
        if(mn < 2) continue;
        for (k = 0, vv.n = 0; k < mn; k++){
            luid = seed_uid(&(pp->a[ma[k]>>1]), ps_idx, ruIndex, rug);
            if(luid == (uint32_t)-1) {
                fprintf(stderr, "ERROR-scg\n");
                continue;
            }
            kv_push(uint32_t, vv, luid);
        }
        if(vv.n < 2) continue;
        filter_ovlp_vecs(ha, vv.a, vv.n);
    }

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

    kv_destroy(vv);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, 0x8(%rsp)
xorl %ecx, %ecx
cmpq $0x0, 0x8(%r8)
je 0x112bb4
movq (%r8), %rax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r8, 0x10(%rsp)
movq 0x18(%r8), %rax
movq (%rax,%rcx,8), %rax
testl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0x112ba6
movq %rcx, 0x18(%rsp)
movq %rax, %rbp
shrq $0x1e, %rbp
andq $-0x4, %rbp
addq 0x30(%r8), %rbp
movl %eax, %eax
movq %rax, 0x40(%rsp)
xorl %r14d, %r14d
xorl %r15d, %r15d
movl (%rbp,%r14,4), %eax
shrl %eax
leaq (%rax,%rax,4), %rdi
shlq $0x3, %rdi
movq 0x20(%rsp), %rax
addq 0x10(%rax), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x112717
cmpl $-0x1, %eax
je 0x112b7f
movl %eax, %ebx
cmpq %r12, %r15
jne 0x112b6b
movq %r13, %rdi
leaq (%r12,%r12), %r13
testq %r12, %r12
movl $0x2, %eax
cmoveq %rax, %r13
leaq (,%r13,4), %rsi
callq 0x2370
movq %r13, %r12
movq %rax, %r13
movl %ebx, (%r13,%r15,4)
incq %r15
incq %r14
cmpq %r14, 0x40(%rsp)
jne 0x112b0d
jmp 0x112b86
callq 0x13dec
jmp 0x112b73
cmpq $0x2, %r15
jb 0x112b9c
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x112917
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %rcx
incl %ecx
cmpq %rcx, 0x8(%r8)
ja 0x112ad9
jmp 0x112bb7
xorl %r13d, %r13d
movq 0x8(%rsp), %r10
cmpl $0x0, 0x8(%r10)
je 0x112c51
xorl %eax, %eax
movq (%r10), %r8
leaq (%rax,%rax,2), %rcx
cmpq $0x0, (%r8,%rcx,8)
je 0x112c38
xorl %edi, %edi
movl $0x1, %edx
xorl %esi, %esi
movq 0x10(%r8,%rcx,8), %r8
shlq $0x6, %rdi
cmpb $0x2, 0x2(%r8,%rdi)
je 0x112c23
addq %r8, %rdi
movl %esi, %r9d
incl %esi
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)
movl %edx, %edi
movq (%r10), %r8
incl %edx
cmpq %rdi, (%r8,%rcx,8)
ja 0x112be0
leaq (%r8,%rcx,8), %rcx
movl %esi, %edx
jmp 0x112c3e
leaq (%r8,%rcx,8), %rcx
xorl %edx, %edx
movq %rdx, (%rcx)
incq %rax
movl 0x8(%r10), %ecx
cmpq %rcx, %rax
jb 0x112bc9
movq %r13, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220