// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: convert_usg_t(usg_t*, ma_ug_t*)
ma_ug_t *convert_usg_t(usg_t *ng, ma_ug_t *ref)
{
    ma_ug_t *ug = NULL; uint32_t k, nv, z; usg_arc_t *av; asg_arc_t *p;
    ma_utg_t *des, *src;
    CALLOC(ug, 1); ug->g = asg_init(); 
    ug->u.n = ug->u.m = ng->n; CALLOC(ug->u.a, ug->u.n);
    for (k = 0; k < ng->n; k++) {
        asg_seq_set(ug->g, k, ng->a[k].len, ng->a[k].del);
        ug->g->seq[k].c = ref->g->seq[ng->a[k].mm].c;

        av = usg_arc_a(ng, (k<<1)); nv = usg_arc_n(ng, (k<<1));
        for (z = 0; z < nv; z++) {
            if(av[z].del) continue;
            p = asg_arc_pushp(ug->g); memset(p, 0, sizeof((*p)));
            p->ul = av[z].ul; p->v = av[z].v; p->ol = av[z].ol; p->del = av[z].del;
        }

        av = usg_arc_a(ng, (k<<1)+1); nv = usg_arc_n(ng, (k<<1)+1);
        for (z = 0; z < nv; z++) {
            if(av[z].del) continue;
            p = asg_arc_pushp(ug->g); memset(p, 0, sizeof((*p)));
            p->ul = av[z].ul; p->v = av[z].v; p->ol = av[z].ol; p->del = av[z].del;
        }

        des = &(ug->u.a[k]); src = &(ref->u.a[ng->a[k].mm]);
        (*des) = (*src); des->a = NULL; des->s = NULL;
        if(src->a) {
            MALLOC(des->a, des->m); 
            memcpy(des->a, src->a, src->n*sizeof((*(src->a))));
        }

        if(src->s) {
            MALLOC(des->s, des->len);
            memcpy(des->s, src->s, src->len*sizeof((*(src->s))));
        }
    }

    asg_cleanup(ug->g);
    return ug;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbp
movq %rdi, %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x2120
movq %rax, %r14
callq 0x9fccc
movq %rax, %r12
movq %rax, 0x18(%r14)
movq 0x8(%rbx), %rdi
movq %rdi, 0x8(%r14)
movq %rdi, (%r14)
movl $0x28, %esi
callq 0x2120
movq %r14, 0x18(%rsp)
movq %rax, 0x28(%rsp)
movq %rax, 0x10(%r14)
cmpq $0x0, 0x8(%rbx)
je 0x21712b
xorl %r13d, %r13d
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl $0x80000000, %r14d      # imm = 0x80000000
movq %rbp, 0x20(%rsp)
movq %rbx, (%rsp)
movq (%rbx), %rax
movq %rbp, %rbx
imulq $0x78, %r13, %rbp
movl 0x8(%rax,%rbp), %edx
movzbl 0x70(%rax,%rbp), %ecx
movq %r12, %rdi
movl %r13d, %esi
callq 0xa0115
movq 0x18(%rbx), %rax
movq 0x20(%rax), %rcx
movq (%rsp), %rax
movq (%rax), %rax
movq %rbp, 0x30(%rsp)
movl (%rax,%rbp), %edx
movb 0x4(%rcx,%rdx,8), %cl
movq 0x20(%r12), %rdx
movb %cl, 0x4(%rdx,%r13,8)
movq %r13, 0x10(%rsp)
movl %r13d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
imulq $0x78, %rcx, %rcx
movq %rcx, 0x8(%rsp)
movl 0x10(%rax,%rcx), %r13d
testq %r13, %r13
je 0x216f86
movq 0x8(%rsp), %rcx
movq 0x20(%rax,%rcx), %rbx
shlq $0x5, %r13
xorl %ebp, %ebp
cmpl $0x0, 0xc(%rbx,%rbp)
js 0x216f79
movl 0x4(%r12), %ecx
andl %r15d, %ecx
movl (%r12), %eax
cmpl %eax, %ecx
jne 0x216f12
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, (%r12)
movq 0x8(%r12), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x8(%r12)
movq 0x8(%r12), %rax
movl 0x4(%r12), %ecx
movl %ecx, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leal 0x1(%rcx), %esi
andl %r15d, %esi
andl %r14d, %ecx
orl %esi, %ecx
movl %ecx, 0x4(%r12)
leaq (%rdx,%rdx,2), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rcx,8)
movq $0x0, 0x10(%rax,%rcx,8)
movq (%rbx,%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x8(%rbx,%rbp), %edx
movl %edx, 0x8(%rax,%rcx,8)
movl 0xc(%rbx,%rbp), %edx
andl %r15d, %edx
movl 0xc(%rax,%rcx,8), %esi
andl %r14d, %esi
orl %edx, %esi
movl %esi, 0xc(%rax,%rcx,8)
movl 0xc(%rbx,%rbp), %esi
andl %r14d, %esi
orl %edx, %esi
movl %esi, 0xc(%rax,%rcx,8)
addq $0x20, %rbp
cmpq %rbp, %r13
jne 0x216ecf
movq (%rsp), %rax
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movl 0x28(%rax,%rcx), %r13d
testq %r13, %r13
je 0x217062
movq 0x38(%rax,%rcx), %rbx
shlq $0x5, %r13
xorl %ebp, %ebp
cmpl $0x0, 0xc(%rbx,%rbp)
js 0x217055
movl 0x4(%r12), %ecx
andl %r15d, %ecx
movl (%r12), %eax
cmpl %eax, %ecx
jne 0x216fee
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, (%r12)
movq 0x8(%r12), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x8(%r12)
movq 0x8(%r12), %rax
movl 0x4(%r12), %ecx
movl %ecx, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leal 0x1(%rcx), %esi
andl %r15d, %esi
andl %r14d, %ecx
orl %esi, %ecx
movl %ecx, 0x4(%r12)
leaq (%rdx,%rdx,2), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rcx,8)
movq $0x0, 0x10(%rax,%rcx,8)
movq (%rbx,%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x8(%rbx,%rbp), %edx
movl %edx, 0x8(%rax,%rcx,8)
movl 0xc(%rbx,%rbp), %edx
andl %r15d, %edx
movl 0xc(%rax,%rcx,8), %esi
andl %r14d, %esi
orl %edx, %esi
movl %esi, 0xc(%rax,%rcx,8)
movl 0xc(%rbx,%rbp), %esi
andl %r14d, %esi
orl %edx, %esi
movl %esi, 0xc(%rax,%rcx,8)
addq $0x20, %rbp
cmpq %rbp, %r13
jne 0x216fab
movq 0x10(%rsp), %rax
leaq (%rax,%rax,4), %rax
movq 0x28(%rsp), %rsi
leaq (%rsi,%rax,8), %rbx
movq 0x20(%rsp), %rbp
movq 0x10(%rbp), %rcx
movq (%rsp), %rdx
movq (%rdx), %rdx
movq 0x30(%rsp), %rdi
movl (%rdx,%rdi), %edx
leaq (%rdx,%rdx,4), %rdx
leaq (%rcx,%rdx,8), %r13
movq 0x20(%r13), %rcx
movq %rcx, 0x20(%rsi,%rax,8)
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups %xmm1, 0x10(%rsi,%rax,8)
movups %xmm0, (%rsi,%rax,8)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rsi,%rax,8)
cmpq $0x0, 0x18(%r13)
je 0x2170e3
movl 0xc(%rbx), %edi
shlq $0x3, %rdi
callq 0x2280
movq %rax, 0x18(%rbx)
movq 0x18(%r13), %rsi
movl 0x10(%r13), %edx
shlq $0x3, %rdx
movq %rax, %rdi
callq 0x2160
cmpq $0x0, 0x20(%r13)
je 0x217115
movl (%rbx), %edi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rdi
callq 0x2280
movq %rax, 0x20(%rbx)
movq 0x20(%r13), %rsi
movl (%r13), %edx
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, %rdx
movq %rax, %rdi
callq 0x2160
movq 0x10(%rsp), %r13
incl %r13d
movq (%rsp), %rbx
cmpq %r13, 0x8(%rbx)
ja 0x216e57
movq %r12, %rdi
callq 0xa02fa
movq 0x18(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq