// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movq %rsi, %r13
movq %rdi, %rbx
movq 0x18(%rsi), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %rsi
leaq 0x40(%rsp), %rdi
callq 0x13bb82
movq 0x18(%r13), %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 0x194123
xorl %r12d, %r12d
movq %rbx, 0x30(%rsp)
movq %r13, 0x28(%rsp)
movq $0x0, (%rsp)
movq 0x28(%rbx), %rax
movq (%rax,%r12,8), %r14
testl %r14d, %r14d
je 0x194116
movq 0x10(%rbx), %rax
movq %rax, 0x38(%rsp)
leal (%r12,%r12), %ebp
movq 0x18(%r13), %rcx
movq 0x28(%rcx), %rax
movq (%rax,%rbp,8), %rax
testl %eax, %eax
je 0x193fbb
movq %rbp, 0x20(%rsp)
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rbx
addq $0xc, %rbx
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
xorl %ebp, %ebp
cmpl $0x0, (%rbx,%rbp)
js 0x193f7b
movq 0x8(%rsp), %rax
cmpq %rax, (%rsp)
jne 0x193f63
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x10(%rsp)
movl -0x4(%rbx,%rbp), %eax
movq (%rsp), %rcx
movq 0x10(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rsp)
movl %eax, (%rdx,%rcx,4)
addq $0x18, %rbp
cmpq %rbp, %r13
jne 0x193f2a
movq 0x28(%rsp), %r13
movq 0x18(%r13), %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 0x20(%rsp), %rbp
movl %ebp, %edi
leaq 0x40(%rsp), %rsi
movq %rsp, %rcx
callq 0x13c78a
movq 0x30(%rsp), %rbx
orl $0x1, %ebp
movq 0x18(%r13), %rcx
movq 0x28(%rcx), %rax
movq (%rax,%rbp,8), %rax
testl %eax, %eax
je 0x194089
movq %rbp, 0x20(%rsp)
movq 0x8(%rcx), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
leaq (%rcx,%rdx,8), %rbx
addq $0xc, %rbx
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
xorl %ebp, %ebp
cmpl $0x0, (%rbx,%rbp)
js 0x19404b
movq 0x8(%rsp), %rax
cmpq %rax, (%rsp)
jne 0x194033
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x10(%rsp)
movl -0x4(%rbx,%rbp), %eax
movq (%rsp), %rcx
movq 0x10(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rsp)
movl %eax, (%rdx,%rcx,4)
addq $0x18, %rbp
cmpq %rbp, %r13
jne 0x193ffa
movq 0x28(%rsp), %r13
movq 0x18(%r13), %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 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %rsp, %rcx
callq 0x13c78a
movq 0x30(%rsp), %rbx
movq (%rsp), %rax
testq %rax, %rax
je 0x1940ad
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 0x194099
movq %r14, %rax
shrq $0x20, %rax
cmpl $0x1, %r14d
adcl $0x0, %r14d
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq 0x38(%rsp), %rcx
addq %rcx, %rax
addq $0x28, %rax
shlq $0x4, %r14
leaq (%r14,%r14,2), %rcx
xorl %edx, %edx
movl -0x14(%rax,%rdx), %esi
cmpb $0x0, (%r15,%rsi)
je 0x1940e9
orb $-0x80, (%rax,%rdx)
addq $0x30, %rdx
cmpq %rdx, %rcx
jne 0x1940da
movq (%rsp), %rax
testq %rax, %rax
je 0x194116
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 0x194102
incl %r12d
cmpq %r12, 0x18(%rbx)
ja 0x193ec8
leaq 0x40(%rsp), %rdi
callq 0x13bc20
movq 0x10(%rsp), %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2220
xorl %eax, %eax
cmpq $0x0, (%rbx)
je 0x194194
movl $0x1, %ecx
xorl %esi, %esi
movq 0x10(%rbx), %rdx
leaq (%rsi,%rsi,2), %rsi
shlq $0x4, %rsi
cmpb $0x0, 0x28(%rdx,%rsi)
js 0x194189
addq %rdx, %rsi
movl %eax, %edi
leaq (%rdi,%rdi,2), %rdi
shlq $0x4, %rdi
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
movups 0x20(%rsi), %xmm2
movups %xmm2, 0x20(%rdx,%rdi)
movups %xmm1, 0x10(%rdx,%rdi)
movups %xmm0, (%rdx,%rdi)
incl %eax
movl %ecx, %esi
incl %ecx
cmpq %rsi, (%rbx)
ja 0x19414e
movl %eax, %eax
movq %rax, (%rbx)
movq 0x18(%r13), %rax
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl 0x14(%rax), %esi
andl %ebp, %esi
movq %rbx, %rdi
callq 0xc405a
movq 0x18(%r13), %rax
andl 0x14(%rax), %ebp
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0xcb60e
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq