// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: renew_kv_u_trans(kv_u_trans_t*, hc_links*, kvec_pe_hit*, kv_u_trans_t*, ha_ug_index*, bubble_type*, signed char*, mc_gg_status*, unsigned int)
void renew_kv_u_trans(kv_u_trans_t *ta, hc_links *lk, kvec_pe_hit* hits, kv_u_trans_t *ref,
ha_ug_index* idx, bubble_type* bub, int8_t *s, mc_gg_status *sa, uint32_t ignore_dis)
{   
    uint64_t k, i, m, is_comples_weight = 0;
    trans_idx dis;
    kv_init(dis);
    if(bub->round_id > 0 && ignore_dis == 0)
    {
        is_comples_weight = get_trans_rate_function_advance(idx, hits, lk, bub, NULL, s, sa, &dis);
    }

    for (i = 0; i < lk->a.n; i++)
    {
        for (k = m = 0; k < lk->a.a[i].e.n; k++)
        {
            if(lk->a.a[i].e.a[k].del) continue;
            lk->a.a[i].e.a[m] = lk->a.a[i].e.a[k];
            lk->a.a[i].e.a[m].weight = 0;
            lk->a.a[i].e.a[m].occ = 0;
            m++;
        }
        lk->a.a[i].e.n = m;
    }

    if(hits->idx.n == 0) idx_hc_links(hits, idx, bub);

    weight_kv_u_trans(idx, hits, lk, bub, ta, is_comples_weight == 1? &dis : NULL, asm_opt.flag&HA_F_USKEW?0:1);
    // if(bub->round_id == bub->n_round-1)
    // {
    //     print_debug_hc_links(idx, bub, lk, ta, hits);
    // }
    // adjust_weight_kv_u_trans(idx, hits, lk, bub, ta, ref, is_comples_weight == 1? &dis : NULL);
    adjust_weight_kv_u_trans_advance(idx, hits, lk, bub, ta, ref, is_comples_weight == 1? &dis : NULL);
    kv_destroy(dis);
    // print_kv_weight(ta);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %r14
movq %r8, %r12
movq %rcx, 0x18(%rsp)
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
xorps %xmm0, %xmm0
andq $0x0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
xorl %ebx, %ebx
cmpl $0x0, 0x90(%rsp)
jne 0x11921f
cmpl $0x0, 0x8(%r14)
je 0x11921f
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %r9
leaq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq %rax, (%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x10aa3d
movl %eax, %ebx
xorl %eax, %eax
cmpq (%r13), %rax
jae 0x119298
movq 0x10(%r13), %r8
imulq $0x30, %rax, %rcx
xorl %edx, %edx
xorl %edi, %edi
xorl %esi, %esi
leaq (%r8,%rcx), %r9
cmpq (%r8,%rcx), %rdi
jae 0x119290
movq 0x10(%r9), %r9
cmpb $0x0, 0x18(%r9,%rdx)
js 0x119287
leaq (%r9,%rdx), %r8
imulq $0x28, %rsi, %r10
movq 0x20(%r8), %r11
movq %r11, 0x20(%r9,%r10)
movups (%r8), %xmm0
movups 0x10(%r8), %xmm1
movups %xmm1, 0x10(%r9,%r10)
movups %xmm0, (%r9,%r10)
movq 0x10(%r13), %r8
movq 0x10(%r8,%rcx), %r9
andq $0x0, (%r9,%r10)
andq $0x0, 0x20(%r9,%r10)
incq %rsi
incq %rdi
addq $0x28, %rdx
jmp 0x119235
movq %rsi, (%r9)
incq %rax
jmp 0x119221
cmpq $0x0, 0x18(%rbp)
jne 0x1192ad
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xfdcd5
xorl %r15d, %r15d
testb %bl, %bl
leaq 0x20(%rsp), %rax
cmovneq %rax, %r15
leaq 0x13a496(%rip), %rax    # 0x253758
xorl %ecx, %ecx
btl $0xd, (%rax)
setae %cl
movl %ecx, (%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %r14, %rbx
movq %r12, %r14
movq 0x10(%rsp), %r12
movq %r12, %r8
movq %r15, %r9
callq 0x117866
movq %r15, (%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq 0x18(%rsp), %r9
callq 0x118ced
leaq 0x20(%rsp), %rax
movq (%rax), %rdi
callq 0x2220
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq