// File: /workspace/github_cpp_makefile_star2_O3/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 %edx, %edx
cmpq $0x0, 0x8(%r8)
je 0x11869c
movq (%r8), %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %r8, 0x10(%rsp)
movq 0x18(%r8), %rcx
movq (%rcx,%rdx,8), %rcx
testl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
je 0x11868e
movq %rdx, 0x18(%rsp)
movq %rcx, %rbp
shrq $0x1e, %rbp
andq $-0x4, %rbp
addq 0x30(%r8), %rbp
movl %ecx, %ecx
movq %rcx, 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 0x1182a8
cmpl $-0x1, %eax
je 0x118667
movl %eax, %ebx
cmpq %r13, %r15
jne 0x118654
leaq (%r15,%r15), %r13
testq %r15, %r15
movl $0x2, %eax
cmoveq %rax, %r13
leaq (,%r13,4), %rsi
movq %r12, %rdi
callq 0x2370
movq %rax, %r12
movl %ebx, (%r12,%r15,4)
incq %r15
incq %r14
cmpq %r14, 0x40(%rsp)
jne 0x1185f9
jmp 0x11866e
callq 0x136e8
jmp 0x11865b
cmpq $0x2, %r15
jb 0x118684
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0x118426
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %rdx
incl %edx
cmpq %rdx, 0x8(%r8)
ja 0x1185c4
jmp 0x11869f
xorl %r12d, %r12d
movq 0x8(%rsp), %r10
movl 0x8(%r10), %esi
testl %esi, %esi
je 0x118742
movq (%r10), %rcx
xorl %r11d, %r11d
leaq (%r11,%r11,2), %rdx
cmpq $0x0, (%rcx,%rdx,8)
je 0x11872b
xorl %r8d, %r8d
movl $0x1, %esi
xorl %edi, %edi
movq 0x10(%rcx,%rdx,8), %r9
shlq $0x6, %r8
cmpb $0x2, 0x2(%r9,%r8)
je 0x118714
addq %r9, %r8
movl %edi, %ecx
incl %edi
shlq $0x6, %rcx
movups (%r8), %xmm0
movups 0x10(%r8), %xmm1
movups 0x20(%r8), %xmm2
movups 0x30(%r8), %xmm3
movups %xmm3, 0x30(%r9,%rcx)
movups %xmm2, 0x20(%r9,%rcx)
movups %xmm1, 0x10(%r9,%rcx)
movups %xmm0, (%r9,%rcx)
movq (%r10), %rcx
movl %esi, %r8d
incl %esi
cmpq %r8, (%rcx,%rdx,8)
ja 0x1186cb
leaq (%rcx,%rdx,8), %rdx
movl 0x8(%r10), %esi
movl %edi, %edi
jmp 0x118731
leaq (%rcx,%rdx,8), %rdx
xorl %edi, %edi
movq %rdi, (%rdx)
incq %r11
movl %esi, %edx
cmpq %rdx, %r11
jb 0x1186b6
movq %r12, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220