// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/graph.c
// Function: trim_graph_repeats
int trim_graph_repeats(graph_t *g)
{
    // TODO a more sophisticated implemetation for complex repeats
    uint32_t v, v1, v2, w1, w2, nv, n_del;
    graph_arc_t *av, *aw;
    nv = graph_n_vtx(g);
    nv <<= 1;
    n_del = 0;

    for (v = 0; v < nv; ++v) {
        if (graph_arc_n(g, v) != 2 || graph_arc_n(g, v^1) != 2)
            continue;
        av = graph_arc_a(g, v^1);
        v1 = av->w;
        v2 = (av + 1)->w;
        aw = graph_arc_a(g, v);
        w1 = aw->w;
        w2 = (aw + 1)->w;

        if ((graph_arc(g, v1, w1) && graph_arc(g, v2, w2)) ||
                (graph_arc(g, v1, w2) && graph_arc(g, v2, w1))) {
            n_del += graph_arc_del_existed(g, av);
            n_del += graph_arc_del_existed(g, av + 1);
            n_del += graph_arc_del_existed(g, aw);
            n_del += graph_arc_del_existed(g, aw + 1);
        }
    }

    graph_clean(g, 1);

#ifdef DEBUG_GRAPH_PRUNE
    fprintf(stderr, "[DEBUG_GRAPH_PRUNE::%s] #del repeats: %u\n", __func__, 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, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x9d5e
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x2, %eax
jne 0x9c28
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movl -0xc(%rbp), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x2, %eax
je 0x9c2d
jmp 0x9d50
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl -0xc(%rbp), %edx
xorl $0x1, %edx
movl %edx, %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x14(%rbp)
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, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x38(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x8f10
cmpq $0x0, %rax
je 0x9cd0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x8f10
cmpq $0x0, %rax
jne 0x9cfa
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x8f10
cmpq $0x0, %rax
je 0x9d4e
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x8f10
cmpq $0x0, %rax
je 0x9d4e
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x97e0
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x20, %rsi
callq 0x97e0
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x97e0
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
addq $0x20, %rsi
callq 0x97e0
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x9d50
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9bef
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x88e0
movl -0x24(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)