// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: deep_clean_u_trans(kv_u_trans_t*, u_trans_t*, ma_ug_t*, asg64_v*, unsigned int, double)
void deep_clean_u_trans(kv_u_trans_t *ta, u_trans_t *mz, ma_ug_t *ug, asg64_v *srt, uint32_t len_cut, double rate_cut)
{
    if(mz->qn > mz->tn) return;
    u_trans_t *r_a, *cz, *a; uint32_t r_k, r_n, n, k;
    r_a = u_trans_a(*ta, mz->tn); r_n = u_trans_n(*ta, mz->tn);
    for (r_k = 0; (r_k < r_n) && (r_a[r_k].tn != mz->qn); r_k++);
    assert(r_k < r_n); cz = &(r_a[r_k]);
    // if((mz->qn == 3924 && mz->tn == 160) || (mz->tn == 3924 && mz->qn == 160)) {
    //     fprintf(stderr, "[M::%s::]\tutg%.6u%c\t%u\t%u\t%u\t%c\tutg%.6u%c\t%u\t%u\t%u\tnw::%f\tf::%u\tdel::%u\n", __func__,
    //                 mz->qn+1, "lc"[ug->u.a[mz->qn].circ], ug->u.a[mz->qn].len, mz->qs, mz->qe, "+-"[mz->rev],
    //                 mz->tn+1, "lc"[ug->u.a[mz->tn].circ], ug->u.a[mz->tn].len, mz->ts, mz->te, mz->nw, mz->f,
    //                 (mz->occ == ((uint32_t)-1))?1:0);
    //     fprintf(stderr, "[M::%s::]\tutg%.6u%c\t%u\t%u\t%u\t%c\tutg%.6u%c\t%u\t%u\t%u\tnw::%f\tf::%u\tdel::%u\n", __func__,
    //                 cz->qn+1, "lc"[ug->u.a[cz->qn].circ], ug->u.a[cz->qn].len, cz->qs, cz->qe, "+-"[cz->rev],
    //                 cz->tn+1, "lc"[ug->u.a[cz->tn].circ], ug->u.a[cz->tn].len, cz->ts, cz->te, cz->nw, cz->f,
    //                 (cz->occ == ((uint32_t)-1))?1:0);
    // }
    if((mz->occ == ((uint32_t)-1)) && (cz->occ == ((uint32_t)-1))) return;
    if((mz->occ != ((uint32_t)-1)) && (cz->occ != ((uint32_t)-1))) return;

    if(!test_arc_rm(ug, r_a, r_n, r_k, ug->u.a[mz->tn].len, srt, len_cut, rate_cut)) {
        mz->occ = cz->occ = 0; return;
    } else {
        a = u_trans_a(*ta, mz->qn); n = u_trans_n(*ta, mz->qn);
        for (k = 0; (k < n) && (a[k].tn != mz->tn); k++); assert(k < n);
        if(!test_arc_rm(ug, a, n, k, ug->u.a[mz->qn].len, srt, len_cut, rate_cut)) {
            mz->occ = cz->occ = 0; return;
        }
    }
    mz->occ = cz->occ = ((uint32_t)-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jbe 0x102d66
jmp 0x102fe7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x10(%rbp), %rdx
movl 0x14(%rdx), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x14(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x50(%rbp), %ecx
movb %al, -0x59(%rbp)
jae 0x102dd8
movq -0x38(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x102de1
jmp 0x102dee
jmp 0x102de3
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x102dad
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jae 0x102df8
jmp 0x102e17
leaq 0x2847ff(%rip), %rdi    # 0x3875fe
leaq 0x283ab7(%rip), %rsi    # 0x3868bd
movl $0x3b2f, %edx           # imm = 0x3B2F
leaq 0x2847f6(%rip), %rcx    # 0x387608
callq 0x2130
movq -0x38(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
jne 0x102e42
movq -0x40(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
jne 0x102e42
jmp 0x102fe7
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
je 0x102e5b
movq -0x40(%rbp), %rax
cmpl $-0x1, 0x18(%rax)
je 0x102e5b
jmp 0x102fe7
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x50(%rbp), %edx
movl -0x4c(%rbp), %ecx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %r8
movl 0x14(%r8), %r8d
imulq $0x28, %r8, %r8
addq %r8, %rax
movl (%rax), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq -0x20(%rbp), %r9
movl -0x24(%rbp), %eax
movsd -0x30(%rbp), %xmm0
movl %eax, (%rsp)
callq 0x102880
cmpl $0x0, %eax
jne 0x102ebe
movq -0x40(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
jmp 0x102fe7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x10(%rbp), %rdx
movl 0x8(%rdx), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %ecx
xorl %eax, %eax
cmpl -0x54(%rbp), %ecx
movb %al, -0x5a(%rbp)
jae 0x102f30
movq -0x48(%rbp), %rax
movl -0x58(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x14(%rcx), %eax
setne %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
testb $0x1, %al
jne 0x102f39
jmp 0x102f46
jmp 0x102f3b
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x102f05
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
jae 0x102f50
jmp 0x102f6f
leaq 0x28470e(%rip), %rdi    # 0x387665
leaq 0x28395f(%rip), %rsi    # 0x3868bd
movl $0x3b41, %edx           # imm = 0x3B41
leaq 0x28469e(%rip), %rcx    # 0x387608
callq 0x2130
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x54(%rbp), %edx
movl -0x58(%rbp), %ecx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %r8
movl 0x8(%r8), %r8d
imulq $0x28, %r8, %r8
addq %r8, %rax
movl (%rax), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq -0x20(%rbp), %r9
movl -0x24(%rbp), %eax
movsd -0x30(%rbp), %xmm0
movl %eax, (%rsp)
callq 0x102880
cmpl $0x0, %eax
jne 0x102fcf
movq -0x40(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x18(%rax)
jmp 0x102fe7
jmp 0x102fd1
movq -0x40(%rbp), %rax
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x18(%rax) # imm = 0xFFFFFFFF
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)