// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movq %rsi, %r13
movq %rsi, 0x8(%rsp)
movq %rdi, 0x20(%rsp)
movq 0x18(%rdi), %r14
movl 0x14(%r14), %eax
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq %rax, %rcx
movq %rax, %rbp
movq %rax, (%rsp)
andq %rbx, %rcx
movq %rcx, 0x18(%rsp)
movl $0x1, %edi
movl $0x38, %esi
callq 0x2120
movq %rax, %r15
movl $0x1, %edi
movl $0x48, %esi
callq 0x2120
movq %rax, %r12
movq %r15, 0x10(%rsp)
movq %rax, 0x18(%r15)
movq 0x18(%r13), %r15
movl 0x38(%r15), %eax
addl 0x38(%r14), %eax
movl %eax, 0x38(%r12)
movl 0x18(%r15), %eax
addl 0x18(%r14), %eax
movl %eax, 0x18(%r12)
movl 0x14(%r15), %edi
addl %ebp, %edi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %edi
movl %edi, 0x14(%r12)
movl %edi, 0x10(%r12)
shlq $0x3, %rdi
callq 0x2280
movq %rax, %r13
movq %rax, 0x20(%r12)
movq 0x20(%r14), %rsi
movq 0x18(%rsp), %rbp
leaq (,%rbp,8), %rdx
movq %rax, %rdi
callq 0x2160
leaq (,%rbp,8), %rdi
addq %r13, %rdi
movq 0x20(%r15), %rsi
movl 0x14(%r15), %edx
andq %rbx, %rdx
shlq $0x3, %rdx
callq 0x2160
movl 0x4(%r14), %ebp
movl 0x4(%r15), %eax
addl %ebp, %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
movl %eax, 0x4(%r12)
movl %eax, (%r12)
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
callq 0x2280
movq %rax, %r13
movq %rax, 0x8(%r12)
movq 0x8(%r14), %rsi
andq %rbx, %rbp
shlq $0x3, %rbp
leaq (,%rbp,2), %rdx
addq %rbp, %rdx
movq 0x8(%rsp), %rbp
movq %rax, %rdi
callq 0x2160
movq (%rsp), %r10
movq 0x20(%rsp), %r9
testl $0x7fffffff, 0x4(%r15)  # imm = 0x7FFFFFFF
je 0xdfc28
leal (%r10,%r10), %eax
shlq $0x21, %r10
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x8(%r15), %rsi
movl 0x4(%r14), %edi
andq %rbx, %rdi
leaq (%rdi,%rdi,2), %rdi
leaq (,%rdi,8), %rdi
addq %r13, %rdi
movq 0x10(%rsi,%rcx), %r8
movq %r8, 0x10(%rcx,%rdi)
movups (%rsi,%rcx), %xmm0
movups %xmm0, (%rcx,%rdi)
movq 0x8(%r12), %r13
movq 0x18(%r9), %r14
movl 0x4(%r14), %esi
andq %rbx, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (,%rsi,8), %rsi
addq %r13, %rsi
addl %eax, 0x8(%rcx,%rsi)
movl 0x4(%r14), %esi
andq %rbx, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (,%rsi,8), %rsi
addq %r13, %rsi
addq %r10, (%rcx,%rsi)
incq %rdx
movq 0x18(%rbp), %r15
movl 0x4(%r15), %esi
andq %rbx, %rsi
addq $0x18, %rcx
cmpq %rsi, %rdx
jb 0xdfba8
movq %r12, %rdi
movq %r9, %r15
callq 0xa0a7d
movq %r12, %rdi
callq 0xa0ab6
movq %r12, %rdi
callq 0xa0b79
orb $-0x80, 0x17(%r12)
movq (%r15), %r13
movq (%rbp), %rbx
leaq (%rbx,%r13), %rax
movq 0x10(%rsp), %r14
movq %rax, (%r14)
movq %rax, 0x8(%r14)
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdi
callq 0x2280
movq %rax, %r12
movq %rax, 0x10(%r14)
movq %r13, (%rsp)
testq %r13, %r13
je 0xdfce0
movq 0x10(%r15), %r13
movl $0x18, %ebp
movq (%rsp), %r14
movq -0x8(%r13,%rbp), %rax
movq %rax, -0x8(%r12,%rbp)
movups -0x18(%r13,%rbp), %xmm0
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 %r14
jne 0xdfc8a
testq %rbx, %rbx
je 0xdfd55
movq (%rsp), %rax
leaq (%rax,%rax,4), %rax
leaq (%r12,%rax,8), %r15
movq 0x8(%rsp), %rax
movq 0x10(%rax), %r12
movl $0x18, %r13d
movq -0x8(%r12,%r13), %rax
movq %rax, -0x8(%r15,%r13)
movups -0x18(%r12,%r13), %xmm0
movups %xmm0, -0x18(%r15,%r13)
xorps %xmm0, %xmm0
movups %xmm0, (%r15,%r13)
movl -0x8(%r12,%r13), %r14d
movl %r14d, -0x8(%r15,%r13)
movl %r14d, -0xc(%r15,%r13)
shlq $0x3, %r14
movq %r14, %rdi
callq 0x2280
movq %rax, (%r15,%r13)
movq (%r12,%r13), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x2160
addq $0x28, %r13
decq %rbx
jne 0xdfd00
movq 0x10(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq