// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x1
popq %rdi
pushq $0x38
popq %rsi
callq 0x2120
movq %rax, %r14
callq 0x68f5d
movq %rax, %r12
movq %rax, 0x18(%r14)
movq %rbx, (%rsp)
movq 0x8(%rbx), %r15
movq %r15, 0x8(%r14)
movq %r15, (%r14)
pushq $0x28
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %r14, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%r14)
xorl %ecx, %ecx
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x80000000, %r13d      # imm = 0x80000000
movq %rbp, 0x20(%rsp)
movl %ecx, %ecx
cmpq %rcx, %r15
jbe 0x1d3ab2
movq %rcx, %r15
movq (%rsp), %rax
movq (%rax), %rax
movq %rbp, %r14
imulq $0x78, %rcx, %rbp
movl 0x8(%rax,%rbp), %edx
movzbl 0x70(%rax,%rbp), %ecx
movq %r12, %rdi
movl %r15d, %esi
callq 0x69316
movq 0x18(%r14), %rax
movq 0x20(%rax), %rax
movq (%rsp), %rcx
movq (%rcx), %rcx
movq %rbp, 0x30(%rsp)
movl (%rcx,%rbp), %edx
movb 0x4(%rax,%rdx,8), %al
movq 0x20(%r12), %rdx
movb %al, 0x4(%rdx,%r15,8)
movq %r15, 0x8(%rsp)
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
imulq $0x78, %rax, %rax
movq 0x20(%rcx,%rax), %r15
movq %rax, 0x28(%rsp)
movl 0x10(%rcx,%rax), %ebp
shlq $0x5, %rbp
xorl %r14d, %r14d
cmpq %r14, %rbp
je 0x1d398e
cmpl $0x0, 0xc(%r15,%r14)
js 0x1d3988
movq %r12, %rdi
callq 0x1ab555
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq (%r15,%r14), %rcx
movq %rcx, (%rax)
movl 0x8(%r15,%r14), %ecx
movl %ecx, 0x8(%rax)
movl 0xc(%r15,%r14), %ecx
andl %ebx, %ecx
movl %ecx, 0xc(%rax)
movl 0xc(%r15,%r14), %edx
andl %r13d, %edx
orl %ecx, %edx
movl %edx, 0xc(%rax)
addq $0x20, %r14
jmp 0x1d3942
movq (%rsp), %rax
movq (%rax), %rax
movq 0x28(%rsp), %rcx
movq 0x38(%rax,%rcx), %r15
movl 0x28(%rax,%rcx), %r14d
shlq $0x5, %r14
xorl %ebp, %ebp
cmpq %rbp, %r14
je 0x1d39f6
cmpl $0x0, 0xc(%r15,%rbp)
js 0x1d39f0
movq %r12, %rdi
callq 0x1ab555
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq (%r15,%rbp), %rcx
movq %rcx, (%rax)
movl 0x8(%r15,%rbp), %ecx
movl %ecx, 0x8(%rax)
movl 0xc(%r15,%rbp), %ecx
andl %ebx, %ecx
movl %ecx, 0xc(%rax)
movl 0xc(%r15,%rbp), %edx
andl %r13d, %edx
orl %ecx, %edx
movl %edx, 0xc(%rax)
addq $0x20, %rbp
jmp 0x1d39aa
imulq $0x28, 0x8(%rsp), %rax
movq 0x18(%rsp), %rdi
leaq (%rdi,%rax), %r14
movq 0x20(%rsp), %rbp
movq 0x10(%rbp), %rcx
movq (%rsp), %rdx
movq (%rdx), %rdx
movq 0x30(%rsp), %rsi
movl (%rdx,%rsi), %edx
imulq $0x28, %rdx, %rdx
leaq (%rcx,%rdx), %r15
movq 0x10(%rcx,%rdx), %rsi
movq %rsi, 0x10(%rdi,%rax)
movups (%rcx,%rdx), %xmm0
movups %xmm0, (%rdi,%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rdi,%rax)
cmpq $0x0, 0x18(%rcx,%rdx)
je 0x1d3a6c
movl 0xc(%r14), %edi
shlq $0x3, %rdi
callq 0x2280
movq %rax, 0x18(%r14)
movq 0x18(%r15), %rsi
movl 0x10(%r15), %edx
shlq $0x3, %rdx
movq %rax, %rdi
callq 0x2160
cmpq $0x0, 0x20(%r15)
je 0x1d3a9e
movl (%r14), %edi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rdi
callq 0x2280
movq %rax, 0x20(%r14)
movq 0x20(%r15), %rsi
movl (%r15), %edx
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, %rdx
movq %rax, %rdi
callq 0x2160
movq 0x8(%rsp), %rcx
incl %ecx
movq (%rsp), %rax
movq 0x8(%rax), %r15
jmp 0x1d38c7
movq %r12, %rdi
callq 0x694eb
movq 0x10(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq