// File: /workspace/github_c_makefile_star2_O1/c-zhou[P]yahs/graph.c
// Function: graph_print_all_clusters
void graph_print_all_clusters(graph_t *g, FILE *fp)
{
    uint32_t nv, na, v, i, c;
    uint64_t lens;
    graph_arc_t *av, *a;
    kdq_t(uint32_t) *q, *s;
    
    graph_remove_multi_arcs(g);
    graph_add_symm_arcs(g);

    nv = graph_n_vtx(g);
    q = kdq_init(uint32_t);
    s = kdq_init(uint32_t);
    uint8_t *visited = calloc(nv, sizeof(uint8_t));

    c = 0;
    for (i = 0; i < nv; ++i) {
        if (visited[i]) 
            continue;
        kdq_push(uint32_t, q, i << 1);
        kdq_push(uint32_t, s, i);
        visited[i] = 1;
        while (kdq_size(q) > 0) {
            v = *kdq_shift(uint32_t, q);
            na = graph_arc_n(g, v);
            if (na) {
                av = graph_arc_a(g, v);
                for (a = av; a < av + na; ++a) {
                    if (!visited[(a->w) >> 1]) {
                        kdq_push(uint32_t, q, a->w);
                        kdq_push(uint32_t, s, a->w >> 1);
                        visited[a->w >> 1] = 1;
                    }
                }
            }
            na = graph_arc_n(g, v^1);
            if (na) {
                av = graph_arc_a(g, v^1);
                for (a = av; a < av + na; ++a) {
                    if (!visited[(a->w^1) >> 1]) {
                        kdq_push(uint32_t, q, a->w^1);
                        kdq_push(uint32_t, s, (a->w^1) >> 1);
                        visited[(a->w^1) >> 1] = 1;
                    }
                }    
            }
        }

        lens = 0;
        for (i = 0; i < kdq_size(s); ++i)
            lens += g->sdict->s[kdq_at(s, i)].len;
        fprintf(fp, "Cluster %d [%ld seqs, %ld bp]:", ++c, kdq_size(s), lens);
        while (kdq_size(s) > 0)
            fprintf(fp, " %s", g->sdict->s[*kdq_shift(uint32_t, s)].name);
        fprintf(fp, "\n");
    }
    
    kdq_destroy(uint32_t, q);
    kdq_destroy(uint32_t, s);
    free(visited);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
movabsq $0x3ffffffffffffff, %r15 # imm = 0x3FFFFFFFFFFFFFF
callq 0x8948
movq %r14, %rdi
callq 0x89e6
movq 0x8(%r14), %rax
movl (%rax), %ebp
movl $0x1, %edi
movl $0x20, %esi
callq 0x2290
movq %rax, %r12
movq (%rax), %rax
andq %r15, %rax
btsq $0x3b, %rax
movq %rax, (%r12)
movl $0x3, %ebx
movq %rbx, 0x10(%r12)
movl $0x10, %edi
callq 0x2330
movq %rax, 0x18(%r12)
movl $0x1, %edi
movl $0x20, %esi
callq 0x2290
movq %rax, %r13
movq (%rax), %rax
andq %r15, %rax
btsq $0x3b, %rax
movq %rax, (%r13)
movq %rbx, 0x10(%r13)
movl $0x10, %edi
callq 0x2330
movq %rax, 0x18(%r13)
movl $0x1, %esi
movq %rbp, %rdi
callq 0x2290
movq %rbp, %rcx
movq %rax, %rbp
testq %rcx, %rcx
je 0x8ead
xorl %r15d, %r15d
movl $0x0, 0xc(%rsp)
movq %r14, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movl %r15d, %ebx
cmpb $0x0, (%rbp,%rbx)
jne 0x8ea1
leal (%r15,%r15), %esi
movq %r12, %rdi
callq 0x8ee6
movq %r13, %rdi
movl %r15d, %esi
callq 0x8ee6
movb $0x1, (%rbp,%rbx)
movq 0x8(%r12), %rax
testq %rax, %rax
je 0x8d7f
movq (%r12), %rcx
movq 0x18(%r12), %rdx
movq %rcx, %rsi
movabsq $0x3ffffffffffffff, %r8 # imm = 0x3FFFFFFFFFFFFFF
andq %r8, %rsi
leaq 0x1(%rcx), %rdi
andq %r8, %rdi
movabsq $-0x400000000000000, %r8 # imm = 0xFC00000000000000
andq %r8, %rcx
andq 0x10(%r12), %rdi
orq %rcx, %rdi
movq %rdi, (%r12)
decq %rax
movq %rax, 0x8(%r12)
movl (%rdx,%rsi,4), %r15d
movq 0x28(%r14), %rax
movq (%rax,%r15,8), %rbx
movq %rbx, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %r14
je 0x8d09
shrq $0x1b, %rbx
andq $-0x20, %rbx
movq 0x18(%rsp), %rax
addq 0x20(%rax), %rbx
shlq $0x5, %r14
addq %rbx, %r14
movl 0x4(%rbx), %esi
movl %esi, %eax
shrl %eax
cmpb $0x0, (%rbp,%rax)
jne 0x8d00
movq %r12, %rdi
callq 0x8ee6
movl 0x4(%rbx), %esi
shrl %esi
movq %r13, %rdi
callq 0x8ee6
movl 0x4(%rbx), %eax
shrl %eax
movb $0x1, (%rbp,%rax)
addq $0x20, %rbx
cmpq %r14, %rbx
jb 0x8cd3
movq 0x18(%rsp), %r14
movq 0x28(%r14), %rax
xorq $0x1, %r15
movq (%rax,%r15,8), %r15
movq %r15, %rbx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %rbx
je 0x8c53
shrq $0x1b, %r15
andq $-0x20, %r15
addq 0x20(%r14), %r15
shlq $0x5, %rbx
addq %r15, %rbx
movl 0x4(%r15), %esi
movl %esi, %eax
shrl %eax
cmpb $0x0, (%rbp,%rax)
jne 0x8d71
xorl $0x1, %esi
movq %r12, %rdi
callq 0x8ee6
movl 0x4(%r15), %esi
shrl %esi
movq %r13, %rdi
callq 0x8ee6
movl 0x4(%r15), %eax
shrl %eax
movb $0x1, (%rbp,%rax)
addq $0x20, %r15
cmpq %rbx, %r15
jb 0x8d3e
jmp 0x8c53
movq 0x8(%r13), %rcx
testq %rcx, %rcx
movabsq $0x3ffffffffffffff, %r8 # imm = 0x3FFFFFFFFFFFFFF
je 0x8dd0
movq 0x8(%r14), %rax
movq 0x8(%rax), %rax
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rsi
movq (%r13), %rdi
andq %r8, %rdi
xorl %r15d, %r15d
xorl %r8d, %r8d
leaq (%rdi,%r15), %r9
andq %rdx, %r9
movl (%rsi,%r9,4), %r9d
imulq $0x58, %r9, %r9
addq 0x8(%rax,%r9), %r8
incq %r15
movl %r15d, %r9d
cmpq %r9, %rcx
ja 0x8daf
jmp 0x8dd6
xorl %r8d, %r8d
xorl %r15d, %r15d
movl 0xc(%rsp), %edx
incl %edx
movq 0x10(%rsp), %rdi
leaq 0x185fc(%rip), %rsi     # 0x213e4
movl %edx, 0xc(%rsp)
xorl %eax, %eax
callq 0x22c0
movq 0x8(%r13), %rbx
testq %rbx, %rbx
je 0x8e89
movq 0x18(%r13), %rax
movq %rax, 0x30(%rsp)
movq (%r13), %r14
movq 0x10(%r13), %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %r14, %rcx
movabsq $0x3ffffffffffffff, %rsi # imm = 0x3FFFFFFFFFFFFFF
andq %rsi, %rcx
leaq 0x1(%r14), %rdx
andq %rsi, %rdx
andq 0x28(%rsp), %rdx
movabsq $-0x400000000000000, %rsi # imm = 0xFC00000000000000
andq %rsi, %r14
orq %rdx, %r14
movq 0x30(%rsp), %rdx
movl (%rdx,%rcx,4), %ecx
imulq $0x58, %rcx, %rcx
movq (%rax,%rcx), %rdx
movq 0x10(%rsp), %rdi
leaq 0x182ec(%rip), %rsi     # 0x21157
xorl %eax, %eax
callq 0x22c0
decq %rbx
jne 0x8e16
movq %r14, (%r13)
xorl %ebx, %ebx
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %r14
jmp 0x8e8e
movq 0x10(%rsp), %rsi
movq %rbx, 0x8(%r13)
movl $0xa, %edi
callq 0x2260
movq 0x20(%rsp), %rcx
incl %r15d
cmpl %ecx, %r15d
jb 0x8c29
movq 0x18(%r12), %rdi
callq 0x2060
movq %r12, %rdi
callq 0x2060
movq 0x18(%r13), %rdi
callq 0x2060
movq %r13, %rdi
callq 0x2060
movq %rbp, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2060