// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq %rsi, %rbx
movq %rdi, 0x10(%rsp)
movq 0x18(%rdi), %r14
movl 0x14(%r14), %r13d
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq %r13, %rax
andq %rbp, %rax
movq %rax, 0x28(%rsp)
leal (,%r13,2), %eax
movl %eax, 0x8(%rsp)
movq %r13, %rax
shlq $0x21, %rax
movq %rax, 0x30(%rsp)
pushq $0x1
popq %rdi
pushq $0x38
popq %rsi
callq 0x2120
movq %rax, %r15
callq 0x68f5d
movq %rax, %r12
movq %r15, 0x20(%rsp)
movq %rax, 0x18(%r15)
movq %rbx, 0x18(%rsp)
movq 0x18(%rbx), %rbx
movl 0x38(%rbx), %eax
addl 0x38(%r14), %eax
movl %eax, 0x38(%r12)
movl 0x18(%rbx), %eax
addl 0x18(%r14), %eax
movl %eax, 0x18(%r12)
movl 0x14(%rbx), %edi
addl %r13d, %edi
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 0x20(%r14), %rsi
movq 0x28(%rsp), %r15
leaq (,%r15,8), %rdx
movq %rax, %rdi
callq 0x2160
leaq (,%r15,8), %rdi
addq %r13, %rdi
movq 0x20(%rbx), %rsi
movl 0x14(%rbx), %edx
andq %rbp, %rdx
shlq $0x3, %rdx
callq 0x2160
movl 0x4(%r14), %r15d
movl 0x4(%rbx), %eax
addl %r15d, %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)
imulq $0x18, %rax, %rdi
callq 0x2280
movq %rax, %r13
movq %rax, 0x8(%r12)
movq 0x8(%r14), %rsi
andq %rbp, %r15
imulq $0x18, %r15, %rdx
movq %rax, %rdi
callq 0x2160
movq 0x30(%rsp), %r8
movl 0x8(%rsp), %edi
xorl %eax, %eax
xorl %ecx, %ecx
movl 0x4(%rbx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
jae 0xa239d
movq 0x8(%rbx), %rdx
movl 0x4(%r14), %esi
andq %rbp, %rsi
imulq $0x18, %rsi, %rsi
addq %rsi, %r13
movq 0x10(%rdx,%rax), %rsi
movq %rsi, 0x10(%rax,%r13)
movups (%rdx,%rax), %xmm0
movups %xmm0, (%rax,%r13)
movq 0x8(%r12), %r13
movq 0x10(%rsp), %rdx
movq 0x18(%rdx), %r14
movl 0x4(%r14), %edx
andq %rbp, %rdx
imulq $0x18, %rdx, %rdx
addq %r13, %rdx
addl %edi, 0x8(%rax,%rdx)
movl 0x4(%r14), %edx
andq %rbp, %rdx
imulq $0x18, %rdx, %rdx
addq %r13, %rdx
addq %r8, (%rax,%rdx)
incq %rcx
movq 0x18(%rsp), %rdx
movq 0x18(%rdx), %rbx
addq $0x18, %rax
jmp 0xa2326
movq %r12, %rdi
callq 0x694eb
movq %r12, %rdi
callq 0x69638
movq 0x10(%rsp), %rax
movq (%rax), %r15
movq 0x18(%rsp), %rax
movq (%rax), %rbx
leaq (%rbx,%r15), %rax
movq 0x20(%rsp), %r14
movq %rax, (%r14)
movq %rax, 0x8(%r14)
imulq $0x28, %rax, %rdi
callq 0x2280
movq %rax, %r12
movq %rax, 0x10(%r14)
pushq $0x18
popq %rbp
movq %r15, 0x8(%rsp)
movq %r15, %r14
subq $0x1, %r14
jb 0xa2449
movq 0x10(%rsp), %rax
movq 0x10(%rax), %r15
movq -0x8(%r15,%rbp), %rax
movq %rax, -0x8(%r12,%rbp)
movups -0x18(%r15,%rbp), %xmm0
movups %xmm0, -0x18(%r12,%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%r12,%rbp)
movl -0x8(%r15,%rbp), %r13d
movl %r13d, -0x8(%r12,%rbp)
movl %r13d, -0xc(%r12,%rbp)
shlq $0x3, %r13
movq %r13, %rdi
callq 0x2280
movq %rax, (%r12,%rbp)
movq (%r15,%rbp), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x2160
addq $0x28, %rbp
jmp 0xa23e8
imulq $0x28, 0x8(%rsp), %rax
addq %rax, %r12
pushq $0x18
popq %r14
subq $0x1, %rbx
jb 0xa24b8
movq 0x18(%rsp), %rax
movq 0x10(%rax), %r13
movq -0x8(%r13,%r14), %rax
movq %rax, -0x8(%r12,%r14)
movups -0x18(%r13,%r14), %xmm0
movups %xmm0, -0x18(%r12,%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r12,%r14)
movl -0x8(%r13,%r14), %r15d
movl %r15d, -0x8(%r12,%r14)
movl %r15d, -0xc(%r12,%r14)
shlq $0x3, %r15
movq %r15, %rdi
callq 0x2280
movq %rax, (%r12,%r14)
movq (%r13,%r14), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2160
addq $0x28, %r14
jmp 0xa2456
movq 0x20(%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq