// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: append_node_arcs(asg_t*, asg_t*, unsigned char*, unsigned char, unsigned int)
void append_node_arcs(asg_t *des, asg_t *src, uint8_t *s, uint8_t se, uint32_t v)
{
    asg_arc_t *av, *za; uint32_t an, zn, k, n0, n1;
    n0 = n1 = 0;
    za = asg_arc_a(src, v); zn = asg_arc_n(src, v); 
    av = asg_arc_a(des, v); an = asg_arc_n(des, v); 
    ///set
    for (k = 0; k < zn; k++) {
        if(za[k].del) continue;
        s[za[k].v] |= se; n0++;
    }

    for (k = 0; k < an; k++) {
        ///s[av[k].v]&se:: in the existing graph
        if(s[av[k].v]&se) {
            av[k].del = 0; n1++;
            asg_arc_del(des, av[k].v^1, (av[k].ul>>32)^1, 0);
        }
    }
    
    ///reset
    for (k = 0; k < zn; k++) {
        if(za[k].del) continue;
        if(s[za[k].v]&se) s[za[k].v] -= se;
    }
    if(!(n0 == n1)) {
        fprintf(stderr, "[M::%s] n0::%u, n1::%u\n", __func__, n0, n1);
    }
    assert(n0 == n1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movl %r8d, -0x20(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x20(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x20(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x20(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x20(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x34(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x13cb9b
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x13cb65
jmp 0x13cb90
movzbl -0x19(%rbp), %esi
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movl -0x3c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
movzbl (%rax,%rcx), %edx
orl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x13cb42
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x13cc42
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movl -0x3c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x19(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x13cc32
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0xc(%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
xorl $0x1, %esi
movq -0x28(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
xorq $0x1, %rax
movl %eax, %edx
xorl %ecx, %ecx
callq 0xd6530
jmp 0x13cc34
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x13cba2
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x13ccbf
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x13cc6c
jmp 0x13ccb4
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movl -0x3c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x19(%rbp), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x13ccb2
movzbl -0x19(%rbp), %esi
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movl -0x3c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
movzbl (%rax,%rcx), %edx
subl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x13ccb4
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x13cc49
movl -0x40(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0x13cced
movq 0x287312(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x40(%rbp), %ecx
movl -0x44(%rbp), %r8d
leaq 0x24bf6c(%rip), %rsi    # 0x388c4b
leaq 0x24bf7d(%rip), %rdx    # 0x388c63
movb $0x0, %al
callq 0x22a0
movl -0x40(%rbp), %eax
cmpl -0x44(%rbp), %eax
jne 0x13ccf7
jmp 0x13cd16
leaq 0x24bf76(%rip), %rdi    # 0x388c74
leaq 0x249bb8(%rip), %rsi    # 0x3868bd
movl $0x677c, %edx           # imm = 0x677C
leaq 0x24bf6c(%rip), %rcx    # 0x388c7d
callq 0x2130
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)