// File: /workspace/github_c_makefile_star2_O0/ComplexNetworks-DCC-FCUP[P]gtrieScanner/Isomorphism.cpp
// Function: Isomorphism::canonicalBasedNauty(char const*, char*, int)
void Isomorphism::canonicalBasedNauty(const char *in, char *best, int size) {

  int i, j, k, min_i, ss, mymap[size];
  int degree[size], last_degree[size], total_degree[size];
  char used[size], articulation[size];
  int nbfs, bfs[size];

  for (i=0; i<size; i++) {
    degree[i] = 0;
    used[i]=0;
    for (j=0; j<size; j++) {
      if (in[i*size+j]=='1') degree[i]++;
      if (in[i+size*j]=='1') degree[i]++;
    }
    total_degree[i] = last_degree[i] = degree[i];
  }

  // Find the node with the smaller number of connections
  for (ss = size-1; ss>=0; ss--) {

    if (ss>3) {
      // Find articulation points (cannot be removed)
      for (i=0; i<size; i++) {
	if (used[i]) continue;
	used[i]=2;
	j=0; while (used[j]) j++;
	nbfs=1; bfs[0]=j; used[j]=2; j=0;
	while (j<nbfs) {
	  for (k=0; k<size; k++)
	    if (!used[k] && (in[k*size+bfs[j]]=='1' || in[k+size*bfs[j]]=='1')) {
	      used[k]=2;
	      bfs[nbfs++]=k;
	    }
	  j++;
	}
	if (nbfs!=ss) articulation[i]=1;
	else articulation[i]=0;
	for (j=0; j<size; j++)
	  if (used[j]==2) used[j]=0;
      }
    } else for (i=0; i<size; i++) articulation[i]=0;

    min_i = -1;
    for (i=0; i<size; i++) {
      if (used[i] || articulation[i]) continue;
      if (min_i<0 || degree[i] < degree[min_i]) min_i=i;
      else if (degree[i] == degree[min_i]) {
	if (last_degree[i] < last_degree[min_i]) min_i=i;
	else if (last_degree[i] == last_degree[min_i]) {
	  if (total_degree[i] < total_degree[min_i]) min_i = i;
	  else if (total_degree[i] == total_degree[min_i]) {
	    for (j=ss+1; j<size; j++)
	      if (in[i*size+mymap[j]] != in[min_i*size+mymap[j]]) {
		if (in[i*size+mymap[j]]=='0') min_i=i;
		break;
	      }
	    if (j==size) {
	      for (j=ss+1; j<size; j++)
		if (in[i+size*mymap[j]] != in[min_i+size*mymap[j]]) {
		  if (in[i+size*mymap[j]]=='0') min_i=i;
		  break;
		}	      
	    }
	  }
	}
      }
    }
    
    if (ss!=0 && degree[min_i]==0) {
      fprintf(stderr, "[%s]\n", in);
      fprintf(stderr, "!!! OH NO %d [canonicalBasedNauty]\n", ss); fflush(stdout);
      exit(1);
    }
    
    for (i=0; i<size; i++) {
      last_degree[i] = degree[i];
      if (in[i*size+min_i]=='1') degree[i]--;
      if (in[i+size*min_i]=='1') degree[i]--;
    }
    mymap[ss] = min_i;
    used[min_i]=1;
  }

  best[size*size]=0;
  for (i=0; i<n; i++)
    for (j=0; j<n; j++)
      best[i*size+j] = in[mymap[i]*size+mymap[j]];  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x30(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xa8(%rbp)
movq %rcx, %rsp
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xa0(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x98(%rbp)
movq %rcx, %rsp
movq %rax, -0x48(%rbp)
movl -0x14(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x90(%rbp)
movq %rcx, %rsp
movq %rax, -0x50(%rbp)
movl -0x14(%rbp), %eax
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x88(%rbp)
movq %rcx, %rsp
movq %rax, -0x58(%rbp)
movl -0x14(%rbp), %eax
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x80(%rbp)
movq %rcx, %rsp
movq %rax, -0x60(%rbp)
movl -0x14(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x78(%rbp)
movq %rcx, %rsp
movq %rax, -0x70(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe460
movq -0x88(%rbp), %rax
movq -0xa0(%rbp), %rcx
movslq -0x18(%rbp), %rdx
movl $0x0, (%rcx,%rdx,4)
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe428
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x31, %eax
jne 0xe3eb
movq -0xa0(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movl -0x14(%rbp), %edx
imull -0x1c(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x31, %eax
jne 0xe41b
movq -0xa0(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0xe41d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe3b5
movq -0x90(%rbp), %rax
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %rdx
movslq -0x18(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
movslq -0x18(%rbp), %rsi
movl %edx, (%rcx,%rsi,4)
movslq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe381
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jl 0xe9c9
cmpl $0x3, -0x28(%rbp)
jle 0xe62c
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe62a
movq -0x88(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xe4a6
jmp 0xe61c
movq -0x88(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x2, (%rax,%rcx)
movl $0x0, -0x1c(%rbp)
movq -0x88(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xe4d8
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe4bc
movq -0x88(%rbp), %rax
movq -0x78(%rbp), %rcx
movl $0x1, -0x64(%rbp)
movl -0x1c(%rbp), %edx
movl %edx, (%rcx)
movslq -0x1c(%rbp), %rcx
movb $0x2, (%rax,%rcx)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0xe5b9
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe5ab
movq -0x88(%rbp), %rax
movslq -0x20(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0xe59b
movq -0x78(%rbp), %rdx
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
imull -0x14(%rbp), %ecx
movslq -0x1c(%rbp), %rsi
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x31, %eax
je 0xe574
movq -0x78(%rbp), %rsi
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movl -0x14(%rbp), %edx
movslq -0x1c(%rbp), %rdi
imull (%rsi,%rdi,4), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x31, %eax
jne 0xe59b
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movslq -0x20(%rbp), %rdx
movb $0x2, (%rcx,%rdx)
movl -0x20(%rbp), %edx
movl -0x64(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x64(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0xe59d
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xe511
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe4fe
movl -0x64(%rbp), %eax
cmpl -0x28(%rbp), %eax
je 0xe5cf
movq -0x80(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0xe5db
movq -0x80(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe61a
movq -0x88(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0xe60d
movq -0x88(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0xe60f
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe5e2
jmp 0xe61c
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe484
jmp 0xe654
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe652
movq -0x80(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe633
jmp 0xe654
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe897
movq -0x88(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
jne 0xe68d
movq -0x80(%rbp), %rax
movslq -0x18(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xe692
jmp 0xe889
cmpl $0x0, -0x24(%rbp)
jl 0xe6af
movq -0xa0(%rbp), %rcx
movslq -0x18(%rbp), %rax
movl (%rcx,%rax,4), %eax
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0xe6ba
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0xe887
movq -0xa0(%rbp), %rcx
movslq -0x18(%rbp), %rax
movl (%rcx,%rax,4), %eax
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0xe885
movq -0x98(%rbp), %rcx
movslq -0x18(%rbp), %rax
movl (%rcx,%rax,4), %eax
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0xe6f7
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0xe883
movq -0x98(%rbp), %rcx
movslq -0x18(%rbp), %rax
movl (%rcx,%rax,4), %eax
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0xe881
movq -0x90(%rbp), %rcx
movslq -0x18(%rbp), %rax
movl (%rcx,%rax,4), %eax
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0xe734
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0xe87f
movq -0x90(%rbp), %rcx
movslq -0x18(%rbp), %rax
movl (%rcx,%rax,4), %eax
movslq -0x24(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0xe87d
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe7d7
movq -0xa8(%rbp), %rsi
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
imull -0x14(%rbp), %ecx
movslq -0x1c(%rbp), %rdx
addl (%rsi,%rdx,4), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl -0x24(%rbp), %edx
imull -0x14(%rbp), %edx
movslq -0x1c(%rbp), %rdi
addl (%rsi,%rdi,4), %edx
movslq %edx, %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0xe7ca
movq -0xa8(%rbp), %rdx
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
imull -0x14(%rbp), %ecx
movslq -0x1c(%rbp), %rsi
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x30, %eax
jne 0xe7c8
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0xe7d7
jmp 0xe7cc
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe758
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0xe87b
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe879
movq -0xa8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movl -0x14(%rbp), %edx
movslq -0x1c(%rbp), %rsi
imull (%rdi,%rsi,4), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl -0x24(%rbp), %edx
movl -0x14(%rbp), %esi
movslq -0x1c(%rbp), %r8
imull (%rdi,%r8,4), %esi
addl %esi, %edx
movslq %edx, %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0xe869
movq -0xa8(%rbp), %rsi
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movl -0x14(%rbp), %edx
movslq -0x1c(%rbp), %rdi
imull (%rsi,%rdi,4), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x30, %eax
jne 0xe867
movl -0x18(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0xe879
jmp 0xe86b
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe7ec
jmp 0xe87b
jmp 0xe87d
jmp 0xe87f
jmp 0xe881
jmp 0xe883
jmp 0xe885
jmp 0xe887
jmp 0xe889
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe662
cmpl $0x0, -0x28(%rbp)
je 0xe8fe
movq -0xa0(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0xe8fe
movq 0x1c723(%rip), %rax     # 0x2afd8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
leaq 0x122c1(%rip), %rsi     # 0x20b84
movb $0x0, %al
callq 0x33a0
movq 0x1c707(%rip), %rax     # 0x2afd8
movq (%rax), %rdi
movl -0x28(%rbp), %edx
leaq 0x122ac(%rip), %rsi     # 0x20b8a
movb $0x0, %al
callq 0x33a0
movq 0x1c6d4(%rip), %rax     # 0x2afc0
movq (%rax), %rdi
callq 0x3300
movl $0x1, %edi
callq 0x3330
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xe99b
movq -0x98(%rbp), %rax
movq -0xa0(%rbp), %rcx
movslq -0x18(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movslq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x31, %eax
jne 0xe95b
movq -0xa0(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movl -0x14(%rbp), %edx
imull -0x24(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x31, %eax
jne 0xe98b
movq -0xa0(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0xe98d
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe905
movq -0x88(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl -0x24(%rbp), %esi
movslq -0x28(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movslq -0x24(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xe469
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
imull -0x14(%rbp), %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl 0x265c5(%rip), %eax     # 0x34fb0
jge 0xea4e
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x265b3(%rip), %eax     # 0x34fb0
jge 0xea41
movq -0xa8(%rbp), %rdx
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl (%rdx,%rcx,4), %ecx
imull -0x14(%rbp), %ecx
movslq -0x1c(%rbp), %rsi
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe9f4
jmp 0xea43
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe9e2
movq -0x30(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)