// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %rdi
movq %r8, 0x38(%rsp)
movq %rcx, %r15
movq %rdx, %r12
movl %esi, %ebx
movl 0x98(%rsp), %r14d
movq 0x90(%rsp), %rsi
movq %r9, 0x8(%rsp)
movq %rsi, 0x18(%rsp)
callq 0x22c0
testl %eax, %eax
js 0x7266
cmpl %r14d, %ebx
jne 0x70f7
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21d0
movq %r14, %rdi
movq %rsp, 0x40(%rsp)
testl %edi, %edi
movq 0x8(%rsp), %rdx
movq 0x38(%rsp), %r8
jle 0x7261
movq %rbx, %rsi
movl %edi, %r13d
movslq %esi, %rax
movq %rax, 0x48(%rsp)
movl %edi, %ebp
imull %esi, %ebp
leal (%rbx,%rbp), %eax
movslq %eax, %r10
leal 0x1(%rbx), %eax
movl %eax, 0x14(%rsp)
movl %esi, %r14d
addq %rdx, %rbp
leaq (%rdx,%r14), %rax
movq %rax, 0x30(%rsp)
xorl %ebx, %ebx
movq %rsi, 0x28(%rsp)
movq %rdi, 0x50(%rsp)
movq %r10, 0x20(%rsp)
cmpb $0x0, (%r8,%rbx)
jne 0x7255
movl %ebx, %eax
imulq %r13, %rax
leaq (%r12,%rbx), %rcx
movb $0x1, (%r8,%rbx)
movq 0x48(%rsp), %r9
movb %bl, (%r15,%r9)
movb (%rax,%rcx), %al
movb %al, (%rdx,%r10)
testl %esi, %esi
jle 0x7215
movl %ebx, %eax
imull %edi, %eax
cltq
movq 0x30(%rsp), %rcx
xorl %edx, %edx
movsbq (%r15,%rdx), %rsi
addq %rax, %rsi
movb (%r12,%rsi), %sil
movb %sil, (%rbp,%rdx)
movsbl (%r15,%rdx), %esi
imull %edi, %esi
addl %ebx, %esi
movslq %esi, %rsi
movb (%r12,%rsi), %sil
movb %sil, (%rcx)
incq %rdx
addq %r13, %rcx
cmpq %rdx, %r14
jne 0x7191
movl 0x14(%rsp), %esi
movq %r12, %rdx
movq %r15, %rcx
movq 0x8(%rsp), %r9
pushq %rdi
pushq 0x20(%rsp)
callq 0x7090
movq 0x18(%rsp), %rdx
addq $0x10, %rsp
movq 0x20(%rsp), %r10
movb $0x32, (%rdx,%r10)
movq 0x28(%rsp), %rsi
testl %esi, %esi
movb $0x32, %dil
jle 0x7246
movq 0x30(%rsp), %rax
xorl %ecx, %ecx
movb %dil, (%rbp,%rcx)
movb %dil, (%rax)
incq %rcx
addq %r13, %rax
cmpq %rcx, %r14
jne 0x7200
jmp 0x7246
movl 0x14(%rsp), %esi
movq %r12, %rdx
movq %r15, %rcx
movq 0x8(%rsp), %r9
pushq %rdi
pushq 0x20(%rsp)
callq 0x7090
movq 0x30(%rsp), %r10
movq 0x38(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq $0x10, %rsp
movb $0x32, (%rdx,%r10)
movq 0x38(%rsp), %r8
movb $0x0, (%r8,%rbx)
movq 0x50(%rsp), %rdi
incq %rbx
cmpq %r13, %rbx
jne 0x7151
movq 0x40(%rsp), %rsp
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop