// File: chhylp123[P]hifiasm/rcut.cpp
// Function: mb_g_cc_core(mb_match_t*)
uint64_t *mb_g_cc_core(mb_match_t *ma)
{
    uint32_t i, x, y, *flag;
    uint64_t *group;
    mb_edge_t *o = NULL;
    kvec_t(uint32_t) stack; kv_init(stack);

    MALLOC(flag, ma->n_seq);
    for (i = 0; i < ma->n_seq; ++i)
        flag[i] = (uint32_t)-1;

    // connected componets
    for (i = 0; i < ma->n_seq; ++i) {
        if (flag[i] != (uint32_t)-1) continue;
        stack.n = 0;
        kv_push(uint32_t, stack, i);
        while (stack.n > 0) {
            uint32_t k, j, n;
            stack.n--;
            k = stack.a[stack.n];
            flag[k] = i;///group id
            // n = (uint32_t)ma->idx[k];
            // s = ma->idx[k] >> 32;
            o = pt_a(*ma, k); 
            n = pt_n(*ma, k);
            for (j = 0; j < n; ++j) {
                uint32_t t = ma_y(o[j]);
                if (flag[t] != (uint32_t)-1) continue;
                // if (ns == ms) PT_EXPAND(stack, ms);
                // stack[ns++] = t;
                kv_push(uint32_t, stack, t);
            }
        }
    }
    kv_destroy(stack);

    // precalculate the size of each group
    CALLOC(group, ma->n_seq);
    for (i = 0; i < ma->n_seq; ++i)
        group[i] = (uint64_t)flag[i] << 32 | i;
    radix_sort_mc64(group, group + ma->n_seq);
    for (i = 1, x = y = 0; i <= ma->n_seq; ++i) {
        if (i == ma->n_seq || group[i]>>32 != group[x]>>32) {
            uint32_t j;
            for (j = x; j < i; ++j)
                group[j] = (uint64_t)y << 32 | (uint32_t)group[j];///(group id)|first element in this group
            ++y, x = i;
        }
    }
    free(flag);
    return group;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2270
movq %rax, -0x20(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x38(%rcx), %eax
jae 0x224dde
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x224db9
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x38(%rcx), %eax
jae 0x224f96
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
cmpl $-0x1, (%rax,%rcx,4)
je 0x224e07
jmp 0x224f88
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x224e55
cmpq $0x0, -0x40(%rbp)
je 0x224e2d
movq -0x40(%rbp), %rax
shlq %rax
movq %rax, -0x68(%rbp)
jmp 0x224e38
movl $0x2, %eax
movq %rax, -0x68(%rbp)
jmp 0x224e38
movq -0x68(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x38(%rbp)
movl -0xc(%rbp), %edx
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x48(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x224e70
cmpq $0x0, -0x48(%rbp)
jbe 0x224f86
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movl -0xc(%rbp), %edx
movq -0x20(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x4c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jae 0x224f81
movq -0x30(%rbp), %rax
movl -0x50(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movl -0x58(%rbp), %ecx
cmpl $-0x1, (%rax,%rcx,4)
je 0x224f10
jmp 0x224f73
jmp 0x224f12
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x224f58
cmpq $0x0, -0x40(%rbp)
je 0x224f30
movq -0x40(%rbp), %rax
shlq %rax
movq %rax, -0x70(%rbp)
jmp 0x224f3b
movl $0x2, %eax
movq %rax, -0x70(%rbp)
jmp 0x224f3b
movq -0x70(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x38(%rbp)
movl -0x58(%rbp), %edx
movq -0x38(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x48(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x224f73
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x224ee1
jmp 0x224e70
jmp 0x224f88
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x224de5
movq -0x38(%rbp), %rdi
callq 0x2210
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, %edi
movl $0x8, %esi
callq 0x2140
movq %rax, -0x28(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x38(%rcx), %eax
jae 0x224ff5
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, %edx
shlq $0x20, %rdx
movl -0xc(%rbp), %eax
orq %rax, %rdx
movq -0x28(%rbp), %rax
movl -0xc(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x224fbd
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x216280
movl $0x1, -0xc(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x38(%rcx), %eax
ja 0x2250c0
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x38(%rcx), %eax
je 0x225064
movq -0x28(%rbp), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq -0x28(%rbp), %rcx
movl -0x10(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
je 0x2250b0
movl -0x10(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x2250a1
movl -0x14(%rbp), %eax
movl %eax, %edx
shlq $0x20, %rdx
movq -0x28(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
orq %rax, %rdx
movq -0x28(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x22506a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x2250b2
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x225025
movq -0x20(%rbp), %rdi
callq 0x2210
movq -0x28(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)