// File: /workspace/github_cpp_makefile_star2_O3/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 0x1a3b1
cmpl $0x0, 0x8(%r14)
je 0x1a3b1
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 0x151cae
movl %eax, %ebx
movq (%r13), %rdi
testq %rdi, %rdi
je 0x1a443
movq 0x10(%r13), %rcx
xorl %eax, %eax
imulq $0x30, %rax, %rdx
cmpq $0x0, (%rcx,%rdx)
je 0x1a433
xorl %edi, %edi
xorl %esi, %esi
xorl %r8d, %r8d
movq 0x10(%rcx,%rdx), %r9
cmpb $0x0, 0x18(%r9,%rdi)
js 0x1a41d
leaq (%r9,%rdi), %rcx
imulq $0x28, %rsi, %r10
movq 0x20(%rcx), %r11
movq %r11, 0x20(%r9,%r10)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%r9,%r10)
movups %xmm0, (%r9,%r10)
movq 0x10(%r13), %rcx
movq 0x10(%rcx,%rdx), %r9
andq $0x0, (%r9,%r10)
andq $0x0, 0x20(%r9,%r10)
incq %rsi
incq %r8
addq $0x28, %rdi
cmpq (%rcx,%rdx), %r8
jb 0x1a3d6
addq %rcx, %rdx
movq (%r13), %rdi
jmp 0x1a438
addq %rcx, %rdx
xorl %esi, %esi
movq %rsi, (%rdx)
incq %rax
cmpq %rdi, %rax
jb 0x1a3c4
cmpq $0x0, 0x18(%rbp)
jne 0x1a458
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x14547c
xorl %r15d, %r15d
testb %bl, %bl
leaq 0x20(%rsp), %rax
cmovneq %rax, %r15
leaq 0x27b2eb(%rip), %rax    # 0x295758
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 0x15dd50
movq %r15, (%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq 0x18(%rsp), %r9
callq 0x19e3e
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