// File: /workspace/github_cpp_makefile_star2_O2/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 0xfa585
movq %r14, 0x28(%rsp)
movq 0x18(%r14), %rax
movl 0x14(%rax), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
pushq $0x1
popq %rsi
callq 0x2120
movq %rax, %r12
xorps %xmm0, %xmm0
movq %rsp, %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorl %eax, %eax
xorl %r13d, %r13d
movq %rbx, 0x30(%rsp)
movl %r13d, %r13d
cmpq %r13, 0x18(%rbx)
jbe 0x155c1a
andq $0x0, (%rsp)
movq 0x28(%rbx), %rcx
movq (%rcx,%r13,8), %rdx
movq %rdx, %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andq %rcx, %rsi
je 0x155c12
movq %rsi, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
movq 0x10(%rbx), %rcx
movq %rcx, 0x38(%rsp)
leal (,%r13,2), %ebp
movq 0x28(%rsp), %rcx
movq 0x18(%rcx), %rdx
movq 0x8(%rdx), %rcx
movq 0x28(%rdx), %rdx
movq (%rdx,%rbp,8), %rsi
testl %esi, %esi
je 0x155add
movq %rsi, %rdx
shrq $0x20, %rdx
movl %esi, %esi
imulq $0x18, %rsi, %r15
imulq $0x18, %rdx, %rdx
leaq (%rcx,%rdx), %rbx
addq $0xc, %rbx
xorl %r14d, %r14d
xorl %ecx, %ecx
cmpq %r14, %r15
je 0x155aa4
cmpl $0x0, (%rbx,%r14)
js 0x155a9e
cmpq 0x8(%rsp), %rcx
jne 0x155a8b
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
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,%r14), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rsp)
movl %edx, (%rax,%rcx,4)
movq %rsi, %rcx
addq $0x18, %r14
jmp 0x155a50
movq 0x28(%rsp), %rbx
movq 0x18(%rbx), %rdx
movq 0x20(%rdx), %rax
movl %r13d, %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %ecx
movl (%rax,%rcx,8), %r8d
andl %esi, %r8d
movl %ebp, %edi
leaq 0x50(%rsp), %rsi
movq %rsp, %rcx
callq 0xfb03f
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rcx
movq 0x28(%rax), %rdx
orl $0x1, %ebp
movq (%rdx,%rbp,8), %rax
testl %eax, %eax
je 0x155b8f
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
imulq $0x18, %rax, %rbx
imulq $0x18, %rdx, %rax
leaq (%rcx,%rax), %r14
addq $0xc, %r14
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0x155b62
cmpl $0x0, (%r14,%r15)
js 0x155b5c
movq (%rsp), %rcx
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rcx
jne 0x155b4c
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x10(%rsp)
movq (%rsp), %rcx
movl -0x4(%r14,%r15), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rsp)
movl %edx, (%rax,%rcx,4)
addq $0x18, %r15
jmp 0x155b08
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdx
movq 0x20(%rdx), %rax
movl %r13d, %ecx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %ecx
movl (%rax,%rcx,8), %r8d
andl %esi, %r8d
movl %ebp, %edi
leaq 0x50(%rsp), %rsi
movq %rsp, %rcx
callq 0xfb03f
movq 0x48(%rsp), %rdi
shrq $0x20, %rdi
movq (%rsp), %rax
movq 0x10(%rsp), %rcx
xorl %edx, %edx
movq 0x30(%rsp), %rbx
movq 0x40(%rsp), %r8
movl %edx, %edx
cmpq %rdx, %rax
jbe 0x155bc2
movl (%rcx,%rdx,4), %esi
shrl %esi
movb $0x1, (%r12,%rsi)
incl %edx
jmp 0x155bad
imulq $0x30, %r8, %rax
imulq $0x30, %rdi, %rcx
movq 0x38(%rsp), %rdx
addq %rdx, %rcx
addq $0x28, %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x155bf2
movl -0x14(%rcx,%rdx), %esi
cmpb $0x0, (%r12,%rsi)
je 0x155bec
orb $-0x80, (%rcx,%rdx)
addq $0x30, %rdx
jmp 0x155bd8
movq (%rsp), %rcx
movq 0x10(%rsp), %rax
xorl %edx, %edx
movl %edx, %edx
cmpq %rdx, %rcx
jbe 0x155c12
movl (%rax,%rdx,4), %esi
shrl %esi
movb $0x0, (%r12,%rsi)
incl %edx
jmp 0x155bfd
incl %r13d
jmp 0x1559cf
leaq 0x50(%rsp), %rdi
callq 0xfa60b
movq 0x10(%rsp), %rdi
callq 0x2220
movq %r12, %rdi
callq 0x2220
xorl %eax, %eax
xorl %ecx, %ecx
movl %eax, %eax
movl %ecx, %edx
cmpq %rax, (%rbx)
jbe 0x155c78
movq 0x10(%rbx), %rsi
imulq $0x30, %rax, %rdi
cmpb $0x0, 0x28(%rsi,%rdi)
js 0x155c74
addq %rsi, %rdi
imulq $0x30, %rdx, %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 %ecx
incl %eax
jmp 0x155c3a
movq %rdx, (%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 0x88a31
movq 0x18(%r14), %rax
andl 0x14(%rax), %ebp
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x90b09
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq