// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: recall_arcs(asg_t*, asg_t*)
void recall_arcs(asg_t *des, asg_t *src)
{
    uint32_t v, w, n_vtx = src->n_seq*2;
    asg_arc_t *av, *za, *p; uint32_t an, zn, ai, zi, k;
    kvec_t(asg_arc_t) ka; kv_init(ka);

    for (v = 0; v < n_vtx; ++v) {
        if(src->seq[v>>1].del) continue;
        za = asg_arc_a(src, v); zn = asg_arc_n(src, v); 
        av = asg_arc_a(des, v); an = asg_arc_n(des, v); 
        for (zi = 0; zi < zn; zi++) {
            if(za[zi].del) continue;
            w = za[zi].v;
            for (ai = 0; ai < an; ai++) {
                if(av[ai].del) continue;
                if(av[ai].v == w) break;
            }
            if(ai >= an) kv_push(asg_arc_t, ka, za[zi]);
        }
    }

    if(ka.n) {
        for (k = 0; k < ka.n; k++) {
            p = asg_arc_pushp(des); *p = (ka.a[k]); 
        }
        free(des->idx);
        des->idx = 0;
        des->is_srt = 0;
        asg_cleanup(des);
        // asg_symm(des);
    }
    fprintf(stderr, "[M::%s] # transitive arcs::%u\n", __func__, (uint32_t)ka.n);
    fprintf(stderr, "[M::%s] # new arcs::%u, # old arcs::%u\n", __func__, des->n_arc, src->n_arc);
    
    kv_destroy(ka);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %r12
movl 0x14(%rsi), %ecx
xorl %eax, %eax
movl $0x0, %r10d
addl %ecx, %ecx
movq %rsi, 0x8(%rsp)
je 0xad35
movl %ecx, %eax
movq %rax, 0x10(%rsp)
xorl %edi, %edi
xorl %r10d, %r10d
xorl %r9d, %r9d
xorl %eax, %eax
movq %r12, 0x18(%rsp)
movq 0x20(%r14), %rcx
movl %edi, %edx
shrl %edx
cmpl $0x0, (%rcx,%rdx,8)
movq %rdi, 0x20(%rsp)
js 0xad18
movq 0x28(%r14), %rcx
movq (%rcx,%rdi,8), %rcx
testl %ecx, %ecx
je 0xad18
movq %rcx, %rdx
shrq $0x20, %rdx
imulq $0x18, %rdx, %r11
addq 0x8(%r14), %r11
movq 0x8(%r12), %rdx
movq 0x28(%r12), %rsi
movq (%rsi,%rdi,8), %rbx
movq %rbx, %rsi
shrq $0x20, %rsi
movl %ebx, %r13d
testq %r13, %r13
setne 0x7(%rsp)
movl %ecx, %r12d
imulq $0x18, %rsi, %rcx
addq %rdx, %rcx
addq $0xc, %rcx
movq %rcx, 0x38(%rsp)
movq %r13, %r14
negq %r14
xorl %r15d, %r15d
movq %rbx, 0x30(%rsp)
movq %r12, 0x28(%rsp)
imulq $0x18, %r15, %rbp
cmpl $0x0, 0xc(%r11,%rbp)
js 0xad0c
addq %r11, %rbp
testl %ebx, %ebx
je 0xacb8
movl 0x8(%rbp), %ecx
pushq $0x1
popq %rdx
movq 0x38(%rsp), %rsi
movb 0x7(%rsp), %dil
cmpl $0x0, (%rsi)
js 0xac95
cmpl %ecx, -0x4(%rsi)
je 0xacb2
cmpq %r13, %rdx
setb %dil
addq $0x18, %rsi
leaq (%r14,%rdx), %r8
incq %r8
incq %rdx
cmpq $0x1, %r8
jne 0xac8b
jmp 0xacb8
testb $0x1, %dil
jne 0xad0c
cmpq %r9, %r10
jne 0xacf4
leaq (%r9,%r9), %r12
testq %r9, %r9
pushq $0x2
popq %rcx
cmoveq %rcx, %r12
imulq $0x18, %r12, %rsi
movq %rax, %rdi
movq %r10, 0x40(%rsp)
movq %r11, %rbx
callq 0x2370
movq %rbx, %r11
movq 0x30(%rsp), %rbx
movq 0x40(%rsp), %r10
movq %r12, %r9
movq 0x28(%rsp), %r12
imulq $0x18, %r10, %rcx
incq %r10
movq 0x10(%rbp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movups (%rbp), %xmm0
movups %xmm0, (%rax,%rcx)
incq %r15
cmpq %r12, %r15
jne 0xac64
movq 0x20(%rsp), %rdi
incq %rdi
cmpq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r14
movq 0x18(%rsp), %r12
jne 0xabe8
movq %rax, %r13
testq %r10, %r10
je 0xadff
pushq $0x1
popq %rbx
xorl %r15d, %r15d
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq %r13, %rdi
movq %r10, %r14
movl 0x4(%r12), %ecx
andl %ebp, %ecx
movl (%r12), %eax
cmpl %eax, %ecx
jne 0xad89
leal (%rax,%rax), %ecx
testl %eax, %eax
pushq $0x10
popq %rax
cmovel %eax, %ecx
movl %ecx, (%r12)
movq 0x8(%r12), %rdi
imulq $0x18, %rcx, %rsi
callq 0x2370
movq %r14, %r10
movq %r13, %rdi
movq %rax, 0x8(%r12)
movq 0x8(%r12), %rax
movl 0x4(%r12), %ecx
movl %ecx, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leal 0x1(%rcx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %esi, %ecx
movl %ecx, 0x4(%r12)
imulq $0x18, %rdx, %rcx
imulq $0x18, %r15, %rdx
movq 0x10(%rdi,%rdx), %rsi
movq %rsi, 0x10(%rax,%rcx)
movups (%rdi,%rdx), %xmm0
movups %xmm0, (%rax,%rcx)
movl %ebx, %r15d
incl %ebx
cmpq %r15, %r10
ja 0xad52
movq 0x28(%r12), %rdi
callq 0x2220
andq $0x0, 0x28(%r12)
andb $0x7f, 0x7(%r12)
movq %r12, %rdi
callq 0xa02fa
movq %r14, %r10
movq 0x8(%rsp), %r14
movq 0x27f1da(%rip), %rbx    # 0x289fe0
movq (%rbx), %rdi
leaq 0x220557(%rip), %rsi    # 0x22b367
leaq 0x22056f(%rip), %r15    # 0x22b386
movq %r15, %rdx
movl %r10d, %ecx
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rdi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl 0x4(%r12), %ecx
andl %r8d, %ecx
andl 0x4(%r14), %r8d
leaq 0x220552(%rip), %rsi    # 0x22b392
movq %r15, %rdx
xorl %eax, %eax
callq 0x22b0
movq %r13, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220