// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movl %edx, %r8d
movl %edx, %r12d
movq %rsp, %rbx
leaq 0xf(,%r12,4), %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rsp, %rcx
leaq 0xf(%r12), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x50(%rbp)
movq %rcx, %rsp
movl %edx, %r13d
imull %r13d, %r13d
movq %rsp, %r9
leaq 0x10(%r13), %rcx
andq $-0x10, %rcx
subq %rcx, %r9
movq %r9, %rsp
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x40(%rbp)
movq %rcx, %rsp
xorl %r14d, %r14d
testl %edx, %edx
jle 0x77b4
movq %rdi, %rax
xorl %ecx, %ecx
movl $0x0, (%rbx,%rcx,4)
xorl %r11d, %r11d
xorl %edx, %edx
movsbl (%rax,%r11), %r10d
addl %r10d, %edx
addl $-0x30, %edx
incq %r11
cmpq %r11, %r12
jne 0x7785
movl %edx, (%rbx,%rcx,4)
movslq %r14d, %r14
cmpl (%rbx,%r14,4), %edx
cmovgl %ecx, %r14d
incq %rcx
addq %r12, %rax
cmpq %r12, %rcx
jne 0x7779
movslq %r14d, %r14
testl %r8d, %r8d
je 0x77db
movslq %r13d, %rcx
cmpl $0x1, %ecx
leaq -0x1(%rcx,%rdi), %rax
adcl $0x0, %ecx
xorl %edx, %edx
movb (%rax), %r10b
movb %r10b, (%rsi,%rdx)
incq %rdx
decq %rax
cmpq %rdx, %rcx
jne 0x77c9
movq %rdi, -0x58(%rbp)
movl %r13d, %r15d
movq %rsi, -0x60(%rbp)
movb $0x0, (%rsi,%r15)
testl %r8d, %r8d
movq %r9, -0x38(%rbp)
jle 0x7814
movq -0x40(%rbp), %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r13, -0x30(%rbp)
movl %r8d, %r13d
callq 0x2120
movq -0x38(%rbp), %r9
movl %r13d, %r8d
movq -0x30(%rbp), %r13
testl %r8d, %r8d
je 0x783b
cmpl $0x1, %r13d
adcl $0x0, %r13d
movq %r9, %rdi
movl $0x32, %esi
movq %r13, %rdx
movl %r8d, %r13d
callq 0x2120
movq -0x38(%rbp), %r9
movl %r13d, %r8d
movb $0x0, (%r9,%r15)
testl %r8d, %r8d
jle 0x78b6
movl (%rbx,%r14,4), %eax
incl %r8d
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rbx, -0x48(%rbp)
movl %eax, -0x30(%rbp)
cmpl %eax, (%rbx,%r13,4)
jne 0x78ab
movq -0x40(%rbp), %rbx
movb $0x1, (%rbx,%r13)
movq -0x50(%rbp), %rcx
movb %r13b, (%rcx)
movslq %r15d, %rax
movq -0x58(%rbp), %rdx
movb (%rdx,%rax), %al
movb %al, (%r9)
movl $0x1, %esi
movl %r8d, %r14d
movq %rbx, %r8
pushq %r12
pushq -0x60(%rbp)
callq 0x6f9c
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %r9
movl %r14d, %r8d
addq $0x10, %rsp
movb %r13b, (%r9)
movb $0x0, (%rbx,%r13)
movq -0x48(%rbp), %rbx
incq %r13
addl %r8d, %r15d
cmpq %r13, %r12
jne 0x7859
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop