// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: merge_utgs(ma_ug_t*, ma_ug_t*)
ma_ug_t *merge_utgs(ma_ug_t *in0, ma_ug_t *in1)
{
    uint64_t k, m[2]; ma_utg_t *su = NULL, *du = NULL;
    m[0] = ((uint64_t)(in0->g->n_seq))<<1;
    m[1] = ((uint64_t)(in0->g->n_seq))<<33;
    ma_ug_t *ug = NULL; CALLOC(ug, 1); ug->g = asg_init();
    ug->g->n_F_seq = in0->g->n_F_seq + in1->g->n_F_seq;
    ug->g->r_seq = in0->g->r_seq + in1->g->r_seq;
    ug->g->m_seq = ug->g->n_seq = in0->g->n_seq + in1->g->n_seq;
    MALLOC(ug->g->seq, ug->g->n_seq);
    memcpy(ug->g->seq, in0->g->seq, sizeof((*(ug->g->seq)))*in0->g->n_seq);
    memcpy(ug->g->seq+in0->g->n_seq, in1->g->seq, sizeof((*(ug->g->seq)))*in1->g->n_seq);

    ug->g->m_arc = ug->g->n_arc = in0->g->n_arc + in1->g->n_arc;
    MALLOC(ug->g->arc, ug->g->n_arc);
    memcpy(ug->g->arc, in0->g->arc, sizeof((*(ug->g->arc)))*in0->g->n_arc);
    for(k = 0; k < in1->g->n_arc; k++) {
        ug->g->arc[k+in0->g->n_arc] = in1->g->arc[k];
        ug->g->arc[k+in0->g->n_arc].v += m[0];
        ug->g->arc[k+in0->g->n_arc].ul += m[1];
    }
    asg_cleanup(ug->g); asg_symm(ug->g);

    ug->u.m = ug->u.n = in0->u.n + in1->u.n;
    MALLOC(ug->u.a, ug->u.n);
    for (k = 0; k < in0->u.n; k++) {
        su = &(in0->u.a[k]); du = &(ug->u.a[k]);
        (*du) = (*su);
        du->s = NULL; du->a = NULL; du->m = du->n = su->n;
        MALLOC(du->a, du->n); memcpy(du->a, su->a, sizeof((*(du->a)))*du->n);
    }
    for (k = 0; k < in1->u.n; k++) {
        su = &(in1->u.a[k]); du = &(ug->u.a[k + in0->u.n]);
        (*du) = (*su);
        du->s = NULL; du->a = NULL; du->m = du->n = su->n;
        MALLOC(du->a, du->n); memcpy(du->a, su->a, sizeof((*(du->a)))*du->n);
    }

    return ug;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %r13
movl 0x14(%r13), %ebp
movl $0x1, %edi
movl $0x38, %esi
callq 0x2120
movq %rax, %rbx
movl $0x1, %edi
movl $0x48, %esi
callq 0x2120
movq %rax, %r12
movq %rbx, 0x8(%rsp)
movq %rax, 0x18(%rbx)
movq 0x18(%r14), %rcx
movq %rcx, 0x10(%rsp)
movl 0x38(%rcx), %eax
addl 0x38(%r13), %eax
movl %eax, 0x38(%r12)
movl 0x18(%rcx), %eax
addl 0x18(%r13), %eax
movl %eax, 0x18(%r12)
movl 0x14(%rcx), %edi
addl 0x14(%r13), %edi
movq %r13, %rbx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %edi
movl $0x80000000, %ecx       # imm = 0x80000000
movl 0x14(%r12), %eax
andl %ecx, %eax
orl %edi, %eax
movl %eax, 0x14(%r12)
movl %edi, 0x10(%r12)
shlq $0x3, %rdi
callq 0x2280
movq %rax, %r13
movq %rax, 0x20(%r12)
movq %rbx, (%rsp)
movq 0x20(%rbx), %rsi
movl 0x14(%rbx), %edx
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %rdx
shlq $0x3, %rdx
movq %rax, %rdi
callq 0x2160
movq (%rsp), %rax
movl 0x14(%rax), %eax
andq %rbx, %rax
leaq (,%rax,8), %rdi
addq %r13, %rdi
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rsi
movl 0x14(%rax), %edx
movq %rax, %r13
andq %rbx, %rdx
shlq $0x3, %rdx
callq 0x2160
movl 0x4(%r13), %eax
movq (%rsp), %r13
addl 0x4(%r13), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
movl $0x80000000, %ecx       # imm = 0x80000000
andl 0x4(%r12), %ecx
orl %eax, %ecx
movl %ecx, 0x4(%r12)
movl %eax, (%r12)
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
callq 0x2280
movq %rax, 0x8(%r12)
movq 0x8(%r13), %rsi
movl 0x4(%r13), %ecx
andq %rbx, %rcx
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rdx
movq %rax, %rdi
callq 0x2160
movq 0x18(%r14), %rsi
testl $0x7fffffff, 0x4(%rsi)  # imm = 0x7FFFFFFF
je 0xde8ac
leal (,%rbp,2), %eax
shlq $0x21, %rbp
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x8(%rsi), %rsi
movq 0x18(%r15), %rdi
movl 0x4(%rdi), %edi
andq %rbx, %rdi
leaq (%rdi,%rdi,2), %rdi
shlq $0x3, %rdi
addq 0x8(%r12), %rdi
movq 0x10(%rsi,%rcx), %r8
movq %r8, 0x10(%rcx,%rdi)
movups (%rsi,%rcx), %xmm0
movups %xmm0, (%rcx,%rdi)
movq 0x8(%r12), %rsi
movq 0x18(%r15), %rdi
movl 0x4(%rdi), %r8d
andq %rbx, %r8
leaq (%r8,%r8,2), %r8
leaq (%rsi,%r8,8), %r8
addl %eax, 0x8(%rcx,%r8)
movl 0x4(%rdi), %edi
andq %rbx, %rdi
leaq (%rdi,%rdi,2), %rdi
leaq (%rsi,%rdi,8), %rsi
addq %rbp, (%rcx,%rsi)
incq %rdx
movq 0x18(%r14), %rsi
movl 0x4(%rsi), %edi
andq %rbx, %rdi
addq $0x18, %rcx
cmpq %rdi, %rdx
jb 0xde83a
movq %r12, %rdi
callq 0xa02fa
movq %r12, %rdi
callq 0xa0333
movq %r12, %rdi
callq 0xa03e9
orb $-0x80, 0x17(%r12)
movq (%r14), %rax
addq (%r15), %rax
movq 0x8(%rsp), %rbx
movq %rax, (%rbx)
movq %rax, 0x8(%rbx)
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdi
callq 0x2280
movq %rax, %r12
movq %rax, 0x10(%rbx)
movq (%r15), %rcx
movq %rcx, (%rsp)
testq %rcx, %rcx
je 0xde96b
movq 0x10(%r15), %r13
movl $0x18, %ebp
movq (%rsp), %rbx
movq 0x8(%r13,%rbp), %rax
movq %rax, 0x8(%r12,%rbp)
movups -0x18(%r13,%rbp), %xmm0
movups -0x8(%r13,%rbp), %xmm1
movups %xmm1, -0x8(%r12,%rbp)
movups %xmm0, -0x18(%r12,%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%r12,%rbp)
movl -0x8(%r13,%rbp), %r15d
movl %r15d, -0x8(%r12,%rbp)
movl %r15d, -0xc(%r12,%rbp)
shlq $0x3, %r15
movq %r15, %rdi
callq 0x2280
movq %rax, (%r12,%rbp)
movq (%r13,%rbp), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2160
addq $0x28, %rbp
decq %rbx
jne 0xde909
movq (%r14), %r15
testq %r15, %r15
je 0xde9ea
movq (%rsp), %rax
leaq (%rax,%rax,4), %rax
leaq (%r12,%rax,8), %rbx
movq 0x10(%r14), %r12
movl $0x18, %r13d
movq 0x8(%r12,%r13), %rax
movq %rax, 0x8(%rbx,%r13)
movups -0x18(%r12,%r13), %xmm0
movups -0x8(%r12,%r13), %xmm1
movups %xmm1, -0x8(%rbx,%r13)
movups %xmm0, -0x18(%rbx,%r13)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx,%r13)
movl -0x8(%r12,%r13), %r14d
movl %r14d, -0x8(%rbx,%r13)
movl %r14d, -0xc(%rbx,%r13)
shlq $0x3, %r14
movq %r14, %rdi
callq 0x2280
movq %rax, (%rbx,%r13)
movq (%r12,%r13), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x2160
addq $0x28, %r13
decq %r15
jne 0xde989
movq 0x8(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq