// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %rsi, %r15
movq %rdi, %r13
movl 0x14(%rsi), %eax
addl %eax, %eax
jne 0xab98
xorl %ecx, %ecx
xorl %r14d, %r14d
jmp 0xad8f
movl %eax, %eax
movq %rax, 0x8(%rsp)
xorl %esi, %esi
xorl %r9d, %r9d
xorl %r12d, %r12d
xorl %edi, %edi
movq %r15, 0x10(%rsp)
movq %r13, (%rsp)
movq 0x20(%r15), %rax
movl %esi, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
movq %rsi, 0x18(%rsp)
js 0xacac
movq 0x28(%r15), %rax
movq (%rax,%rsi,8), %rax
testl %eax, %eax
je 0xacac
movq %rax, %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %r10
addq 0x8(%r15), %r10
movq (%rsp), %rdx
movq 0x8(%rdx), %rcx
movq 0x28(%rdx), %rdx
movq (%rdx,%rsi,8), %rsi
movq %rsi, %rdx
shrq $0x20, %rdx
movl %eax, %r11d
movl %esi, %eax
imulq $0x18, %rdx, %rdx
leaq (%rcx,%rdx), %r15
addq $0xc, %r15
imulq $0x18, %rax, %r14
xorl %ebx, %ebx
movq %r10, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %r11, 0x20(%rsp)
imulq $0x18, %rbx, %rbp
cmpl $0x0, 0xc(%r10,%rbp)
js 0xaca0
addq %r10, %rbp
testl %esi, %esi
je 0xac54
movl 0x8(%rbp), %eax
xorl %ecx, %ecx
cmpl $0x0, (%r15,%rcx)
js 0xac4b
cmpl %eax, -0x4(%r15,%rcx)
je 0xaca0
addq $0x18, %rcx
cmpq %rcx, %r14
jne 0xac3d
cmpq %r12, %r9
jne 0xac88
leaq (%r9,%r9), %r12
testq %r9, %r9
pushq $0x2
popq %rax
cmoveq %rax, %r12
imulq $0x18, %r12, %rsi
movq %r9, %r13
callq 0x2370
movq 0x20(%rsp), %r11
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r10
movq %r13, %r9
movq %rax, %rdi
imulq $0x18, %r9, %rax
incq %r9
movq 0x10(%rbp), %rcx
movq %rcx, 0x10(%rdi,%rax)
movups (%rbp), %xmm0
movups %xmm0, (%rdi,%rax)
incq %rbx
cmpq %r11, %rbx
jne 0xac25
movq 0x18(%rsp), %rsi
incq %rsi
cmpq 0x8(%rsp), %rsi
movq 0x10(%rsp), %r15
movq (%rsp), %r13
jne 0xabb2
xorl %ecx, %ecx
testq %r9, %r9
jne 0xacd7
movq %rdi, %r14
jmp 0xad8f
pushq $0x1
popq %rbx
xorl %r14d, %r14d
movl 0x4(%r13), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl (%r13), %ecx
jne 0xad29
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
pushq $0x10
popq %rcx
cmovel %ecx, %eax
movl %eax, (%r13)
movq %rdi, %rbp
movq 0x8(%r13), %rdi
imulq $0x18, %rax, %rsi
movq %r9, %r12
callq 0x2370
movq %r12, %r9
movq %rbp, %rdi
movq %rax, 0x8(%r13)
movl 0x4(%r13), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0xad2d
movq 0x8(%r13), %rax
leal 0x1(%rdx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %esi, %edx
movl %edx, 0x4(%r13)
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
imulq $0x18, %r14, %rdx
movq 0x10(%rdi,%rdx), %rsi
movq %rsi, 0x10(%rax,%rcx)
movups (%rdi,%rdx), %xmm0
movups %xmm0, (%rax,%rcx)
movl %ebx, %r14d
incl %ebx
cmpq %r14, %r9
ja 0xacdd
movq %rdi, %r14
movq 0x28(%r13), %rdi
movq %r9, %rbx
callq 0x2220
andq $0x0, 0x28(%r13)
andb $0x7f, 0x7(%r13)
movq %r13, %rdi
callq 0xa0a7d
movl %ebx, %ecx
movq 0x28a24a(%rip), %rbx    # 0x294fe0
movq (%rbx), %rdi
leaq 0x22c7b7(%rip), %rsi    # 0x237557
leaq 0x22c7cf(%rip), %r12    # 0x237576
movq %r12, %rdx
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rdi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl 0x4(%r13), %ecx
andl %r8d, %ecx
andl 0x4(%r15), %r8d
leaq 0x22c7b6(%rip), %rsi    # 0x237582
movq %r12, %rdx
xorl %eax, %eax
callq 0x22b0
movq %r14, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220