// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, 0x30(%rsp)
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq (%rdi), %r15
movq %rdi, 0x10(%rsp)
callq 0x11fef
leaq 0x4(,%rax,4), %rbx
movq %rbx, %rdi
callq 0x2310
movq %rax, %r14
movq %rax, %rdi
movl $0xff, %esi
movq %rbx, %rdx
callq 0x21e0
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x2250
movq %rax, 0x18(%rsp)
leal 0x1(,%r15,2), %eax
movl %eax, 0x20(%rsp)
xorl %r13d, %r13d
movl $0x0, 0xc(%rsp)
xorl %edx, %edx
movq %r15, 0x38(%rsp)
cmpq %r15, %rdx
je 0x12841
movq 0x18(%rsp), %rax
cmpb $0x0, (%rax,%rdx)
jne 0x12839
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
imulq $0x28, %rdx, %rcx
testb $0x40, 0x23(%rax,%rcx)
jne 0x12839
movq %r14, %rbx
movq %rdx, 0x40(%rsp)
leaq (%rdx,%rdx), %rax
movq %rax, 0x48(%rsp)
xorl %esi, %esi
xorl %r15d, %r15d
cmpq $0x2, %rsi
je 0x1281a
movq %rsi, 0x28(%rsp)
orq 0x48(%rsp), %rsi
movq 0x10(%rsp), %rdi
movl 0x20(%rsp), %edx
xorl %ecx, %ecx
leaq 0x50(%rsp), %r8
xorl %r9d, %r9d
callq 0x128b6
movl %eax, 0x24(%rsp)
movq 0x50(%rsp), %r14
movq 0x60(%rsp), %r13
pushq $0x1
popq %r12
cmpq %r14, %r12
jae 0x127e9
movq -0x8(%r13,%r12,8), %rsi
movq (%r13,%r12,8), %rbp
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0x12a8e
movq 0x28(%rax), %rax
movl 0xc(%rsp), %ecx
movl %ecx, (%rbx,%rax,4)
shrq %rbp
movq 0x18(%rsp), %rax
movb $0x1, (%rax,%rbp)
incl %r15d
incq %r12
jmp 0x127ae
cmpl $0x3, 0x24(%rsp)
jne 0x1280d
movq -0x8(%r13,%r14,8), %rsi
movq 0x10(%rsp), %rdi
callq 0x12abe
movq 0x28(%rax), %rax
movl 0xc(%rsp), %ecx
movl %ecx, (%rbx,%rax,4)
incl %r15d
movq 0x28(%rsp), %rsi
incq %rsi
jmp 0x12770
cmpl $0x1, %r15d
sbbl $-0x1, 0xc(%rsp)
movq 0x18(%rsp), %rax
movq 0x40(%rsp), %rdx
movb $0x1, (%rax,%rdx)
movq %rbx, %r14
movq 0x38(%rsp), %r15
incq %rdx
jmp 0x1272a
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
pushq $0x28
popq %rcx
movq 0x30(%rsp), %rsi
subq $0x1, %rax
jb 0x12887
movq 0x10(%rsp), %rdx
movq 0x28(%rdx), %rdx
testb $0x40, -0x5(%rdx,%rcx)
jne 0x12881
movq (%rdx,%rcx), %rdx
cmpl $-0x1, (%r14,%rdx,4)
jne 0x12881
movl 0xc(%rsp), %edi
movl %edi, (%r14,%rdx,4)
incl %edi
movl %edi, 0xc(%rsp)
addq $0x30, %rcx
jmp 0x12852
testq %rsi, %rsi
je 0x12892
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
movq %r13, %rdi
callq 0x2060
movq 0x18(%rsp), %rdi
callq 0x2060
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq