// File: /workspace/github_c_makefile_star2_O2/ComplexNetworks-DCC-FCUP[P]gtrieScanner/Conditions.cpp
// Function: Conditions::isomorphicExtensions()
void Conditions::isomorphicExtensions() {
  int i, j, cand[_subgraph_size], ncand;
  int *v, num;

  if (pos == _subgraph_size) {

    smallNode *v = new smallNode[_subgraph_size];
    for (i=0; i<fastf->numf; i++) v[i]=fastf->f[i];
    fastvv->push_back(v);

  } else {    

    list<iPair>::iterator ii;
    int n, m;
    int flag;

    int count[_subgraph_size];

    ncand=0;
    for (i=0; i<_subgraph_size; i++) count[i]=0;

    for (i=0; i<_subgraph_size; i++)     // For all nodes of H already mapped
      if (fastf->f[i]!=INVALID) {        // find their not mapped neighbours
	v = fastg->arrayNeighbours(i);    
	num = fastg->numNeighbours(i);
	for (j=0; j<num; j++)
	  if (fastf->f[v[j]]==INVALID) {
	    if (count[v[j]]==0) 
	      cand[ncand++]=v[j];	    
	    count[v[j]]++;
	  }	
      }

   // Find most constrained neighbour 'm' (with more mapped neighbours)
    m = 0;
    for (i=1; i<ncand; i++)    
      if (count[i]>count[m])  // Later: add more restraining conditions??
	m = i;
    m = cand[m];

    ncand=0;
    bool already[_subgraph_size];
    for (i=0; i<_subgraph_size; i++) already[i]=false;

    for (i=0; i<_subgraph_size; i++)  // For all nodes of G already mapped
      if (fastf->f[i]!=INVALID) {         // find their not mapped neighbours 
	v = fastg->arrayNeighbours(fastf->f[i]);    
	num = fastg->numNeighbours(fastf->f[i]);    
	for (j=0; j<num; j++)
	  if (!already[v[j]] && fastf->r[v[j]]==INVALID && fasts[m*_subgraph_size+v[j]])  {
	    cand[ncand++]=v[j];
	    already[v[j]]=true;
	  }
      }
        
    for (i=0; i<ncand; i++) {
      n = cand[i];

      flag = false;

      for (j=0; j<_subgraph_size; j++)
	if (fastf->f[j]!=INVALID) {
	  if      (adj[m][j] != adj[n][fastf->f[j]])      {flag=true; break;}
	  else if (adj[j][m] != adj[fastf->f[j]][n])      {flag=true; break;}
	}

      if (!flag) {	
	fastf->add(m, n);
	pos++;
	isomorphicExtensions();
	pos--;
	fastf->remove(m);
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl 0x136c7(%rip), %eax     # 0x197f4
movq %rsp, %rdx
leaq 0xf(,%rax,4), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, -0x30(%rbp)
movq %rdx, %rsp
cmpl %eax, 0x136ac(%rip)     # 0x197f8
jne 0x617c
movslq %eax, %rdi
callq 0x2030
movq %rax, -0x48(%rbp)
xorl %ecx, %ecx
movq 0x1369d(%rip), %rdx     # 0x19800
movslq (%rdx), %rsi
cmpq %rsi, %rcx
jge 0x61ab
movq 0x8(%rdx), %rsi
movb (%rsi,%rcx,4), %sil
movb %sil, (%rax,%rcx)
incq %rcx
jmp 0x6163
movq %rsp, -0x40(%rbp)
movq %rsp, %r13
subq %rcx, %r13
movq %r13, %rsp
movl 0x13665(%rip), %ecx     # 0x197f4
xorl %eax, %eax
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
cmpq %rax, %rdx
je 0x61c0
andl $0x0, (%r13,%rax,4)
incq %rax
jmp 0x619b
movq 0x1365e(%rip), %rdi     # 0x19810
leaq -0x48(%rbp), %rsi
callq 0x6630
jmp 0x6451
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r12d, %r12d
movslq %ecx, %rax
cmpq %rax, %rbx
jge 0x6262
movq 0x13625(%rip), %rax     # 0x19800
movq 0x8(%rax), %rax
cmpl $-0x1, (%rax,%rbx,4)
je 0x625a
movq 0x1361c(%rip), %rdi     # 0x19808
movq (%rdi), %rax
movl %ebx, %esi
callq *0xa8(%rax)
movq %rax, %r14
movq 0x13607(%rip), %rdi     # 0x19808
movq (%rdi), %rax
movl %ebx, %esi
callq *0x70(%rax)
movq 0x135f0(%rip), %rdx     # 0x19800
testl %eax, %eax
cmovlel %r15d, %eax
movl 0x135d8(%rip), %ecx     # 0x197f4
xorl %esi, %esi
cmpq %rsi, %rax
je 0x625a
movq 0x8(%rdx), %r8
movl (%r14,%rsi,4), %r9d
movslq %r9d, %rdi
cmpl $-0x1, (%r8,%rdi,4)
jne 0x6255
movl (%r13,%rdi,4), %r8d
testl %r8d, %r8d
jne 0x624d
movslq %r12d, %r10
incl %r12d
movq -0x30(%rbp), %r11
movl %r9d, (%r11,%r10,4)
incl %r8d
movl %r8d, (%r13,%rdi,4)
incq %rsi
jmp 0x621e
incq %rbx
jmp 0x61c8
movslq %r12d, %rax
xorl %esi, %esi
pushq $0x1
popq %rdx
movslq %esi, %rdi
cmpq %rax, %rdx
jge 0x628c
movl (%r13,%rdx,4), %r9d
movl %edx, %r8d
cmpl (%r13,%rdi,4), %r9d
jg 0x6284
movl %esi, %r8d
incq %rdx
movl %r8d, %esi
jmp 0x626a
movq -0x30(%rbp), %rax
movl (%rax,%rdi,4), %eax
movl %eax, -0x34(%rbp)
movslq %eax, %r14
movl %ecx, %eax
movq %rsp, %r12
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
xorl %eax, %eax
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
cmpq %rax, %rdx
je 0x62c7
movb $0x0, (%r12,%rax)
incq %rax
jmp 0x62b8
xorl %r15d, %r15d
xorl %r13d, %r13d
movslq %ecx, %rax
cmpq %rax, %r15
jge 0x6394
movq 0x13520(%rip), %rax     # 0x19800
movq 0x8(%rax), %rax
movl (%rax,%r15,4), %esi
cmpl $-0x1, %esi
je 0x638c
movq 0x13510(%rip), %rdi     # 0x19808
movq (%rdi), %rax
callq *0xa8(%rax)
movq %rax, %rbx
movq 0x134fd(%rip), %rdi     # 0x19808
movq 0x134ee(%rip), %rax     # 0x19800
movq 0x8(%rax), %rax
movl (%rax,%r15,4), %esi
movq (%rdi), %rax
callq *0x70(%rax)
movq 0x134d9(%rip), %rdx     # 0x19800
movq 0x134ea(%rip), %rsi     # 0x19818
movl 0x134c0(%rip), %ecx     # 0x197f4
movl %ecx, %edi
imull -0x34(%rbp), %edi
testl %eax, %eax
movl $0x0, %r8d
cmovlel %r8d, %eax
xorl %r8d, %r8d
cmpq %r8, %rax
je 0x638c
movl (%rbx,%r8,4), %r10d
movslq %r10d, %r9
cmpb $0x0, (%r12,%r9)
jne 0x6387
movq 0x10(%rdx), %r11
cmpl $-0x1, (%r11,%r9,4)
jne 0x6387
addl %edi, %r10d
movslq %r10d, %r10
cmpb $0x1, (%rsi,%r10)
jne 0x6387
movslq %r13d, %r10
incl %r13d
movq -0x30(%rbp), %r11
movl %r9d, (%r11,%r10,4)
movb $0x1, (%r12,%r9)
incq %r8
jmp 0x6349
incq %r15
jmp 0x62cd
xorl %ebx, %ebx
testl %r13d, %r13d
cmovlel %ebx, %r13d
xorl %r15d, %r15d
cmpq %r13, %r15
je 0x644d
movq -0x30(%rbp), %rax
movl (%rax,%r15,4), %ecx
movl 0x1343d(%rip), %edx     # 0x197f4
movq 0x13442(%rip), %rax     # 0x19800
movq 0x1345b(%rip), %rsi     # 0x19820
movslq %ecx, %rcx
testl %edx, %edx
cmovlel %ebx, %edx
movq 0x8(%rax), %rdi
xorl %r8d, %r8d
cmpq %r8, %rdx
je 0x640c
movslq (%rdi,%r8,4), %r9
cmpq $-0x1, %r9
je 0x6407
movq (%rsi,%r14,8), %r10
movb (%r10,%r8), %r10b
movq (%rsi,%rcx,8), %r11
cmpb (%r11,%r9), %r10b
jne 0x6445
movq (%rsi,%r8,8), %r10
movb (%r10,%r14), %r10b
movq (%rsi,%r9,8), %r9
cmpb (%r9,%rcx), %r10b
jne 0x6445
incq %r8
jmp 0x63d4
movl %ecx, (%rdi,%r14,4)
movq 0x10(%rax), %rax
movl %r14d, (%rax,%rcx,4)
incl 0x133da(%rip)           # 0x197f8
callq 0x6116
decl 0x133cf(%rip)           # 0x197f8
movq 0x133d0(%rip), %rax     # 0x19800
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rax
movslq (%rcx,%r14,4), %rdx
orl $-0x1, (%rax,%rdx,4)
orl $-0x1, (%rcx,%r14,4)
incq %r15
jmp 0x63a0
movq -0x40(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq