// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/statistics.c
// Function: connected_components
int connected_components(Linkptr edges, int nodecount)
{
 /*Last Changed 12.03.2004*/
 int** components, i, j, *counts, compcount = 0, compf, comps;
 Linkptr e;
 components = (int **)safemalloc_2d(sizeof(int *), sizeof(int), nodecount, nodecount, "connected_components", 3);
 counts = (int *)safemalloc(nodecount * sizeof(int), "connected_components", 4);
 for (i = 0; i < nodecount; i++)
  {
   components[i][0] = i;
   counts[i] = 1;
  }
 e = edges;
 while (e)
  {
   for (i = 0; i < nodecount; i++)
     for (j = 0; j < counts[i]; j++)
       if (components[i][j] == e->from)
        {
         compf = i;
         i = nodecount;
         break;
        }
   for (i = 0; i < nodecount; i++)
     for (j = 0; j < counts[i]; j++)
       if (components[i][j] == e->to)
        {
         comps = i;
         i = nodecount;
         break;
        }
   if (compf != comps)
    {
     components[compf] = alloc(components[compf], (counts[compf] + counts[comps]) * sizeof(int), counts[compf] + counts[comps]);
     for (i = 0; i < counts[comps]; i++)
       components[compf][counts[compf] + i] = components[comps][i];
     counts[compf] = counts[compf] + counts[comps];
     safe_free(components[comps]);
     counts[comps] = 0;
    }
   e = e->next;
  }
 for (i = 0; i < nodecount; i++)
   if (counts[i] > 0)
     safe_free(components[i]);
 safe_free(components);
 for (i = 0; i < nodecount; i++)
   if (counts[i] > 0)
     compcount++;
 safe_free(counts);
 return compcount;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movq %rdi, %r15
leaq 0x23728(%rip), %rbx     # 0xb1735
movl $0x8, %edi
movl $0x4, %esi
movl %ebp, %edx
movl %ebp, %ecx
movq %rbx, %r8
movl $0x3, %r9d
callq 0x3a3ac
movq %rax, %r14
movslq %ebp, %r12
leaq (,%r12,4), %rdi
movq %rbx, %rsi
movl $0x4, %edx
callq 0x3a0e1
movq %rax, %rbx
movl %ebp, %r13d
testl %r12d, %r12d
jle 0x8e066
xorl %eax, %eax
movq (%r14,%rax,8), %rcx
movl %eax, (%rcx)
movl $0x1, (%rbx,%rax,4)
incq %rax
cmpq %rax, %r13
jne 0x8e051
testq %r15, %r15
je 0x8e16d
movq %r13, 0x10(%rsp)
testl %ebp, %ebp
jle 0x8e0e5
xorl %eax, %eax
movl %eax, %edx
movslq (%rbx,%rdx,4), %rcx
testq %rcx, %rcx
jle 0x8e09b
movq (%r14,%rdx,8), %rdx
movl (%r15), %esi
xorl %edi, %edi
cmpl %esi, (%rdx,%rdi,4)
je 0x8e09f
incq %rdi
cmpq %rdi, %rcx
jne 0x8e08e
movl %eax, %ecx
jmp 0x8e0a4
movl %ebp, %ecx
movl %eax, %r9d
incl %ecx
movl %ecx, %eax
cmpl %ebp, %ecx
jl 0x8e07a
testl %ebp, %ebp
jle 0x8e0e5
xorl %eax, %eax
movl %eax, %edx
movslq (%rbx,%rdx,4), %rcx
testq %rcx, %rcx
jle 0x8e0d4
movq (%r14,%rdx,8), %rdx
movl 0x4(%r15), %esi
xorl %edi, %edi
cmpl %esi, (%rdx,%rdi,4)
je 0x8e0d8
incq %rdi
cmpq %rdi, %rcx
jne 0x8e0c7
movl %eax, %ecx
jmp 0x8e0dd
movl %ebp, %ecx
movl %eax, %r8d
incl %ecx
movl %ecx, %eax
cmpl %ebp, %ecx
jl 0x8e0b2
cmpl %r8d, %r9d
je 0x8e160
movl %r9d, 0x8(%rsp)
movslq %r9d, %r12
movq (%r14,%r12,8), %rdi
movslq (%rbx,%r12,4), %rax
movl %r8d, 0xc(%rsp)
movslq %r8d, %r13
movslq (%rbx,%r13,4), %rdx
addq %rax, %rdx
movq %rdx, %rsi
shlq $0x2, %rsi
callq 0x3a0b4
movq %rax, (%r14,%r12,8)
movl (%rbx,%r13,4), %ecx
movq (%r14,%r13,8), %rdi
testl %ecx, %ecx
jle 0x8e140
xorl %edx, %edx
movl (%rdi,%rdx,4), %ecx
movslq (%rbx,%r12,4), %rsi
addq %rdx, %rsi
movl %ecx, (%rax,%rsi,4)
incq %rdx
movslq (%rbx,%r13,4), %rcx
cmpq %rcx, %rdx
jl 0x8e127
addl %ecx, (%rbx,%r12,4)
callq 0x3a180
movl $0x0, (%rbx,%r13,4)
movq 0x10(%rsp), %r13
movl 0xc(%rsp), %r8d
movl 0x8(%rsp), %r9d
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0x8e074
testl %ebp, %ebp
jle 0x8e1b1
xorl %r15d, %r15d
cmpl $0x0, (%rbx,%r15,4)
jle 0x8e184
movq (%r14,%r15,8), %rdi
callq 0x3a180
incq %r15
cmpq %r15, %r13
jne 0x8e174
movq %r14, %rdi
callq 0x3a180
testl %ebp, %ebp
jle 0x8e1b9
xorl %eax, %eax
xorl %ebp, %ebp
xorl %ecx, %ecx
cmpl $0x0, (%rbx,%rax,4)
setg %cl
addl %ecx, %ebp
incq %rax
cmpq %rax, %r13
jne 0x8e19c
jmp 0x8e1bb
movq %r14, %rdi
callq 0x3a180
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x3a180
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq