// File: /workspace/github_cpp_makefile_star2_O2/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)
movq (%r8), %rax
movq %rax, 0x20(%rsp)
xorl %ecx, %ecx
xorl %ebp, %ebp
xorl %ebx, %ebx
movq %r8, 0x10(%rsp)
movl %ecx, %ecx
cmpq %rcx, 0x8(%r8)
jbe 0xd3375
movq 0x18(%r8), %rax
movq (%rax,%rcx,8), %rax
testl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0xd336e
movq %rcx, 0x18(%rsp)
movq %rax, %r13
shrq $0x1e, %r13
andq $-0x4, %r13
addq 0x30(%r8), %r13
movl %eax, %eax
movq %rax, 0x40(%rsp)
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpq %r14, 0x40(%rsp)
je 0xd334e
movl (%r13,%r14,4), %eax
shrl %eax
imulq $0x28, %rax, %rdi
movq 0x20(%rsp), %rax
addq 0x10(%rax), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0xd2fdc
cmpl $-0x1, %eax
je 0xd3330
movl %eax, %r12d
cmpq %rbx, %r15
jne 0xd3323
movq %rbp, %rdi
leaq (%rbx,%rbx), %rbp
testq %rbx, %rbx
pushq $0x2
popq %rax
cmoveq %rax, %rbp
leaq (,%rbp,4), %rsi
callq 0x2370
movq %rbp, %rbx
movq %rax, %rbp
movl %r12d, (%rbp,%r15,4)
incq %r15
incq %r14
jmp 0xd32bf
movq 0x17fca9(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x118741(%rip), %rdi    # 0x1eba82
pushq $0xa
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
jmp 0xd332b
cmpq $0x2, %r15
jb 0xd3364
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movl %r15d, %edx
callq 0xd313c
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %rcx
incl %ecx
jmp 0xd327f
xorl %eax, %eax
movq 0x8(%rsp), %r10
movl 0x8(%r10), %ecx
cmpq %rcx, %rax
jae 0xd33f0
xorl %ecx, %ecx
imulq $0x18, %rax, %rdx
xorl %esi, %esi
movl %esi, %esi
movq (%r10), %r9
leaq (%r9,%rdx), %r8
movl %ecx, %edi
cmpq %rsi, (%r9,%rdx)
jbe 0xd33e8
movq 0x10(%r8), %r8
movq %rsi, %r9
shlq $0x6, %r9
cmpb $0x2, 0x2(%r8,%r9)
je 0xd33e4
addq %r8, %r9
incl %ecx
shlq $0x6, %rdi
movups (%r9), %xmm0
movups 0x10(%r9), %xmm1
movups 0x20(%r9), %xmm2
movups 0x30(%r9), %xmm3
movups %xmm3, 0x30(%r8,%rdi)
movups %xmm2, 0x20(%r8,%rdi)
movups %xmm1, 0x10(%r8,%rdi)
movups %xmm0, (%r8,%rdi)
incl %esi
jmp 0xd338d
movq %rdi, (%r8)
incq %rax
jmp 0xd337c
movq %rbp, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220