// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
shll %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0xa110
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
je 0x9fe8
jmp 0xa102
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0xc(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x28(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x10(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x1, %eax
jne 0xa100
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x14(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x1, %eax
jne 0xa100
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x10(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0x14(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x38(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0xa0fe
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x97e0
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x20, %rsi
callq 0x97e0
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x97e0
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x97e0
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0xa100
jmp 0xa102
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9fbf
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x88e0
movl -0x20(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)