// File: /workspace/github_c_makefile_star2_O3/ComplexNetworks-DCC-FCUP[P]gtrieScanner/Isomorphism.cpp
// Function: Isomorphism::canonicalBigger(char const*, char*, int)
void Isomorphism::canonicalBigger(const char *in, char *best, int size) {
  int i,j;
  int nedges[size], max;
  char perm[size], current[size*size+1], used[size];

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


  for (i=0; i<size*size; i++)
    best[i] = in[size*size-1-i];    
  best[size*size]=0;

  for (i=0; i<size; i++) used[i]=0;
  for (i=0; i<size*size; i++) current[i]='2';

  current[size*size]='\0';
  for (i=0; i<size; i++)
    if (nedges[i]==nedges[max]) {
      used[i]=1;
      perm[0]=i;
      current[0]=in[i*size+i];
      _goCan(i, 1, in, perm, used, current, best, size);
      current[0]=i;
      used[i]=0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r10d
movl %edx, %r12d
movq %rsp, %r14
leaq 0xf(,%r12,4), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movq %rsp, %rax
leaq 0xf(%r12), %rcx
andq $-0x10, %rcx
subq %rcx, %rax
movq %rax, -0x68(%rbp)
movq %rax, %rsp
movl %edx, %eax
imull %eax, %eax
movq %rsp, %r8
leaq 0x10(%rax), %rdx
andq $-0x10, %rdx
subq %rdx, %r8
movq %r8, -0x38(%rbp)
movq %r8, %rsp
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0x48(%rbp)
movq %rdx, %rsp
xorl %r15d, %r15d
testl %r10d, %r10d
jle 0x787f
movq %rdi, %rcx
xorl %edx, %edx
xorl %r11d, %r11d
xorl %r9d, %r9d
movsbl (%rcx,%r11), %r8d
addl %r8d, %r9d
addl $-0x30, %r9d
incq %r11
cmpq %r11, %r12
jne 0x784e
movl %r9d, (%r14,%rdx,4)
movslq %r15d, %r15
cmpl (%r14,%r15,4), %r9d
cmovgl %edx, %r15d
incq %rdx
addq %r12, %rcx
cmpq %r12, %rdx
jne 0x7848
movslq %r15d, %r15
testl %r10d, %r10d
je 0x796e
movslq %eax, %rdx
cmpl $0x1, %edx
movq %rdi, -0x58(%rbp)
leaq -0x1(%rdx,%rdi), %rcx
adcl $0x0, %edx
xorl %r8d, %r8d
movb (%rcx), %dil
movb %dil, (%rsi,%r8)
incq %r8
decq %rcx
cmpq %r8, %rdx
jne 0x789d
movl %eax, %r13d
movq %rsi, -0x60(%rbp)
movb $0x0, (%rsi,%r13)
testl %r10d, %r10d
jle 0x7974
xorl %ebx, %ebx
movq -0x48(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
movl %r10d, -0x2c(%rbp)
callq 0x2120
cmpq $0x1, %r13
movq %r13, %rdx
adcq $0x0, %rdx
movq -0x38(%rbp), %rdi
movl $0x32, %esi
callq 0x2120
movl -0x2c(%rbp), %edi
movq -0x38(%rbp), %rax
movb $0x0, (%rax,%r13)
movl (%r14,%r15,4), %eax
incl %edi
xorl %r13d, %r13d
movq %r14, -0x50(%rbp)
movl %edi, -0x2c(%rbp)
movl %eax, -0x3c(%rbp)
movq -0x48(%rbp), %r15
cmpl %eax, (%r14,%r13,4)
jne 0x7962
movb $0x1, (%r15,%r13)
movq -0x68(%rbp), %rcx
movb %r13b, (%rcx)
movslq %ebx, %rax
movq -0x58(%rbp), %rdx
movb (%rdx,%rax), %al
movq -0x38(%rbp), %r14
movb %al, (%r14)
movl $0x1, %esi
movq %r15, %r8
movq %r14, %r9
pushq %r12
pushq -0x60(%rbp)
callq 0x7090
movl -0x3c(%rbp), %eax
movl -0x2c(%rbp), %edi
addq $0x10, %rsp
movb %r13b, (%r14)
movq -0x50(%rbp), %r14
movb $0x0, (%r15,%r13)
incq %r13
addl %edi, %ebx
cmpq %r13, %r12
jne 0x7914
jmp 0x7974
movl %eax, %eax
movb $0x0, (%rsi,%rax)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop