// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0x2120
movq %rax, %r12
movq %r14, 0x18(%rsp)
movq 0x8(%r14), %r13
movq %rbx, 0x20(%rsp)
movq 0x8(%rbx), %r14
leaq (%r14,%r13), %rdi
movq %rdi, 0x10(%rax)
movq %rdi, 0x8(%rax)
pushq $0x58
popq %rsi
callq 0x2120
movq %rax, %r15
movq %r12, 0x10(%rsp)
movq %rax, (%r12)
pushq $0x38
popq %rbx
movq %r13, 0x8(%rsp)
subq $0x1, %r13
jb 0xa25e2
leaq (%r15,%rbx), %rdi
addq $-0x38, %rdi
movq 0x18(%rsp), %rax
movq (%rax), %r12
leaq -0x38(%r12,%rbx), %rsi
pushq $0xb
popq %rcx
rep  movsq (%rsi), %es:(%rdi)
andq $0x0, -0x28(%r15,%rbx)
movq -0x30(%r15,%rbx), %rbp
testq %rbp, %rbp
je 0xa257a
movq %rbp, %rdi
callq 0x2280
movq %rax, -0x28(%r15,%rbx)
movq -0x28(%r12,%rbx), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x2160
andq $0x0, -0x8(%r15,%rbx)
movq -0x10(%r15,%rbx), %rax
testq %rax, %rax
je 0xa25ab
imulq $0x24, %rax, %rbp
movq %rbp, %rdi
callq 0x2280
movq %rax, -0x8(%r15,%rbx)
movq -0x8(%r12,%rbx), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x2160
andq $0x0, (%r15,%rbx)
movq 0x10(%r15,%rbx), %rbp
testq %rbp, %rbp
je 0xa25d9
shlq $0x2, %rbp
movq %rbp, %rdi
callq 0x2280
movq %rax, (%r15,%rbx)
movq (%r12,%rbx), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x2160
addq $0x58, %rbx
jmp 0xa2528
imulq $0x58, 0x8(%rsp), %rax
addq %rax, %r15
pushq $0x38
popq %rbp
subq $0x1, %r14
jb 0xa26ad
leaq (%r15,%rbp), %rax
addq $-0x38, %rax
movq 0x20(%rsp), %rcx
movq (%rcx), %rbx
leaq -0x38(%rbx,%rbp), %rsi
pushq $0xb
popq %rcx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
andq $0x0, 0x10(%rax)
movq 0x8(%rax), %r13
testq %r13, %r13
je 0xa2645
leaq (%r15,%rbp), %r12
movq %r13, %rdi
callq 0x2280
movq %rax, -0x28(%r12)
movq -0x28(%rbx,%rbp), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x2160
andq $0x0, -0x8(%r15,%rbp)
movq -0x10(%r15,%rbp), %rax
testq %rax, %rax
je 0xa2676
imulq $0x24, %rax, %r13
movq %r13, %rdi
callq 0x2280
movq %rax, -0x8(%r15,%rbp)
movq -0x8(%rbx,%rbp), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x2160
andq $0x0, (%r15,%rbp)
movq 0x10(%r15,%rbp), %r13
testq %r13, %r13
je 0xa26a4
shlq $0x2, %r13
movq %r13, %rdi
callq 0x2280
movq %rax, (%r15,%rbp)
movq (%rbx,%rbp), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x2160
addq $0x58, %rbp
jmp 0xa25ee
movq 0x10(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq