// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: copy_untig_graph(ma_ug_t*)
ma_ug_t* copy_untig_graph(ma_ug_t *src)
{
    ma_ug_t *ug = NULL;
    ug = (ma_ug_t*)calloc(1, sizeof(ma_ug_t));
    ug->g = asg_init();
    uint32_t v;

    ug->g->n_F_seq = src->g->n_F_seq;
    ug->g->r_seq = src->g->r_seq;
    ug->g->m_seq = ug->g->n_seq = src->g->n_seq;
    ug->g->seq = (asg_seq_t*)malloc(ug->g->n_seq * sizeof(asg_seq_t));
    memcpy(ug->g->seq, src->g->seq, sizeof(asg_seq_t)*ug->g->n_seq);

    ug->g->m_arc = ug->g->n_arc = src->g->n_arc;
    ug->g->arc = (asg_arc_t*)malloc(ug->g->n_arc*sizeof(asg_arc_t));
    memcpy(ug->g->arc, src->g->arc, sizeof(asg_arc_t)*ug->g->n_arc);

    ug->g->is_srt = src->g->is_srt;
    ug->g->is_symm = src->g->is_symm;
    ug->g->idx = (uint64_t*)malloc(ug->g->n_seq*2*8);
    memcpy(ug->g->idx, src->g->idx, ug->g->n_seq*2*8); 
    asg_cleanup(ug->g);



    ug->u.m = ug->u.n = src->u.n;
    ug->u.a = (ma_utg_t*)malloc(sizeof(ma_utg_t)*ug->u.n);

    ma_utg_t *src_u = NULL, *ug_u = NULL;
    for (v = 0; v < ug->u.n; v++)
    {
        src_u = &(src->u.a[v]);
        ug_u = &(ug->u.a[v]);
        (*ug_u) = (*src_u);
        ug_u->s = NULL;
        ug_u->a = NULL;
        ug_u->m = ug_u->n = src_u->n;

        ug_u->a = (uint64_t*)malloc(8 * ug_u->n);
        memcpy(ug_u->a, src_u->a, 8*ug_u->n);
    }

    /**
    if(cmp_untig_graph(src, ug)) fprintf(stderr, "ERROR\n");
    ma_ug_destroy(ug);
    return NULL;
    **/
    return ug;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movl $0x1, %edi
movl $0x38, %esi
callq 0x2140
movq %rax, -0x10(%rbp)
callq 0xcd150
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x38(%rax), %ecx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x18(%rax), %ecx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %ecx, %edx
movl %edx, 0x14(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
shlq $0x3, %rdx
callq 0x2180
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %ecx, %edx
movl %edx, 0x4(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
imulq $0x18, %rax, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
imulq $0x18, %rax, %rdx
callq 0x2180
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %edx
shrl $0x1f, %edx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %edx
shrl $0x1f, %edx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
shll $0x3, %eax
movslq %eax, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
shll $0x3, %eax
movslq %eax, %rdx
callq 0x2180
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xcdd10
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
imulq $0x28, (%rax), %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x10bdd1
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdi
movl $0x28, %edx
callq 0x2180
movq -0x28(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
shll $0x3, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x2270
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
shll $0x3, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x2180
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x10bd07
movq -0x10(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)