// File: /workspace/github_cpp_makefile_star2_O3/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, 0x10(%rsp)
movq %rdi, %r13
movl $0x1, %edi
movl $0x38, %esi
callq 0x2120
movq %rax, %rbx
callq 0xa0485
movq %rax, %r12
movq %rax, 0x18(%rbx)
movq 0x8(%r13), %rbp
movq %rbp, 0x8(%rbx)
movq %rbp, (%rbx)
movl $0x28, %esi
movq %rbp, %rdi
callq 0x2120
movq %rbx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movq %rax, 0x10(%rbx)
testq %rbp, %rbp
je 0x2224c9
movq (%r13), %rdi
xorl %ebp, %ebp
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x80000000, %r14d      # imm = 0x80000000
movq %r13, (%rsp)
imulq $0x78, %rbp, %r15
movl 0x8(%rdi,%r15), %edx
movzbl 0x70(%rdi,%r15), %ecx
movq %r12, %rdi
movl %ebp, %esi
callq 0xa0887
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq (%r13), %rdi
movq %r15, 0x30(%rsp)
movl (%rdi,%r15), %ecx
movb 0x4(%rax,%rcx,8), %al
movq 0x20(%r12), %rcx
movb %al, 0x4(%rcx,%rbp,8)
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
imulq $0x78, %rax, %rax
movl 0x10(%rdi,%rax), %r13d
testq %r13, %r13
movq %rbp, 0x8(%rsp)
je 0x222328
movq %rax, 0x28(%rsp)
movq 0x20(%rdi,%rax), %r15
shlq $0x5, %r13
xorl %ebp, %ebp
cmpl $0x0, 0xc(%r15,%rbp)
js 0x22230a
movl 0x4(%r12), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl (%r12), %ecx
jne 0x2222b6
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
movl $0x10, %ecx
cmovel %ecx, %eax
movl %eax, (%r12)
movq 0x8(%r12), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq %rax, 0x8(%r12)
movl 0x4(%r12), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0x2222bb
movq 0x8(%r12), %rax
leal 0x1(%rdx), %esi
andl %ebx, %esi
andl %r14d, %edx
orl %esi, %edx
movl %edx, 0x4(%r12)
movl %ecx, %ecx
leaq (%rcx,%rcx,2), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rcx,8)
movq $0x0, 0x10(%rax,%rcx,8)
movq (%r15,%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x8(%r15,%rbp), %edx
movl %edx, 0x8(%rax,%rcx,8)
movl 0xc(%r15,%rbp), %edx
andl %ebx, %edx
movl %edx, 0xc(%rax,%rcx,8)
movl 0xc(%r15,%rbp), %esi
andl %r14d, %esi
orl %edx, %esi
movl %esi, 0xc(%rax,%rcx,8)
addq $0x20, %rbp
cmpq %rbp, %r13
jne 0x222260
movq (%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rsp), %rbp
movq 0x28(%rsp), %rax
movl 0x28(%rdi,%rax), %r13d
testq %r13, %r13
je 0x222404
movq 0x38(%rdi,%rax), %r15
shlq $0x5, %r13
xorl %ebp, %ebp
cmpl $0x0, 0xc(%r15,%rbp)
js 0x2223eb
movl 0x4(%r12), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl (%r12), %ecx
jne 0x222397
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
movl $0x10, %ecx
cmovel %ecx, %eax
movl %eax, (%r12)
movq 0x8(%r12), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq %rax, 0x8(%r12)
movl 0x4(%r12), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0x22239c
movq 0x8(%r12), %rax
leal 0x1(%rdx), %esi
andl %ebx, %esi
andl %r14d, %edx
orl %esi, %edx
movl %edx, 0x4(%r12)
movl %ecx, %ecx
leaq (%rcx,%rcx,2), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rcx,8)
movq $0x0, 0x10(%rax,%rcx,8)
movq (%r15,%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x8(%r15,%rbp), %edx
movl %edx, 0x8(%rax,%rcx,8)
movl 0xc(%r15,%rbp), %edx
andl %ebx, %edx
movl %edx, 0xc(%rax,%rcx,8)
movl 0xc(%r15,%rbp), %esi
andl %r14d, %esi
orl %edx, %esi
movl %esi, 0xc(%rax,%rcx,8)
addq $0x20, %rbp
cmpq %rbp, %r13
jne 0x222341
movq (%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rsp), %rbp
leaq (,%rbp,4), %rax
addq %rbp, %rax
movq 0x20(%rsp), %rsi
leaq (%rsi,%rax,8), %r13
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x30(%rsp), %rdx
movl (%rdi,%rdx), %edx
leaq (%rdx,%rdx,4), %rdx
leaq (%rcx,%rdx,8), %rbp
movq 0x10(%rbp), %rcx
movq %rcx, 0x10(%rsi,%rax,8)
movups (%rbp), %xmm0
movups %xmm0, (%rsi,%rax,8)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rsi,%rax,8)
cmpq $0x0, 0x18(%rbp)
je 0x22247b
movq %rdi, %r15
movl 0xc(%r13), %edi
shlq $0x3, %rdi
callq 0x2280
movq %rax, 0x18(%r13)
movq 0x18(%rbp), %rsi
movl 0x10(%rbp), %edx
shlq $0x3, %rdx
movq %rax, %rdi
callq 0x2160
movq %r15, %rdi
cmpq $0x0, 0x20(%rbp)
je 0x2224b4
movq %rdi, %r15
movl (%r13), %edi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rdi
callq 0x2280
movq %rax, 0x20(%r13)
movq 0x20(%rbp), %rsi
movl (%rbp), %edx
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, %rdx
movq %rax, %rdi
callq 0x2160
movq %r15, %rdi
movq 0x8(%rsp), %rbp
incl %ebp
movq (%rsp), %r13
cmpq %rbp, 0x8(%r13)
ja 0x2221f2
movq %r12, %rdi
callq 0xa0a7d
movq 0x18(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq