// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/network.c
// Function: connected
int connected(bayesiangraphptr mygraph)
{
	/*!Last Changed 02.02.2004 added safemalloc*/
 /*!Last Changed 25.02.2001*/
 int found=0,i,j,k,l,**connected_components,*component_counts;
 int pos,pos1,pos2,ind1,ind2;
 connected_components = safemalloc (mygraph->nodecount * sizeof(int *), "connected", 3);
 component_counts = safemalloc (mygraph->nodecount * sizeof(int), "connected", 4);
 for (i = 0; i < mygraph->nodecount; i++)
  {
   component_counts[i]=1;
   connected_components[i] = (int *) safemalloc (sizeof(int), "connected", 8);
   connected_components[i][0]=i;
  }
 for (i=0;i<mygraph->nodecount;i++)
  {
   pos=mygraph->nodes[i].pointer;
   while (pos!=-1)
    {
     ind1=i;
     ind2=mygraph->dest[pos];
     pos1=-1;
     pos2=-1;
     j=0;
     l=0;
     while (j<mygraph->nodecount)
      {
       for (k=0;k<component_counts[j];k++)
        {
         if (connected_components[j][k]==ind1)
           pos1=j;
         if (connected_components[j][k]==ind2)
           pos2=j;
        }
       if (component_counts[j]>0)
         l++;
       j++;
      }
     if (l==1)
      {
       found=1;
       break;
      }
     if (pos1!=pos2)
      {
       connected_components[pos1] = alloc(connected_components[pos1],(component_counts[pos1] + component_counts[pos2])*sizeof(int), component_counts[pos1] + component_counts[pos2]);
       for (j=0;j<component_counts[pos2];j++)
         connected_components[pos1][component_counts[pos1]+j] = connected_components[pos2][j];
       component_counts[pos1]+=component_counts[pos2];
       component_counts[pos2]=0;
      }
     pos=mygraph->arcs[pos].pointer;
    }
  }
 if (!found)
  {
   k=0;
   for (i=0;i<mygraph->nodecount;i++)
     if (component_counts[i]>0)
       k++;
   if (k==1)
     found=1;
  }
	free_2d((void**)connected_components, mygraph->nodecount);
 safe_free(component_counts);
 return found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0x72ee2(%rip), %rsi     # 0xe43b8
movl $0x3, %edx
callq 0x52d70
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movslq 0x10(%rax), %rdi
shlq $0x2, %rdi
leaq 0x72ec1(%rip), %rsi     # 0xe43b8
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x30(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x71568
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl $0x4, %edi
leaq 0x72e85(%rip), %rsi     # 0xe43b8
movl $0x8, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x10(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, (%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x7150c
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x71780
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x10(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $-0x1, -0x34(%rbp)
je 0x71770
movl -0x10(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x14(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x7166b
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x30(%rbp), %rcx
movslq -0x14(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x71646
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x40(%rbp), %eax
jne 0x7161b
movl -0x14(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x44(%rbp), %eax
jne 0x71639
movl -0x14(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x7163b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x715ed
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0x7165d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x715d6
cmpl $0x1, -0x1c(%rbp)
jne 0x7167d
movl $0x1, -0xc(%rbp)
jmp 0x71770
movl -0x38(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x71759
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x30(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x30(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movslq %eax, %rsi
shlq $0x2, %rsi
movq -0x30(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
addl (%rax,%rcx,4), %edx
callq 0x52d10
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x30(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x71731
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x30(%rbp), %rcx
movslq -0x38(%rbp), %rsi
movl (%rcx,%rsi,4), %ecx
addl -0x14(%rbp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x716e3
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movslq -0x38(%rbp), %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
jmp 0x71598
jmp 0x71772
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x7156f
cmpl $0x0, -0xc(%rbp)
jne 0x717d3
movl $0x0, -0x18(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x717c4
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0x717b7
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x717b9
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x71794
cmpl $0x1, -0x18(%rbp)
jne 0x717d1
movl $0x1, -0xc(%rbp)
jmp 0x717d3
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x52e20
movq -0x30(%rbp), %rdi
callq 0x52e80
movl -0xc(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)