// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2100
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movq $0x0, -0x70(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x206b9a
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x5c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jne 0x206b00
jmp 0x206b8c
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %eax
movl %eax, %esi
movl $0x30, %edx
leaq -0xaf5(%rip), %rcx      # 0x206020
callq 0x23e0
movq $0x0, -0x50(%rbp)
movq $0x0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jae 0x206b8a
movq -0x70(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movb 0x28(%rax), %al
shrb $0x7, %al
cmpb $0x0, %al
je 0x206b63
jmp 0x206b7f
movq -0x70(%rbp), %rsi
movl -0x60(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rsi
movsd -0x18(%rbp), %xmm0
leaq -0x58(%rbp), %rdi
callq 0x206080
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x206b41
jmp 0x206b8c
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x206aac
movq -0x58(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2210
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 $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)