// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/graph.c
// Function: asmg_uext_arc_group
uint32_t *asmg_uext_arc_group(asmg_t *g, uint32_t *n_group)
{
    uint64_t i, j, k, v, n_vtx, n_arc;
    uint32_t *arc_group, group, na;
    uint8_t *visited;
    int32_t vt;
    u64_v_t a = {0, 0, 0};

    n_vtx = g->n_vtx;
    n_arc = asmg_max_link_id(g) + 1; // number unique arcs
    
    MYMALLOC(arc_group, n_arc);
    MYBONE(arc_group, n_arc);
    MYCALLOC(visited, n_vtx);

    group = 0;
    for (i = 0; i < n_vtx; ++i) {
        if (visited[i] || g->vtx[i].del)
            continue;
        na = 0;
        for (k = 0; k < 2; ++k) {
            v = i << 1 | k;
            vt = asmg_uext(g, v, n_vtx*2+1, 0, 0, &a, 0);
            for (j = 1; j < a.n; ++j) {
                arc_group[asmg_arc1(g, a.a[j-1], a.a[j])->link_id] = group;
                visited[a.a[j]>>1] = 1;
                ++na;
            }
            if (vt == ASMG_VT_MULTI_NEI) {
                arc_group[asmg_arc_a1(g, a.a[a.n-1])->link_id] = group;
                ++na;
            }
        }
        if (na > 0) ++group;
        visited[i] = 1;
    }
    
    for (i = 0; i < g->n_arc; ++i) {
        if (g->arc[i].del || 
                arc_group[g->arc[i].link_id] != (uint32_t) -1)
            continue;
        arc_group[g->arc[i].link_id] = group++;
    }

    if (n_group) *n_group = group;

    free(a.a);
    free(visited);

    return arc_group;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x21f0
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1fdd0
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
shlq $0x2, %rdi
callq 0x2320
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
shlq $0x2, %rdx
movl $0xff, %esi
callq 0x21f0
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x2250
movq %rax, -0x58(%rbp)
movl $0x0, -0x4c(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x20cb3
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x20b34
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x20b39
jmp 0x20ca2
movl $0x0, -0x50(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x2, -0x28(%rbp)
jae 0x20c87
movq -0x18(%rbp), %rax
shlq %rax
orq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq %rax
addq $0x1, %rax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x78(%rbp), %r9
xorl %eax, %eax
movq %r8, %rcx
movl $0x0, (%rsp)
callq 0x20d70
movl %eax, -0x5c(%rbp)
movq $0x1, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x78(%rbp), %rax
jae 0x20c21
movl -0x4c(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rsi
movq -0x68(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x21000
movl -0x84(%rbp), %edx
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq 0x28(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x58(%rbp), %rax
movq -0x68(%rbp), %rcx
movq -0x20(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq %rcx
movb $0x1, (%rax,%rcx)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x20b9c
cmpl $0x3, -0x5c(%rbp)
jne 0x20c74
movl -0x4c(%rbp), %eax
movl %eax, -0x94(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x210c0
movl -0x94(%rbp), %edx
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq 0x28(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x20c76
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x20b48
cmpl $0x0, -0x50(%rbp)
jbe 0x20c96
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x20af7
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x20d3b
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
imulq $0x30, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x20d05
movq -0x48(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
imulq $0x30, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq 0x28(%rcx), %rcx
cmpl $-0x1, (%rax,%rcx,4)
je 0x20d07
jmp 0x20d2d
movl -0x4c(%rbp), %edx
movl %edx, %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
imulq $0x30, -0x18(%rbp), %rsi
addq %rsi, %rcx
movq 0x28(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x20cbb
cmpq $0x0, -0x10(%rbp)
je 0x20d4b
movl -0x4c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x68(%rbp), %rdi
callq 0x2060
movq -0x58(%rbp), %rdi
callq 0x2060
movq -0x48(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)