// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq %rdi, 0x8(%rsp)
pushq $0x1
popq %rdi
pushq $0x38
popq %rsi
callq 0x2120
movq %rax, %rbx
movq %rax, (%rsp)
callq 0x68f5d
movq %rax, %r15
movq %rax, 0x18(%rbx)
movq 0x18(%r14), %r14
movl 0x38(%r14), %eax
movl %eax, 0x38(%r15)
movl 0x18(%r14), %eax
movl %eax, 0x18(%r15)
movl 0x14(%r14), %r13d
movq %r13, 0x10(%rsp)
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %r13
movl $0x80000000, %r12d      # imm = 0x80000000
movl 0x14(%r15), %eax
andl %r12d, %eax
orl %r13d, %eax
movl %eax, 0x14(%r15)
movl %r13d, 0x10(%r15)
movq %r13, %rbp
shlq $0x3, %rbp
movq %rbp, %rdi
callq 0x2280
movq %rax, 0x20(%r15)
movq 0x20(%r14), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x2160
movl 0x4(%r14), %ebp
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rbp
movl 0x4(%r15), %eax
andl %r12d, %eax
orl %ebp, %eax
movl %eax, 0x4(%r15)
movl %ebp, (%r15)
imulq $0x18, %rbp, %rbx
movq %rbx, %rdi
callq 0x2280
movq %rax, 0x8(%r15)
movq 0x8(%r14), %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0x2160
movl 0x4(%r14), %eax
andl %r12d, %eax
orl %ebp, %eax
movl %eax, 0x4(%r15)
andl 0x14(%r14), %r12d
orl %r13d, %r12d
movl %r12d, 0x14(%r15)
shll $0x4, %r13d
movq %r13, %rdi
callq 0x2280
movq %rax, 0x28(%r15)
movq 0x28(%r14), %rsi
movq 0x10(%rsp), %rdx
shll $0x4, %edx
movq %rax, %rdi
callq 0x2160
movq %r15, %rdi
callq 0x694eb
movq 0x8(%rsp), %rax
movq (%rax), %r14
movq (%rsp), %rbx
movq %r14, (%rbx)
movq %r14, 0x8(%rbx)
imulq $0x28, %r14, %rdi
callq 0x2280
movq %rax, %r15
movq %rax, 0x10(%rbx)
xorl %eax, %eax
movl %eax, %r13d
cmpq %r13, %r14
jbe 0x8cb39
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rbp
imulq $0x28, %r13, %rbx
movq 0x10(%rbp,%rbx), %rax
movq %rax, 0x10(%r15,%rbx)
movups (%rbp,%rbx), %xmm0
movups %xmm0, (%r15,%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r15,%rbx)
movl 0x10(%rbp,%rbx), %r12d
movl %r12d, 0x10(%r15,%rbx)
movl %r12d, 0xc(%r15,%rbx)
shll $0x3, %r12d
movq %r12, %rdi
callq 0x2280
movq %rax, 0x18(%r15,%rbx)
movq 0x18(%rbp,%rbx), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x2160
leal 0x1(%r13), %eax
jmp 0x8cad1
movq (%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq