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

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

  if (pos == size) {
    strcpy(best, current);
  } else {

    int nedges[size], max=-1;
    for (i=0; i<size; i++)
      if (!used[i]) {
	nedges[i]=0;
	for (j=0; j<size; j++)
	  if (!used[j] && in[i*size+j]=='1')
	    nedges[i]++;
	if (nedges[i]>max) max=nedges[i];
      }
    

    for (i=0; i<size; i++)
      if (!used[i] /*&& nedges[i]==max*/) {
	used[i]=1;
	perm[pos]=i;
	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]; 
	}
	_goCan(i, pos+1, in, perm, used, current, best, size);
	current[pos*size+pos] = '2';
	for (j=0; j<pos; j++) {
	  current[pos*size+j] = '2';
	  current[j*size+pos] = '2';
	}
	used[i]=0;
      }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %rdi
movq %r8, -0x58(%rbp)
movq %rcx, -0x50(%rbp)
movq %rdx, %r12
movl %esi, %ebx
movl 0x18(%rbp), %r14d
movq 0x10(%rbp), %rsi
movq %r9, -0x30(%rbp)
movq %rsi, -0x48(%rbp)
callq 0x22c0
testl %eax, %eax
js 0x7186
cmpl %r14d, %ebx
jne 0x6ffa
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21d0
movq %rbx, %r9
movq %r14, %r10
movq %rsp, -0x60(%rbp)
movl %r10d, %ebx
movq %rsp, %rax
leaq 0xf(,%rbx,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rax
movq %rax, %rsp
testl %r10d, %r10d
movq -0x58(%rbp), %r8
movq -0x50(%rbp), %rdi
jle 0x7061
xorl %ecx, %ecx
movq %r12, %rdx
cmpb $0x0, (%r8,%rcx)
jne 0x7056
movl $0x0, (%rax,%rcx,4)
xorl %esi, %esi
cmpb $0x0, (%r8,%rsi)
jne 0x704e
cmpb $0x31, (%rdx,%rsi)
jne 0x704e
incl (%rax,%rcx,4)
incq %rsi
cmpq %rsi, %rbx
jne 0x703e
incq %rcx
addq %rbx, %rdx
cmpq %rbx, %rcx
jne 0x702e
testl %r10d, %r10d
jle 0x7182
movslq %r9d, %rax
movq %rax, -0x70(%rbp)
movl %r10d, %r13d
imull %r9d, %r13d
leal (%r9,%r13), %eax
movslq %eax, %rsi
leal 0x1(%r9), %eax
movl %eax, -0x34(%rbp)
movl %r9d, %r14d
movq -0x30(%rbp), %rax
addq %rax, %r13
addq %r14, %rax
movq %rax, -0x40(%rbp)
xorl %r15d, %r15d
movq %r9, -0x80(%rbp)
movq %r10, -0x78(%rbp)
movq %rsi, -0x68(%rbp)
cmpb $0x0, (%r8,%r15)
jne 0x7176
movl %r15d, %eax
movq %rbx, %rcx
imulq %rax, %rcx
leaq (%r12,%r15), %rax
movb $0x1, (%r8,%r15)
movq -0x70(%rbp), %rdx
movb %r15b, (%rdi,%rdx)
movb (%rcx,%rax), %al
movq -0x30(%rbp), %rcx
movb %al, (%rcx,%rsi)
testl %r9d, %r9d
jle 0x711b
movl %r15d, %eax
imull %r10d, %eax
cltq
movq -0x40(%rbp), %rcx
xorl %edx, %edx
movsbq (%rdi,%rdx), %rsi
addq %rax, %rsi
movb (%r12,%rsi), %sil
movb %sil, (%r13,%rdx)
movsbl (%rdi,%rdx), %esi
imull %r10d, %esi
addl %r15d, %esi
movslq %esi, %rsi
movb (%r12,%rsi), %sil
movb %sil, (%rcx)
incq %rdx
addq %rbx, %rcx
cmpq %rdx, %r14
jne 0x70ea
movl -0x34(%rbp), %esi
movq %r12, %rdx
movq %rdi, %rcx
movq -0x30(%rbp), %r9
pushq %r10
pushq -0x48(%rbp)
callq 0x6f9c
addq $0x10, %rsp
movq -0x68(%rbp), %rsi
movq -0x30(%rbp), %rax
movb $0x32, (%rax,%rsi)
movq -0x80(%rbp), %r9
testl %r9d, %r9d
movb $0x32, %dl
jle 0x7165
movq -0x40(%rbp), %rax
xorl %ecx, %ecx
movb %dl, (%r13,%rcx)
movb %dl, (%rax)
incq %rcx
addq %rbx, %rax
cmpq %rcx, %r14
jne 0x7153
movq -0x58(%rbp), %r8
movb $0x0, (%r8,%r15)
movq -0x50(%rbp), %rdi
movq -0x78(%rbp), %r10
incq %r15
cmpq %rbx, %r15
jne 0x70a6
movq -0x60(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop