// File: /workspace/github_cpp_makefile_star2_O1/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 %r14, 0x8(%rsp)
movq 0x8(%r14), %rdi
addq 0x8(%r12), %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 0x8(%r12), %r15
testq %r15, %r15
je 0xdeb25
movq (%r12), %rbp
movl $0x38, %ebx
movq %r15, %r13
leaq (%r14,%rbx), %rdi
addq $-0x38, %rdi
leaq -0x38(%rbp,%rbx), %rsi
movl $0xb, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq $0x0, -0x28(%r14,%rbx)
movq -0x30(%r14,%rbx), %r12
testq %r12, %r12
je 0xdeaae
movq %r12, %rdi
callq 0x2280
movq %rax, -0x28(%r14,%rbx)
movq -0x28(%rbp,%rbx), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x2160
movq $0x0, -0x8(%r14,%rbx)
movq -0x10(%r14,%rbx), %rax
testq %rax, %rax
je 0xdeae6
shlq $0x2, %rax
leaq (%rax,%rax,8), %r12
movq %r12, %rdi
callq 0x2280
movq %rax, -0x8(%r14,%rbx)
movq -0x8(%rbp,%rbx), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x2160
movq $0x0, (%r14,%rbx)
movq 0x10(%r14,%rbx), %r12
testq %r12, %r12
je 0xdeb18
shlq $0x2, %r12
movq %r12, %rdi
callq 0x2280
movq %rax, (%r14,%rbx)
movq (%rbp,%rbx), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x2160
addq $0x58, %rbx
decq %r13
jne 0xdea69
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %r12
testq %r12, %r12
je 0xdec03
imulq $0x58, %r15, %rax
addq %rax, %r14
movq (%rcx), %r13
movl $0x38, %ebx
leaq (%r14,%rbx), %rax
addq $-0x38, %rax
leaq -0x38(%r13,%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 0xdeb8c
movq %r15, %rdi
callq 0x2280
movq %rax, -0x28(%r14,%rbx)
movq -0x28(%r13,%rbx), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2160
movq $0x0, -0x8(%r14,%rbx)
movq -0x10(%r14,%rbx), %rax
testq %rax, %rax
je 0xdebc4
shlq $0x2, %rax
leaq (%rax,%rax,8), %r15
movq %r15, %rdi
callq 0x2280
movq %rax, -0x8(%r14,%rbx)
movq -0x8(%r13,%rbx), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2160
movq $0x0, (%r14,%rbx)
movq 0x10(%r14,%rbx), %r15
testq %r15, %r15
je 0xdebf6
shlq $0x2, %r15
movq %r15, %rdi
callq 0x2280
movq %rax, (%r14,%rbx)
movq (%r13,%rbx), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2160
addq $0x58, %rbx
decq %r12
jne 0xdeb46
movq 0x10(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq