// File: 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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movslq %eax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x1cb9c0
movq $0x0, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2140
movq %rax, -0xa8(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xb8(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x278efe
movq $0x0, -0xc8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x24(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x278b4b
jmp 0x278ef0
movl -0x24(%rbp), %eax
shll %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rcx
movl -0x30(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jbe 0x278cb7
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x278c7b
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x278bd2
jmp 0x278c6d
jmp 0x278bd4
movq -0xc8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jne 0x278c3b
cmpq $0x0, -0xc0(%rbp)
je 0x278c01
movq -0xc0(%rbp), %rax
shlq %rax
movq %rax, -0xd0(%rbp)
jmp 0x278c0f
movl $0x2, %eax
movq %rax, -0xd0(%rbp)
jmp 0x278c0f
movq -0xd0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0xb8(%rbp)
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movq -0xb8(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0xc8(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x278c6d
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x278ba8
movl -0x30(%rbp), %edi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x30(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq -0xa0(%rbp), %rsi
leaq -0xc8(%rbp), %rcx
callq 0x1cd0e0
movl -0x24(%rbp), %eax
shll %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rcx
movl -0x30(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jbe 0x278e26
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x278dea
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x278d41
jmp 0x278ddc
jmp 0x278d43
movq -0xc8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jne 0x278daa
cmpq $0x0, -0xc0(%rbp)
je 0x278d70
movq -0xc0(%rbp), %rax
shlq %rax
movq %rax, -0xd8(%rbp)
jmp 0x278d7e
movl $0x2, %eax
movq %rax, -0xd8(%rbp)
jmp 0x278d7e
movq -0xd8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0xb8(%rbp)
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edx
movq -0xb8(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0xc8(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x278ddc
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x278d17
movl -0x30(%rbp), %edi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x30(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
leaq -0xa0(%rbp), %rsi
leaq -0xc8(%rbp), %rcx
callq 0x1cd0e0
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpq -0xc8(%rbp), %rax
jae 0x278e60
movq -0xa8(%rbp), %rax
movq -0xb8(%rbp), %rcx
movl -0x28(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
movb $0x1, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x278e2d
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x278eb4
movq -0xa8(%rbp), %rax
movq -0x18(%rbp), %rcx
movl -0x28(%rbp), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movl 0x14(%rcx), %ecx
cmpb $0x0, (%rax,%rcx)
je 0x278ea7
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movb 0x28(%rax), %cl
andb $0x7f, %cl
orb $-0x80, %cl
movb %cl, 0x28(%rax)
jmp 0x278ea9
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x278e67
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpq -0xc8(%rbp), %rax
jae 0x278eee
movq -0xa8(%rbp), %rax
movq -0xb8(%rbp), %rcx
movl -0x28(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x278ebb
jmp 0x278ef0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x278aec
leaq -0xa0(%rbp), %rdi
callq 0x1cbb60
movq -0xb8(%rbp), %rdi
callq 0x2210
movq -0xa8(%rbp), %rdi
callq 0x2210
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x278f9c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movb 0x28(%rax), %al
shrb $0x7, %al
cmpb $0x0, %al
je 0x278f5a
jmp 0x278f91
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x24(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x2c(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl $0x30, %edx
callq 0x2180
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x278f30
movl -0x2c(%rbp), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
callq 0x104540
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %edx, %edx
callq 0x1128e0
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)