// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/tovlp.cpp
// Function: clean_mz_ovlp(kv_u_trans_t*, ma_ug_t*)
void clean_mz_ovlp(kv_u_trans_t *ta, ma_ug_t *ug)
{
    u_trans_t *a = NULL;
    asg_arc_t *as = NULL;
    uint32_t k, i, n, v, ns;
    pdq pq; init_pdq(&pq, ug->g->n_seq<<1);
    uint8_t *vis = NULL; CALLOC(vis, ug->g->n_seq);
    kvec_t_u32_warp p; kv_init(p.a);
    for (k = 0; k < ta->idx.n; k++)
    {
        p.a.n = 0;
        a = u_trans_a(*ta, k);
        n = u_trans_n(*ta, k);
        if(n == 0) continue;

        v = k<<1;
        as = asg_arc_a(ug->g, v); ns = asg_arc_n(ug->g, v);
        if(ns > 0)
        {
            for (i = 0; i < ns; i++)
            {
                if(as[i].del) continue;
                kv_push(uint32_t, p.a, as[i].v);
            }
            set_utg_by_dis(v, &pq, ug->g, &p, ug->g->seq[v>>1].len);
        }


        v = (k<<1) + 1;
        as = asg_arc_a(ug->g, v); ns = asg_arc_n(ug->g, v);
        if(ns > 0)
        {
            for (i = 0; i < ns; i++)
            {
                if(as[i].del) continue;
                kv_push(uint32_t, p.a, as[i].v);
            }
            set_utg_by_dis(v, &pq, ug->g, &p, ug->g->seq[v>>1].len);
        }

        for (i = 0; i < p.a.n; i++) vis[p.a.a[i]>>1] = 1; 

        for (i = 0; i < n; i++)
        {
            if(vis[a[i].tn]) a[i].del = 1;
        }

        for (i = 0; i < p.a.n; i++) vis[p.a.a[i]>>1] = 0; 
    }
    destory_pdq(&pq);
    kv_destroy(p.a);
    free(vis);

    for (k = n = 0; k < ta->n; ++k)
    {
        if(ta->a[k].del) continue;
        ta->a[n] = ta->a[k];
        n++;
    }
    ta->n = n;
    kt_u_trans_t_idx(ta, ug->g->n_seq);
    kt_u_trans_t_simple_symm(ta, ug->g->n_seq, 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rsi), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %rsi
leaq 0x50(%rsp), %rdi
callq 0x14198e
movq %r14, 0x28(%rsp)
movq 0x18(%r14), %rax
movl 0x14(%rax), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movl $0x1, %esi
callq 0x2120
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x18(%rbx)
je 0x19ceac
xorl %r12d, %r12d
movq %rbx, 0x38(%rsp)
movq $0x0, (%rsp)
movq 0x28(%rbx), %rax
movq (%rax,%r12,8), %rcx
movq %rcx, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %r14
je 0x19ce9f
movq %rcx, 0x48(%rsp)
movq 0x10(%rbx), %rax
movq %rax, 0x40(%rsp)
leal (%r12,%r12), %r13d
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x8(%rcx), %rax
movq 0x28(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
testl %edx, %edx
je 0x19cd63
movq %r13, 0x30(%rsp)
movq %rdx, %rcx
shrq $0x20, %rcx
movl %edx, %edx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %r13
addq $0xc, %r13
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rbx
xorl %ebp, %ebp
xorl %ecx, %ecx
cmpl $0x0, (%r13,%rbp)
js 0x19cd16
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rcx
jne 0x19cd03
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rsp)
movq (%rsp), %rcx
movl -0x4(%r13,%rbp), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rsp)
movl %edx, (%rax,%rcx,4)
movq %rsi, %rcx
addq $0x18, %rbp
cmpq %rbp, %rbx
jne 0x19ccc5
movq 0x28(%rsp), %rbx
movq 0x18(%rbx), %rdx
movq 0x20(%rdx), %rax
movl %r12d, %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %ecx
movl (%rax,%rcx,8), %r8d
andl %esi, %r8d
movq 0x30(%rsp), %r13
movl %r13d, %edi
leaq 0x50(%rsp), %rsi
movq %rsp, %rcx
callq 0x14259c
movq 0x18(%rbx), %rcx
movq 0x8(%rcx), %rax
movq 0x28(%rcx), %rcx
movq 0x38(%rsp), %rbx
orl $0x1, %r13d
movq (%rcx,%r13,8), %rcx
testl %ecx, %ecx
je 0x19ce24
movq %r13, 0x30(%rsp)
movq %rcx, %rdx
shrq $0x20, %rdx
movl %ecx, %ecx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rbx
addq $0xc, %rbx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %r13
xorl %ebp, %ebp
cmpl $0x0, (%rbx,%rbp)
js 0x19cde6
movq (%rsp), %rcx
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rcx
jne 0x19cdd7
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rsp)
movq (%rsp), %rcx
movl -0x4(%rbx,%rbp), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rsp)
movl %edx, (%rax,%rcx,4)
addq $0x18, %rbp
cmpq %rbp, %r13
jne 0x19cd97
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdx
movq 0x20(%rdx), %rax
movl %r12d, %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %ecx
movl (%rax,%rcx,8), %r8d
andl %esi, %r8d
movq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rsp, %rcx
callq 0x14259c
movq 0x38(%rsp), %rbx
movq (%rsp), %rax
testq %rax, %rax
je 0x19ce48
movq 0x10(%rsp), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
shrl %esi
movb $0x1, (%r15,%rsi)
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0x19ce34
movq 0x48(%rsp), %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq 0x40(%rsp), %rcx
addq %rcx, %rax
addq $0x28, %rax
movl -0x14(%rax), %ecx
cmpb $0x0, (%r15,%rcx)
je 0x19ce72
orb $-0x80, (%rax)
addq $0x30, %rax
decq %r14
jne 0x19ce65
movq (%rsp), %rax
testq %rax, %rax
je 0x19ce9f
movq 0x10(%rsp), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
shrl %esi
movb $0x0, (%r15,%rsi)
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0x19ce8b
incl %r12d
cmpq %r12, 0x18(%rbx)
ja 0x19cc4f
leaq 0x50(%rsp), %rdi
callq 0x141a1d
movq 0x10(%rsp), %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2220
movq (%rbx), %rdx
xorl %eax, %eax
testq %rdx, %rdx
je 0x19cf22
movl $0x1, %ecx
xorl %edi, %edi
movq 0x10(%rbx), %rsi
leaq (%rdi,%rdi,2), %rdi
shlq $0x4, %rdi
cmpb $0x0, 0x28(%rsi,%rdi)
js 0x19cf17
addq %rsi, %rdi
movl %eax, %edx
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
movups (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
movups 0x20(%rdi), %xmm2
movups %xmm2, 0x20(%rsi,%rdx)
movups %xmm1, 0x10(%rsi,%rdx)
movups %xmm0, (%rsi,%rdx)
incl %eax
movq (%rbx), %rdx
movl %ecx, %edi
incl %ecx
cmpq %rdi, %rdx
ja 0x19ced9
movl %eax, %eax
movq %rax, (%rbx)
movq 0x28(%rsp), %r14
movq 0x18(%r14), %rax
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl 0x14(%rax), %esi
andl %ebp, %esi
movq %rbx, %rdi
callq 0xc4edd
movq 0x18(%r14), %rax
andl 0x14(%rax), %ebp
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0xcc893
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq