// File: /workspace/github_c_makefile_star2_O1/c-zhou[P]yahs/graph.c
// Function: trim_graph_pop_bubbles
int trim_graph_pop_bubbles(graph_t *g)
{
    // TODO a more sophisticated implemetation for complex bubbles
    uint32_t v, v1, v2, nv, na, n_del;
    graph_arc_t *av, *av1, *av2;
    nv = graph_n_vtx(g);
    nv <<= 1;
    n_del = 0;

    for (v = 0; v < nv; ++v) {
        na = graph_arc_n(g, v);
        if (na != 2)
            continue;
        av = graph_arc_a(g, v);
        v1 = av->w;
        v2 = (av + 1)->w;
        if (graph_arc_n(g, v1) == 1 && graph_arc_n(g, v2) == 1) {
            av1 = graph_arc_a(g, v1);
            av2 = graph_arc_a(g, v2);
            if (av1->w == av2->w) {
                n_del += graph_arc_del_existed(g, av);
                n_del += graph_arc_del_existed(g, av + 1);
                n_del += graph_arc_del_existed(g, av1);
                n_del += graph_arc_del_existed(g, av2);
            }
        }
    }

    graph_clean(g, 1);

#ifdef DEBUG_GRAPH_PRUNE
    printf("#del bubbles: %u\n", n_del);
#endif

    return n_del;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x8(%rdi), %rax
movl (%rax), %ecx
addl %ecx, %ecx
je 0x9dc6
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movl %ecx, %ecx
xorl %edx, %edx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %ebx, %ebx
movq 0x28(%rdi), %r9
movq (%r9,%rdx,8), %r15
cmpl $0x2, %r15d
jne 0x9db8
movq 0x20(%rdi), %r8
shrq $0x1b, %r15
andq $-0x20, %r15
movl 0x4(%r8,%r15), %r12d
movq (%r9,%r12,8), %r14
cmpl $0x1, %r14d
jne 0x9db8
addq %r8, %r15
movl 0x24(%r15), %esi
movq (%r9,%rsi,8), %r11
cmpl $0x1, %r11d
jne 0x9db8
shrq $0x1b, %r14
andq $-0x20, %r14
shrq $0x1b, %r11
andq $-0x20, %r11
movl 0x4(%r8,%r14), %esi
cmpl 0x4(%r8,%r11), %esi
jne 0x9db8
movq 0x18(%r15), %rsi
movl $0x0, 0x4(%rsp)
movl $0x0, %r9d
testq %rax, %rsi
jne 0x9c5e
orq %rax, %rsi
movq %rsi, 0x18(%r15)
xorq $0x1, %r12
movq 0x28(%rdi), %rsi
movq (%rsi,%r12,8), %rsi
movq %rsi, %r12
movl $0x1, %r9d
andq %r13, %r12
je 0x9c5e
movl (%r15), %ebp
movq 0x20(%rdi), %r13
shrq $0x20, %rsi
shlq $0x5, %r12
shlq $0x5, %rsi
addq %rsi, %r13
addq $0x18, %r13
xorl %esi, %esi
movl -0x14(%r13,%rsi), %r10d
xorl %ebp, %r10d
cmpl $0x1, %r10d
jne 0x9c4f
orq %rax, (%r13,%rsi)
addq $0x20, %rsi
cmpq %rsi, %r12
jne 0x9c3c
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq 0x38(%r15), %rsi
testq %rax, %rsi
jne 0x9cc7
orq %rax, %rsi
movq %rsi, 0x38(%r15)
movl 0x24(%r15), %esi
xorq $0x1, %rsi
movq 0x28(%rdi), %r10
movq (%r10,%rsi,8), %rsi
movq %rsi, %r12
movl $0x1, 0x4(%rsp)
andq %r13, %r12
je 0x9cc7
movl 0x20(%r15), %ebp
movq 0x20(%rdi), %r10
shrq $0x20, %rsi
shlq $0x5, %r12
shlq $0x5, %rsi
leaq (%r10,%rsi), %r15
addq $0x18, %r15
xorl %esi, %esi
movl -0x14(%r15,%rsi), %r10d
xorl %ebp, %r10d
cmpl $0x1, %r10d
jne 0x9cbe
orq %rax, (%r15,%rsi)
addq $0x20, %rsi
cmpq %rsi, %r12
jne 0x9cac
addq %r8, %r14
movq 0x18(%r14), %rsi
xorl %ebp, %ebp
movl $0x0, %r15d
testq %rax, %rsi
jne 0x9d3f
orq %rax, %rsi
movq %rsi, 0x18(%r14)
movl 0x4(%r14), %esi
xorq $0x1, %rsi
movq 0x28(%rdi), %r10
movq (%r10,%rsi,8), %rsi
movq %rsi, %r12
movl $0x1, %r15d
andq %r13, %r12
je 0x9d3f
movl (%r14), %r14d
movq 0x20(%rdi), %r10
shrq $0x20, %rsi
shlq $0x5, %r12
shlq $0x5, %rsi
leaq (%r10,%rsi), %r13
addq $0x18, %r13
xorl %esi, %esi
movl -0x14(%r13,%rsi), %r10d
xorl %r14d, %r10d
cmpl $0x1, %r10d
jne 0x9d30
orq %rax, (%r13,%rsi)
addq $0x20, %rsi
cmpq %rsi, %r12
jne 0x9d1d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
addq %r11, %r8
movq 0x18(%r8), %rsi
testq %rax, %rsi
jne 0x9da7
orq %rax, %rsi
movq %rsi, 0x18(%r8)
movl 0x4(%r8), %esi
xorq $0x1, %rsi
movq 0x28(%rdi), %r10
movq (%r10,%rsi,8), %rsi
movq %rsi, %r11
movl $0x1, %ebp
andq %r13, %r11
je 0x9da7
movl (%r8), %r8d
movq 0x20(%rdi), %r10
shrq $0x20, %rsi
shlq $0x5, %r11
shlq $0x5, %rsi
leaq (%r10,%rsi), %r14
addq $0x18, %r14
xorl %esi, %esi
movl -0x14(%r14,%rsi), %r10d
xorl %r8d, %r10d
cmpl $0x1, %r10d
jne 0x9d9e
orq %rax, (%r14,%rsi)
addq $0x20, %rsi
cmpq %rsi, %r11
jne 0x9d8c
addl %ebx, %r9d
addl 0x4(%rsp), %r9d
addl %r15d, %r9d
addl %ebp, %r9d
movl %r9d, %ebx
incq %rdx
cmpq %rcx, %rdx
jne 0x9b82
jmp 0x9dc8
xorl %ebx, %ebx
movl $0x1, %esi
callq 0x8744
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq