// File: /workspace/github_c_makefile_star2_O0/ComplexNetworks-DCC-FCUP[P]gtrieScanner/Isomorphism.cpp
// Function: Isomorphism::_goCan2(int, char const*, int*, bool*, char*, int, char*)
void Isomorphism::_goCan2(int pos, const char *in, int *perm, bool *used, char *best, int size, char *current) {
  int i, j;

  if (strcmp(current,best)<0) return;

  if (pos==size) {
    strcpy(best, current);
    return;
  }
  
  // At the beggining everyone is a possible candidate
  bool candidate[size];
  for (i=0; i<size; i++)
    if (used[i]) candidate[i]=false;
    else         candidate[i]=true;


  for (i=0; i<pos; i++) {
    for (j=0; j<size ;j++)
      if (candidate[j] && in[perm[i]*size+j]=='1') break;
    if (j<size) // at least one neighbour
      for (j=0; j<size ;j++)
	if (candidate[j] && in[perm[i]*size+j]=='0') candidate[j]=false;
  }

  // Among those that are still candidates, select the
  // biggest neighborhood on those candidates
  int degree[size];
  int max=-1;
  for (i=0; i<size; i++) {
    degree[i]=0;
    if (candidate[i]) {
      for (j=0; j<size; j++)
	if (i!=j && candidate[j] && in[j*size+i]=='1')
	  degree[i]++;
      if (degree[i]>max) max=degree[i];
    }
  }

  for (i=0; i<size; i++)
    if (candidate[i] && degree[i]==max) {
      perm[pos]=i;
      used[i]=true;
      current[pos*size+pos] = in[i*size+i];
      for (j=0; j<pos; j++) {
	current[pos*size+j] = in[i*size+perm[j]]; 
	current[j*size+pos] = in[perm[j]*size+i]; 
      }

      _goCan2(pos+1, in, perm, used, best, size, current);

      current[pos*size+pos] = '2';
      for (j=0; j<pos; j++) {
	current[pos*size+j] = '2';
	current[j*size+pos] = '2';
      }
      used[i]=false;
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq 0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3390
cmpl $0x0, %eax
jge 0xed2a
jmp 0xf105
movl -0x4(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0xed44
movq -0x28(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x3250
jmp 0xf105
movl -0x2c(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x40(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x60(%rbp)
movq %rcx, %rsp
movq %rax, -0x48(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xedae
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0xed95
movq -0x60(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0xeda1
movq -0x60(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0xeda3
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xed71
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0xee81
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xee0f
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0xee02
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
imull -0x2c(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x31, %eax
jne 0xee02
jmp 0xee0f
jmp 0xee04
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xedc8
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xee71
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xee6f
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0xee62
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
imull -0x2c(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x30, %eax
jne 0xee62
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0xee64
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xee1e
jmp 0xee71
jmp 0xee73
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xedb5
movl -0x2c(%rbp), %eax
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x68(%rbp)
movq %rcx, %rsp
movq %rax, -0x50(%rbp)
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xef65
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movl $0x0, (%rcx,%rdx,4)
movslq -0x30(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0xef55
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xef35
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0xef28
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0xef28
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
imull -0x2c(%rbp), %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x31, %eax
jne 0xef28
movq -0x68(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0xef2a
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xeedf
movq -0x68(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x54(%rbp), %eax
jle 0xef53
movq -0x68(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x54(%rbp)
jmp 0xef55
jmp 0xef57
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xeeaf
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xf0fe
movq -0x60(%rbp), %rax
movslq -0x30(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0xf0ee
movq -0x68(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x54(%rbp), %eax
jne 0xf0ee
movl -0x30(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x4(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
imull -0x2c(%rbp), %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rbp), %rax
movl -0x4(%rbp), %ecx
imull -0x2c(%rbp), %ecx
addl -0x4(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0xf05a
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
imull -0x2c(%rbp), %ecx
movq -0x18(%rbp), %rdx
movslq -0x34(%rbp), %rsi
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rbp), %rax
movl -0x4(%rbp), %ecx
imull -0x2c(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq -0x34(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
imull -0x2c(%rbp), %ecx
addl -0x30(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
imull -0x2c(%rbp), %ecx
addl -0x4(%rbp), %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xefe7
movl -0x4(%rbp), %edi
addl $0x1, %edi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movl -0x2c(%rbp), %r9d
movq 0x10(%rbp), %rax
subq $0x10, %rsp
movq %rax, (%rsp)
callq 0xecf0
addq $0x10, %rsp
movq 0x10(%rbp), %rax
movl -0x4(%rbp), %ecx
imull -0x2c(%rbp), %ecx
addl -0x4(%rbp), %ecx
movslq %ecx, %rcx
movb $0x32, (%rax,%rcx)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0xf0e2
movq 0x10(%rbp), %rax
movl -0x4(%rbp), %ecx
imull -0x2c(%rbp), %ecx
addl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movb $0x32, (%rax,%rcx)
movq 0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
imull -0x2c(%rbp), %ecx
addl -0x4(%rbp), %ecx
movslq %ecx, %rcx
movb $0x32, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xf0a5
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0xf0f0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xef6c
movq -0x40(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw (%rax,%rax)