// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: remap_gen_arcs(usg_t*, unsigned int, unsigned int, unsigned int, unsigned int)
void remap_gen_arcs(usg_t *g, uint32_t ov, uint32_t ow, uint32_t nv, uint32_t nw)
{
    usg_arc_t *op = NULL, *np = NULL; usg_arc_warp *sv; uint32_t k; usg_arc_mm_t *v_a, *pm; uint32_t v_n;
    sv = &(g->a[nv>>1].arc[nv&1]); kv_pushp(usg_arc_t, *sv, &np);
    op = get_usg_arc(g, ov, ow); assert(op);///must get op ater since op might be changed by kv_pushp

    np->ul = (uint32_t)op->ul; np->ul |= (((uint64_t)nv)<<32); np->v = nw;
    np->ol = op->ol; np->del = 0; np->ou = op->ou; 
    np->idx = g->a[nv>>1].arc_mm[nv&1].n; np->idx <<= 32; np->idx |= (uint32_t)op->idx;

    v_n = (uint32_t)op->idx;
    for (k = 0; k < v_n; k++) {
        kv_pushp(usg_arc_mm_t, g->a[nv>>1].arc_mm[nv&1], &pm);
        v_a = g->a[op->ul>>33].arc_mm[(op->ul>>32)&1].a + (op->idx>>32);//va might be changed
        pm->v = nw; pm->uid = v_a[k].uid; pm->off = v_a[k].off;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movl %esi, %r12d
movq %rdi, %r9
movq (%rdi), %rdi
movl %ecx, %eax
shrl %eax
movl %ecx, %edx
andl $0x1, %edx
imulq $0x78, %rax, %r14
leaq (%rdi,%r14), %rax
movq %rdx, 0x20(%rsp)
leaq (%rdx,%rdx,2), %r13
leaq (%rax,%r13,8), %rbx
addq $0x10, %rbx
movq (%rbx), %rdx
cmpq 0x8(%rbx), %rdx
movl %r8d, 0xc(%rsp)
jne 0x216c23
leaq (%rdx,%rdx), %rax
testq %rdx, %rdx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x5, %rsi
movq %r9, %r15
movq %rcx, 0x10(%rsp)
callq 0x2370
movq 0x10(%rsp), %rcx
movq %r15, %r9
movl 0xc(%rsp), %r8d
movq %rax, 0x10(%rbx)
movq (%rbx), %rdx
movq (%r15), %rdi
jmp 0x216c27
movq 0x10(%rbx), %rax
leaq 0x1(%rdx), %rsi
movq %rsi, (%rbx)
movl %r12d, %esi
shrl %esi
andl $0x1, %r12d
imulq $0x78, %rsi, %rsi
addq %rdi, %rsi
leaq (%r12,%r12,2), %rdi
movl 0x10(%rsi,%rdi,8), %r10d
testq %r10, %r10
je 0x216c68
movq 0x20(%rsi,%rdi,8), %r12
shlq $0x5, %r10
xorl %r15d, %r15d
cmpl %ebp, 0x8(%r12,%r15)
je 0x216c87
addq $0x20, %r15
cmpq %r15, %r10
jne 0x216c58
leaq 0x2142d(%rip), %rdi     # 0x23809c
leaq 0x2e993(%rip), %rsi     # 0x245609
leaq 0x31961(%rip), %rcx     # 0x2485de
movl $0x2d77, %edx           # imm = 0x2D77
callq 0x2110
shlq $0x5, %rdx
movl (%r12,%r15), %esi
shlq $0x20, %rcx
orq %rsi, %rcx
movq %rcx, (%rax,%rdx)
movl %r8d, 0x8(%rax,%rdx)
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl 0xc(%r12,%r15), %ecx
movl %ecx, 0xc(%rax,%rdx)
movl 0x10(%r12,%r15), %ecx
movl %ecx, 0x10(%rax,%rdx)
movq %r9, 0x10(%rsp)
movq (%r9), %rcx
leaq (%rcx,%r14), %rsi
movq 0x40(%rsi,%r13,8), %rsi
movq %rsi, %rdi
shlq $0x20, %rdi
movq %rdi, 0x18(%rax,%rdx)
movl 0x18(%r12,%r15), %r9d
orq %rdi, %r9
movq %r9, 0x18(%rax,%rdx)
movq 0x18(%r12,%r15), %rax
testl %eax, %eax
je 0x216dd3
movl %eax, %edx
shlq $0x2, %rdx
leaq (%rdx,%rdx,2), %rbp
xorl %ebx, %ebx
movq %r13, 0x18(%rsp)
leaq (%rcx,%r14), %rdx
cmpq 0x48(%rdx,%r13,8), %rsi
jne 0x216d72
leaq (%rdx,%r13,8), %rax
addq $0x40, %rax
leaq (%rsi,%rsi), %rcx
testq %rsi, %rsi
movl $0x2, %esi
cmoveq %rsi, %rcx
movq 0x20(%rsp), %rsi
leal (,%rsi,8), %esi
movq %rbp, %r13
leaq (%rsi,%rsi,2), %rbp
movq %rcx, 0x48(%rdx,%rbp)
movq 0x10(%rax), %rdi
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movl 0xc(%rsp), %r8d
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rcx,%r14), %rdx
movq %rax, 0x50(%rdx,%rbp)
movq 0x18(%r12,%r15), %rax
movq 0x40(%rdx,%rbp), %rsi
movq %r13, %rbp
movq 0x18(%rsp), %r13
leaq (%rcx,%r14), %rdx
movq 0x50(%rdx,%r13,8), %rdi
leaq (%rsi,%rsi,2), %r11
incq %rsi
movq %rsi, 0x40(%rdx,%r13,8)
movq (%r12,%r15), %rdx
movq %rdx, %r9
shrq $0x21, %r9
shrq $0x20, %rdx
andl $0x1, %edx
imulq $0x78, %r9, %r9
addq %rcx, %r9
leaq (%rdx,%rdx,2), %rdx
movq %rax, %r10
shrq $0x20, %r10
leaq (%r10,%r10,2), %r10
shlq $0x2, %r10
addq 0x50(%r9,%rdx,8), %r10
movl %r8d, (%rdi,%r11,4)
movq 0x4(%rbx,%r10), %rdx
movq %rdx, 0x4(%rdi,%r11,4)
addq $0xc, %rbx
cmpq %rbx, %rbp
jne 0x216cfe
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq