// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: filter_kv_u_trans_t(kv_u_trans_t*, ma_ug_t*, double)
void filter_kv_u_trans_t(kv_u_trans_t *ta, ma_ug_t* ug, double secondRate)
{
    kv_f_chain x; 
    memset(&x, 0, sizeof(kv_f_chain)); x.tw = 0;
    uint32_t k, i, n;
    u_trans_t *a = NULL;
    for (k = 0; k < ta->idx.n; k++)
    {
        a = u_trans_a(*ta, k);
        n = u_trans_n(*ta, k);
        if(n == 0) continue;
        qsort(a, n, sizeof(u_trans_t), cmp_kv_u_weight);
        x.n = 0; x.tov = 0; x.tw = 0; x.b.n = 0;
        for (i = 0; i < n; i++)
        {
            if(a[i].del) continue;
            insert_dip_chain(&x, &(a[i]), secondRate);
        }
    }
    free(x.a); free(x.b.a);
    kt_u_trans_t_idx(ta, ug->g->n_seq);
    kt_u_trans_t_simple_symm(ta, ug->g->n_seq, 0);


    /**
    for (k = 0; k < ta->idx.n; k++)
    {
        a = u_trans_a(*ta, k);
        n = u_trans_n(*ta, k);
        if(n == 0) continue;
        // radix_sort_k_trans_qs(a, a+n);
        for (i = 0; i < n; i++)
        {
            a[i].occ = get_MAPQ(a, n, i, secondRate);
            // if(a[i].occ != 1)
            // {
            //     uint32_t debug_i;
            //     fprintf(stderr, "\nq-utg%.6ul\tt-utg%.6ul\tocc-%u\n", a[i].qn+1, a[i].tn+1, a[i].occ);


            //     for (debug_i = 0; debug_i < n; debug_i++)
            //     {
            //         fprintf(stderr, "q-utg%.6ul\tqs(%u)\tqe(%u)\tt-utg%.6ul\tts(%u)\tte(%u)\trev(%u)\tw(%f)\tf(%u)\n", 
            //         a[debug_i].qn+1, a[debug_i].qs, a[debug_i].qe, a[debug_i].tn+1, a[debug_i].ts, 
            //         a[debug_i].te, a[debug_i].rev, a[debug_i].nw, a[debug_i].f);
            //     }
            // }
        }
    }

    for (k = 0; k < ta->n; k++)
    {
        if(ta->a[k].del || ta->a[k].qn > ta->a[k].tn) continue;
        get_u_trans_spec(ta, ta->a[k].tn, ta->a[k].qn, &r_a, NULL);
        a = &(ta->a[k]); 
        a->occ = r_a->occ = MAX(a->occ, r_a->occ);
    }
    **/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rsi, (%rsp)
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
cmpq $0x0, 0x18(%rdi)
je 0x15a1b5
xorl %r14d, %r14d
leaq 0x10(%rsp), %r12
xorl %eax, %eax
xorl %r15d, %r15d
movq 0x28(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
je 0x15a1a9
movq %rax, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %r13
shlq $0x4, %r13
addq 0x10(%rbx), %r13
movl %eax, %ebp
movl $0x30, %edx
movq %r13, %rdi
movq %rbp, %rsi
leaq -0x437(%rip), %rcx      # 0x159d37
callq 0x23f0
movq %r14, 0x18(%rsp)
movq %r14, 0x28(%rsp)
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rax
movups %xmm0, (%rax)
cmpb $0x0, 0x28(%r13)
js 0x15a1a0
movq %r12, %rdi
movq %r13, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x159d53
addq $0x30, %r13
decq %rbp
jne 0x15a188
incl %r15d
movq %r15, %rax
cmpq %r15, 0x18(%rbx)
ja 0x15a13b
movq 0x10(%rsp), %rdi
callq 0x2220
movq 0x38(%rsp), %rdi
callq 0x2220
movq (%rsp), %r14
movq 0x18(%r14), %rax
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl 0x14(%rax), %esi
andl %ebp, %esi
movq %rbx, %rdi
callq 0xc405a
movq 0x18(%r14), %rax
andl 0x14(%rax), %ebp
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcb60e