// File: /workspace/github_cpp_makefile_star2_O1/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 0x1aac9
cmpl $0x0, 0x8(%r14)
je 0x1aac9
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 0x14b663
movl %eax, %ebx
cmpq $0x0, (%r13)
je 0x1ab5f
xorl %eax, %eax
movq 0x10(%r13), %r8
imulq $0x30, %rax, %rcx
cmpq $0x0, (%r8,%rcx)
je 0x1ab4a
xorl %esi, %esi
xorl %edx, %edx
xorl %edi, %edi
movq 0x10(%r8,%rcx), %r8
cmpb $0x0, 0x18(%r8,%rsi)
js 0x1ab34
leaq (%r8,%rsi), %r9
imulq $0x28, %rdx, %r10
movq 0x20(%r9), %r11
movq %r11, 0x20(%r8,%r10)
movups (%r9), %xmm0
movups 0x10(%r9), %xmm1
movups %xmm1, 0x10(%r8,%r10)
movups %xmm0, (%r8,%r10)
movq 0x10(%r13), %r8
movq 0x10(%r8,%rcx), %r8
andq $0x0, (%r8,%r10)
andq $0x0, 0x20(%r8,%r10)
incq %rdx
incq %rdi
movq 0x10(%r13), %r8
addq $0x28, %rsi
cmpq (%r8,%rcx), %rdi
jb 0x1aaeb
addq %rcx, %r8
jmp 0x1ab4f
addq %rcx, %r8
xorl %edx, %edx
movq %rdx, (%r8)
incq %rax
cmpq (%r13), %rax
jb 0x1aad6
cmpq $0x0, 0x18(%rbp)
jne 0x1ab74
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x13f81d
xorl %r15d, %r15d
testb %bl, %bl
leaq 0x20(%rsp), %rax
cmovneq %rax, %r15
leaq 0x26fbcf(%rip), %rax    # 0x28a758
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 0x157380
movq %r15, (%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq %r12, %r8
movq 0x18(%rsp), %r9
callq 0x1a565
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