// File: /workspace/github_cpp_makefile_star2_O2/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
leaq 0x40(%rsp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
movaps %xmm0, -0x10(%r15)
movaps %xmm0, -0x20(%r15)
movaps %xmm0, -0x30(%r15)
xorl %r12d, %r12d
leaq 0x10(%rsp), %r13
movl %r12d, %r12d
cmpq %r12, 0x18(%rbx)
jbe 0x11a5a8
movq 0x28(%rbx), %rax
movq (%rax,%r12,8), %rax
testl %eax, %eax
je 0x11a5a3
movq %rax, %rcx
shrq $0x20, %rcx
imulq $0x30, %rcx, %rbp
addq 0x10(%rbx), %rbp
movl %eax, %r14d
movq %rbp, %rdi
movq %r14, %rsi
pushq $0x30
popq %rdx
leaq -0x408(%rip), %rcx      # 0x11a160
callq 0x23f0
andq $0x0, 0x18(%rsp)
andq $0x0, 0x28(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
subq $0x1, %r14
jb 0x11a5a3
cmpb $0x0, 0x28(%rbp)
js 0x11a59d
movq %r13, %rdi
movq %rbp, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x11a17c
addq $0x30, %rbp
jmp 0x11a580
incl %r12d
jmp 0x11a531
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 0x88a31
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 0x90b09