// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: merge_scaf_res(scaf_res_t*, scaf_res_t*)
scaf_res_t *merge_scaf_res(scaf_res_t *in0, scaf_res_t *in1)
{
    uint64_t k; ul_vec_t *m; ul_vec_t *s;
    scaf_res_t *p = NULL; CALLOC(p, 1);
    p->n = p->m = in0->n + in1->n; 
    CALLOC(p->a, p->n);
    for(k = 0; k < in0->n; k++) {
        m = &(p->a[k]); s = &(in0->a[k]);
        *m = *s;

        m->r_base.a = NULL; 
        if(m->r_base.m) {
            MALLOC(m->r_base.a, m->r_base.m);
            memcpy(m->r_base.a, s->r_base.a, sizeof((*(m->r_base.a)))*m->r_base.m);
        }

        m->bb.a = NULL; 
        if(m->bb.m) {
            MALLOC(m->bb.a, m->bb.m);
            memcpy(m->bb.a, s->bb.a, sizeof((*(m->bb.a)))*m->bb.m);
        }

        m->N_site.a = NULL; 
        if(m->N_site.m) {
            MALLOC(m->N_site.a, m->N_site.m);
            memcpy(m->N_site.a, s->N_site.a, sizeof((*(m->N_site.a)))*m->N_site.m);
        }
    }

    for(k = 0; k < in1->n; k++) {
        m = &(p->a[k + in0->n]); s = &(in1->a[k]);
        *m = *s;

        m->r_base.a = NULL; 
        if(m->r_base.m) {
            MALLOC(m->r_base.a, m->r_base.m);
            memcpy(m->r_base.a, s->r_base.a, sizeof((*(m->r_base.a)))*m->r_base.m);
        }

        m->bb.a = NULL; 
        if(m->bb.m) {
            MALLOC(m->bb.a, m->bb.m);
            memcpy(m->bb.a, s->bb.a, sizeof((*(m->bb.a)))*m->bb.m);
        }

        m->N_site.a = NULL; 
        if(m->N_site.m) {
            MALLOC(m->N_site.a, m->N_site.m);
            memcpy(m->N_site.a, s->N_site.a, sizeof((*(m->N_site.a)))*m->N_site.m);
        }
    }

    return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %r12
movl $0x1, %edi
movl $0x20, %esi
callq 0x2120
movq %rax, %rbx
movq 0x8(%r12), %r15
movq %r14, 0x8(%rsp)
movq 0x8(%r14), %r13
leaq (%r13,%r15), %rdi
movq %rdi, 0x10(%rax)
movq %rdi, 0x8(%rax)
movl $0x58, %esi
callq 0x2120
movq %rax, %r14
movq %rbx, 0x10(%rsp)
movq %rax, (%rbx)
movq %r15, (%rsp)
testq %r15, %r15
je 0xdfe94
movq (%r12), %r15
movl $0x38, %ebx
movq (%rsp), %rbp
leaq (%r14,%rbx), %rdi
addq $-0x38, %rdi
leaq -0x38(%r15,%rbx), %rsi
movl $0xb, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq $0x0, -0x28(%r14,%rbx)
movq -0x30(%r14,%rbx), %r12
testq %r12, %r12
je 0xdfe1e
movq %r12, %rdi
callq 0x2280
movq %rax, -0x28(%r14,%rbx)
movq -0x28(%r15,%rbx), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x2160
movq $0x0, -0x8(%r14,%rbx)
movq -0x10(%r14,%rbx), %rax
testq %rax, %rax
je 0xdfe56
shlq $0x2, %rax
leaq (%rax,%rax,8), %r12
movq %r12, %rdi
callq 0x2280
movq %rax, -0x8(%r14,%rbx)
movq -0x8(%r15,%rbx), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x2160
movq $0x0, (%r14,%rbx)
movq 0x10(%r14,%rbx), %r12
testq %r12, %r12
je 0xdfe87
shlq $0x2, %r12
movq %r12, %rdi
callq 0x2280
movq %rax, (%r14,%rbx)
movq (%r15,%rbx), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x2160
addq $0x58, %rbx
decq %rbp
jne 0xdfdd9
testq %r13, %r13
je 0xdff6e
imulq $0x58, (%rsp), %rax
addq %rax, %r14
movq 0x8(%rsp), %rax
movq (%rax), %r12
movl $0x38, %ebx
leaq (%r14,%rbx), %rax
addq $-0x38, %rax
leaq -0x38(%r12,%rbx), %rsi
movl $0xb, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq $0x0, 0x10(%rax)
movq 0x8(%rax), %r15
testq %r15, %r15
je 0xdfef8
movq %r15, %rdi
callq 0x2280
movq %rax, -0x28(%r14,%rbx)
movq -0x28(%r12,%rbx), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2160
movq $0x0, -0x8(%r14,%rbx)
movq -0x10(%r14,%rbx), %rax
testq %rax, %rax
je 0xdff30
shlq $0x2, %rax
leaq (%rax,%rax,8), %r15
movq %r15, %rdi
callq 0x2280
movq %rax, -0x8(%r14,%rbx)
movq -0x8(%r12,%rbx), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2160
movq $0x0, (%r14,%rbx)
movq 0x10(%r14,%rbx), %r15
testq %r15, %r15
je 0xdff61
shlq $0x2, %r15
movq %r15, %rdi
callq 0x2280
movq %rax, (%r14,%rbx)
movq (%r12,%rbx), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2160
addq $0x58, %rbx
decq %r13
jne 0xdfeb2
movq 0x10(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq