// File: /workspace/github_c_makefile_star2_O0/ComplexNetworks-DCC-FCUP[P]fase/Fase.cpp
// Function: Fase::expandEnumeration(int, int, long long)
void Fase::expandEnumeration(int depth, int labelNode, long long int label)
{
  if (depth == K - 1)
  {
    while (vextSz[depth])
    {
      int currentVertex = vext[depth][--vextSz[depth]];

      if (!sampling || Random::testProb(sampProb[depth]))
      {
        long long int clabel = Label::updateLabel(vsub, currentVertex, depth);
        igtrie.incrementLabel(igtrie.insertLabel(labelNode, clabel, Label::repDigits(depth)), 1);

        motifCount++;
      }
    }

    return;
  }

  int i, j;
  long long int clabel = label;
  int clabelNode = labelNode;

  for (i = 0; i < vextSz[depth]; i++)
    vext[depth + 1][i] = vext[depth][i];

  while (vextSz[depth])
  {
    int currentVertex = vext[depth][--vextSz[depth]];

    if (!sampling || Random::testProb(sampProb[depth]))
    {
      vextSz[depth + 1] = vextSz[depth];
      vsub[depth] = currentVertex;

      int *eExcl = graph->arrayNeighbours(currentVertex);
      int eExclNum = graph->numNeighbours(currentVertex);
      
      for (i = 0; i < eExclNum; i++)
      {
        if (eExcl[i] <= vsub[0])
          continue;

        for (j = 0; j < depth; j++)
          if (eExcl[i] == vsub[j] || graph->isConnected(eExcl[i], vsub[j]))
            break;

        if (j == depth)
          vext[depth + 1][vextSz[depth + 1]++] = eExcl[i];
      }

      if (depth >= 1)
      {
        clabel = Label::updateLabel(vsub, currentVertex, depth);
        clabelNode = igtrie.insertLabel(labelNode, clabel, Label::repDigits(depth));
      }

      expandEnumeration(depth + 1, clabelNode, clabel);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x58(%rbp)
movl -0xc(%rbp), %eax
movl 0x10(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3cd5
jmp 0x3be4
movq -0x58(%rbp), %rax
movq 0x88(%rax), %rax
movslq -0xc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x3cd0
movq -0x58(%rbp), %rax
movq 0x80(%rax), %rcx
movslq -0xc(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x88(%rax), %rsi
movslq -0xc(%rbp), %rdi
movl (%rsi,%rdi,4), %edx
addl $-0x1, %edx
movl %edx, (%rsi,%rdi,4)
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x1c(%rbp)
testb $0x1, 0x1(%rax)
je 0x3c52
movq -0x58(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x11d10
testb $0x1, %al
jne 0x3c52
jmp 0x3ccb
movq -0x58(%rbp), %rax
movq 0x90(%rax), %rdi
movl -0x1c(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0x8660
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq %rax, %rcx
addq $0x18, %rcx
movq %rcx, -0x60(%rbp)
addq $0x18, %rax
movq %rax, -0x78(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0xc(%rbp), %edi
callq 0x87b0
movq -0x78(%rbp), %rdi
movl -0x6c(%rbp), %esi
movq -0x68(%rbp), %rdx
movl %eax, %ecx
callq 0x8c20
movq -0x60(%rbp), %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0x8bf0
movq -0x58(%rbp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0x3be4
jmp 0x3f91
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x58(%rbp), %rcx
movl -0x2c(%rbp), %eax
movq 0x88(%rcx), %rcx
movslq -0xc(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x3d41
movq -0x58(%rbp), %rax
movq 0x80(%rax), %rcx
movslq -0xc(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x2c(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movq 0x80(%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3cea
jmp 0x3d43
movq -0x58(%rbp), %rax
movq 0x88(%rax), %rax
movslq -0xc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x3f91
movq -0x58(%rbp), %rax
movq 0x80(%rax), %rcx
movslq -0xc(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x88(%rax), %rsi
movslq -0xc(%rbp), %rdi
movl (%rsi,%rdi,4), %edx
addl $-0x1, %edx
movl %edx, (%rsi,%rdi,4)
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x40(%rbp)
testb $0x1, 0x1(%rax)
je 0x3db4
movq -0x58(%rbp), %rax
movq 0x98(%rax), %rax
movslq -0xc(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x11d10
testb $0x1, %al
jne 0x3db4
jmp 0x3f8c
movq -0x58(%rbp), %rax
movq 0x88(%rax), %rcx
movslq -0xc(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movq 0x88(%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movl -0x40(%rbp), %esi
movq 0x90(%rax), %rcx
movslq -0xc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x8(%rax), %rdi
movl -0x40(%rbp), %esi
movq (%rdi), %rax
callq *0xa8(%rax)
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rdi
movl -0x40(%rbp), %esi
movq (%rdi), %rax
callq *0x68(%rax)
movl %eax, -0x4c(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x3f10
movq -0x58(%rbp), %rcx
movq -0x48(%rbp), %rax
movslq -0x2c(%rbp), %rdx
movl (%rax,%rdx,4), %eax
movq 0x90(%rcx), %rcx
cmpl (%rcx), %eax
jg 0x3e47
jmp 0x3f02
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3eb1
movq -0x58(%rbp), %rcx
movq -0x48(%rbp), %rax
movslq -0x2c(%rbp), %rdx
movl (%rax,%rdx,4), %eax
movq 0x90(%rcx), %rcx
movslq -0x30(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x3ea2
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x48(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movq 0x90(%rax), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq (%rdi), %rax
callq *0x50(%rax)
testb $0x1, %al
jne 0x3ea2
jmp 0x3ea4
jmp 0x3eb1
jmp 0x3ea6
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3e4e
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x3f00
movq -0x58(%rbp), %rcx
movq -0x48(%rbp), %rax
movslq -0x2c(%rbp), %rdx
movl (%rax,%rdx,4), %edx
movq 0x80(%rcx), %rax
movl -0xc(%rbp), %esi
addl $0x1, %esi
movslq %esi, %rsi
movq (%rax,%rsi,8), %rax
movq 0x88(%rcx), %rsi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rdi
movl (%rsi,%rdi,4), %ecx
movl %ecx, %r8d
addl $0x1, %r8d
movl %r8d, (%rsi,%rdi,4)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3f02
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3e1c
cmpl $0x1, -0xc(%rbp)
jl 0x3f76
movq -0x58(%rbp), %rax
movq 0x90(%rax), %rdi
movl -0x40(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0x8660
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, -0x38(%rbp)
addq $0x18, %rax
movq %rax, -0x90(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0xc(%rbp), %edi
callq 0x87b0
movq -0x90(%rbp), %rdi
movl -0x84(%rbp), %esi
movq -0x80(%rbp), %rdx
movl %eax, %ecx
callq 0x8c20
movl %eax, -0x3c(%rbp)
movq -0x58(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x1, %esi
movl -0x3c(%rbp), %edx
movq -0x38(%rbp), %rcx
callq 0x3bb0
jmp 0x3d43
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)