// File: /workspace/github_c_makefile_star2_O2/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 0x2106a(%rip), %rbx     # 0xa1695
pushq $0x8
popq %rdi
pushq $0x4
popq %rsi
pushq $0x3
popq %r9
movl %ebp, %edx
movl %ebp, %ecx
movq %rbx, %r8
callq 0x351c3
movq %rax, %r14
movslq %ebp, %r12
leaq (,%r12,4), %rdi
pushq $0x4
popq %rdx
movq %rbx, %rsi
callq 0x34f59
movq %rax, %rbx
xorl %eax, %eax
testl %r12d, %r12d
movl $0x0, %r12d
cmovgl %ebp, %r12d
cmpq %rax, %r12
je 0x80683
movq (%r14,%rax,8), %rcx
movl %eax, (%rcx)
movl $0x1, (%rbx,%rax,4)
incq %rax
jmp 0x8066c
xorl %r8d, %r8d
movq %r12, 0x10(%rsp)
testq %r15, %r15
je 0x80783
xorl %eax, %eax
cmpl %ebp, %eax
jge 0x806ca
movl %eax, %ecx
movl (%rbx,%rcx,4), %edx
testl %edx, %edx
cmovlel %r8d, %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x806c2
movq (%r14,%rcx,8), %rdi
movl (%rdi,%rsi,4), %edi
incq %rsi
cmpl (%r15), %edi
jne 0x806a7
movl %ebp, %ecx
movl %eax, %r9d
jmp 0x806c4
movl %eax, %ecx
incl %ecx
movl %ecx, %eax
jmp 0x80696
xorl %eax, %eax
cmpl %ebp, %eax
jge 0x80701
movl %eax, %ecx
movl (%rbx,%rcx,4), %edx
testl %edx, %edx
cmovlel %r8d, %edx
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x806f9
movq (%r14,%rcx,8), %rdi
movl (%rdi,%rsi,4), %edi
incq %rsi
cmpl 0x4(%r15), %edi
jne 0x806dd
movl %ebp, %ecx
movl %eax, %r10d
jmp 0x806fb
movl %eax, %ecx
incl %ecx
movl %ecx, %eax
jmp 0x806cc
cmpl %r10d, %r9d
je 0x8077a
movl %r9d, 0xc(%rsp)
movslq %r9d, %r13
movq (%r14,%r13,8), %rdi
movslq (%rbx,%r13,4), %rax
movl %r10d, 0x8(%rsp)
movslq %r10d, %r12
movslq (%rbx,%r12,4), %rdx
addq %rax, %rdx
movq %rdx, %rsi
shlq $0x2, %rsi
callq 0x34f30
movq %rax, (%r14,%r13,8)
xorl %ecx, %ecx
movslq (%rbx,%r12,4), %rdx
cmpq %rdx, %rcx
jge 0x80756
movq (%r14,%r12,8), %rdx
movl (%rdx,%rcx,4), %edx
movslq (%rbx,%r13,4), %rsi
addq %rcx, %rsi
movl %edx, (%rax,%rsi,4)
incq %rcx
jmp 0x80737
addl %edx, (%rbx,%r13,4)
movq (%r14,%r12,8), %rdi
callq 0x34ff7
andl $0x0, (%rbx,%r12,4)
movq 0x10(%rsp), %r12
xorl %r8d, %r8d
movl 0xc(%rsp), %r9d
movl 0x8(%rsp), %r10d
movq 0x8(%r15), %r15
jmp 0x8068b
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x807a0
cmpl $0x0, (%rbx,%r15,4)
jle 0x8079b
movq (%r14,%r15,8), %rdi
callq 0x34ff7
incq %r15
jmp 0x80786
movq %r14, %rdi
callq 0x34ff7
xorl %eax, %eax
xorl %ebp, %ebp
cmpq %rax, %r12
je 0x807c1
xorl %ecx, %ecx
cmpl $0x0, (%rbx,%rax,4)
setg %cl
addl %ecx, %ebp
incq %rax
jmp 0x807ac
movq %rbx, %rdi
callq 0x34ff7
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq