// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r12
movl 0x8(%rsi), %edi
movl 0x14(%rsi), %eax
cmpl %eax, %edi
ja 0x87e5a
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rbx
movq 0x10(%r12), %rcx
movq 0x28(%r12), %rdx
movq (%rdx,%rax,8), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
imulq $0x30, %rsi, %r9
leaq (%rcx,%r9), %rsi
movl %edx, %r8d
leaq (%rcx,%r9), %r13
addq $0x18, %r13
xorl %ecx, %ecx
cmpq %rcx, %r8
je 0x87e69
cmpl %edi, -0x4(%r13)
je 0x87d9c
incq %rcx
addq $0x30, %r13
jmp 0x87d84
cmpl $-0x1, 0x18(%rbx)
sete %dil
cmpl $-0x1, (%r13)
sete %r8b
cmpb %r8b, %dil
je 0x87e5a
movq 0x10(%r15), %rdi
imulq $0x28, %rax, %rax
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl (%rdi,%rax), %r8d
movl %ebp, (%rsp)
movq %r14, %r9
movsd %xmm0, 0x10(%rsp)
callq 0x87b60
testl %eax, %eax
je 0x87e50
movq 0x10(%r12), %rcx
movq 0x28(%r12), %rdx
movl 0x8(%rbx), %eax
movq (%rdx,%rax,8), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
imulq $0x30, %rsi, %r8
leaq (%rcx,%r8), %rsi
movl %edx, %edi
addq %rcx, %r8
addq $0x14, %r8
xorl %ecx, %ecx
movsd 0x10(%rsp), %xmm0
cmpq %rcx, %rdi
je 0x87e88
movl (%r8), %r9d
cmpl 0x14(%rbx), %r9d
je 0x87e25
incq %rcx
addq $0x30, %r8
jmp 0x87e0e
movq 0x10(%r15), %rdi
imulq $0x28, %rax, %rax
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl (%rdi,%rax), %r8d
movl %ebp, (%rsp)
movq %r14, %r9
callq 0x87b60
testl %eax, %eax
je 0x87e50
orl $-0x1, (%r13)
pushq $-0x1
popq %rax
jmp 0x87e57
andl $0x0, (%r13)
xorl %eax, %eax
movl %eax, 0x18(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x160c60(%rip), %rdi    # 0x1e8ad0
leaq 0x15ff1a(%rip), %rsi    # 0x1e7d91
leaq 0x160c5c(%rip), %rcx    # 0x1e8ada
movl $0x3b2f, %edx           # imm = 0x3B2F
callq 0x2110
leaq 0x160ca8(%rip), %rdi    # 0x1e8b37
leaq 0x15fefb(%rip), %rsi    # 0x1e7d91
leaq 0x160c3d(%rip), %rcx    # 0x1e8ada
movl $0x3b41, %edx           # imm = 0x3B41
callq 0x2110