// File: /workspace/github_c_makefile_star2_O0/ComplexNetworks-DCC-FCUP[P]gtrieScanner/CmdLine.cpp
// Function: CmdLine::compute_results()
void CmdLine::compute_results() {
  int i, j;
  mapStringInt:: const_iterator ii, iiend;

  // Create map and init results
  mapStringInt m_original;  
  sg_original.populateMap(&m_original, motif_size);
  ResultType res[m_original.size()];
  for (ii=m_original.begin(), iiend=m_original.end(), i=0; ii!=iiend; ii++, i++) {
    res[i].s = strdup((ii->first).c_str());    
    res[i].f_original = ii->second;
    res[i].z_score = res[i].avg_random = res[i].dev_random = 0;
  }

  // Do we have random networks to compute?
  if (random_number > 0) {
    gt = new GTrie;
    sg_original.populateGTrieNauty(gt, motif_size, dir);
    
    mapStringInt m_count[random_number];

    // Generate all random networks
    printf("Computing random networks: ");
    time_random = 0;
    for (i=0; i<random_number; i++) {      

      // Create new random network from previous one
      g->makeVectorNeighbours();
      Random::markovChainPerEdge(g, random_exchanges, random_tries);
      g->sortNeighbours();
      g->makeArrayNeighbours();

      // Compute census
      Timer::start(0);
      gt->census(g);
      Timer::stop(0);
      time_random += Timer::elapsed(0);
      gt->populateMap(&m_count[i], motif_size);
      fputc('.', stdout);      
    }
    fputc('\n', stdout);
    time_random /= (double)random_number;
    printf("Avg time per random network: %.6fs\n\n", time_random);

    // Compute significance
    for (ii=m_original.begin(), iiend=m_original.end(), i=0; ii!=iiend; ii++, i++) {
      // Average frequency
      double avg = 0;
      for (j=0; j<random_number; j++)
	avg += m_count[j][ii->first];
      avg /= random_number;

      // Standard deviation
      double dev=0;
      for (j=0; j<random_number; j++)
	dev += double(m_count[j][ii->first]-avg)*double(m_count[j][ii->first]-avg)/double(random_number-1);
      dev = sqrt(dev);

      // zscore
      double zscore = (ii->second - avg)/dev;

      res[i].avg_random = avg;
      res[i].dev_random = dev;
      res[i].z_score    = zscore;
    }
  }

  // Sort results
  qsort(res, m_original.size(), sizeof(ResultType), compare_results);

  // print results
  show_results(res, m_original.size());
  printf("Results written to file \"%s\"\n", output_file);
  if (occurrences)
    printf("Occurences on original network written to file \"%s\"\n", occ_file);

  for (i=0; i<(int)m_original.size(); i++)
    free(res[i].s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
leaq -0x10(%rbp), %rdi
callq 0x5ff0
leaq -0x18(%rbp), %rdi
callq 0x5ff0
leaq -0x48(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x6010
movq -0xe8(%rbp), %rsi
movl 0x28f3a(%rip), %edx     # 0x2d194
leaq 0x28f8f(%rip), %rdi     # 0x2d1f0
callq 0x19f30
jmp 0x4268
leaq -0x48(%rbp), %rdi
callq 0x6030
movq %rax, %rcx
movq %rcx, %rax
movq %rsp, %rdx
movq %rdx, -0x60(%rbp)
leaq (%rcx,%rcx,4), %rcx
leaq 0xf(,%rcx,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xf0(%rbp)
movq %rcx, %rsp
movq %rax, -0x68(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x6050
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x6080
movq -0x70(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x60a0
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x6080
movq -0x80(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x4(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x60d0
testb $0x1, %al
jne 0x4309
jmp 0x43d1
leaq -0x10(%rbp), %rdi
callq 0x6100
movq %rax, %rdi
callq 0x30f0
movq %rax, %rdi
callq 0x3490
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movslq -0x4(%rbp), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
leaq -0x10(%rbp), %rdi
callq 0x6100
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movl 0x20(%rcx), %edx
movslq -0x4(%rbp), %rcx
imulq $0x28, %rcx, %rsi
movq %rax, %rcx
addq %rsi, %rcx
movl %edx, 0x8(%rcx)
movslq -0x4(%rbp), %rcx
imulq $0x28, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rcx)
movslq -0x4(%rbp), %rcx
imulq $0x28, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rcx)
movslq -0x4(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax)
leaq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x6130
movq %rax, -0x90(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x42f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4ad8
cmpl $0x0, 0x28dc0(%rip)     # 0x2d198
jle 0x4a00
movl $0x8, %edi
callq 0x3270
movq %rax, -0xf8(%rbp)
jmp 0x43f1
movq -0xf8(%rbp), %rdi
callq 0x13610
jmp 0x43ff
movq -0xf8(%rbp), %rax
movq %rax, 0x28dd3(%rip)     # 0x2d1e0
movq 0x28dcc(%rip), %rsi     # 0x2d1e0
movl 0x28d7a(%rip), %edx     # 0x2d194
movzbl 0x28d6f(%rip), %ecx     # 0x2d190
andl $0x1, %ecx
leaq 0x28dc5(%rip), %rdi     # 0x2d1f0
callq 0x19f90
jmp 0x4432
movl 0x28d60(%rip), %eax     # 0x2d198
movq %rax, -0x108(%rbp)
movq %rsp, %rcx
movq %rcx, -0x98(%rbp)
movq %rax, %rcx
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x100(%rbp)
movq %rcx, %rsp
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x44c8
movq -0x100(%rbp), %rax
movq -0x108(%rbp), %rcx
imulq $0x30, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x118(%rbp)
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x6010
movq -0x120(%rbp), %rax
movq -0x118(%rbp), %rcx
addq $0x30, %rax
cmpq %rcx, %rax
movq %rax, -0x110(%rbp)
jne 0x4497
leaq 0x1bdfe(%rip), %rdi     # 0x202cd
xorl %eax, %eax
callq 0x3060
jmp 0x44d8
xorps %xmm0, %xmm0
movsd %xmm0, 0x28ccd(%rip)    # 0x2d1b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x28ca5(%rip), %eax     # 0x2d198
jge 0x464c
movq 0x28cc8(%rip), %rdi     # 0x2d1c8
movq (%rdi), %rax
movq 0x90(%rax), %rax
callq *%rax
jmp 0x450e
movq 0x28cb3(%rip), %rdi     # 0x2d1c8
movl 0x28c85(%rip), %esi     # 0x2d1a0
movl 0x28c83(%rip), %edx     # 0x2d1a4
callq 0x18d00
jmp 0x4528
movq 0x28c99(%rip), %rdi     # 0x2d1c8
movq (%rdi), %rax
movq 0x78(%rax), %rax
callq *%rax
jmp 0x453a
movq 0x28c87(%rip), %rdi     # 0x2d1c8
movq (%rdi), %rax
movq 0x88(%rax), %rax
callq *%rax
jmp 0x454f
xorl %edi, %edi
callq 0x18b40
jmp 0x4558
movq 0x28c81(%rip), %rdi     # 0x2d1e0
movq 0x28c62(%rip), %rsi     # 0x2d1c8
callq 0x13cc0
jmp 0x456d
xorl %edi, %edi
callq 0x18b80
jmp 0x4576
xorl %edi, %edi
callq 0x18bc0
movsd %xmm0, -0x128(%rbp)
jmp 0x4587
movq -0x100(%rbp), %rsi
movsd -0x128(%rbp), %xmm1
movsd 0x28c12(%rip), %xmm0    # 0x2d1b0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28c06(%rip)    # 0x2d1b0
movq 0x28c2f(%rip), %rdi     # 0x2d1e0
movslq -0x4(%rbp), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rax, %rsi
movl 0x28bce(%rip), %edx     # 0x2d194
callq 0x14140
jmp 0x45cd
movq 0x269ec(%rip), %rax     # 0x2afc0
movq (%rax), %rsi
movl $0x2e, %edi
callq 0x3350
jmp 0x45e3
jmp 0x45e5
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x44ea
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0x8, %esi
callq 0x3280
jmp 0x4ad8
movq -0x100(%rbp), %rcx
movq %rax, %rsi
movq -0x108(%rbp), %rax
movq %rsi, -0x50(%rbp)
movl %edx, -0x54(%rbp)
imulq $0x30, %rax, %rdx
movq %rcx, %rax
addq %rdx, %rax
cmpq %rax, %rcx
movq %rax, -0x130(%rbp)
je 0x49fb
jmp 0x49ca
movq 0x2696d(%rip), %rax     # 0x2afc0
movq (%rax), %rsi
movl $0xa, %edi
callq 0x3350
jmp 0x4662
cvtsi2sdl 0x28b2e(%rip), %xmm1 # 0x2d198
movsd 0x28b3e(%rip), %xmm0    # 0x2d1b0
divsd %xmm1, %xmm0
movsd %xmm0, 0x28b32(%rip)    # 0x2d1b0
movsd 0x28b2a(%rip), %xmm0    # 0x2d1b0
leaq 0x1bc5c(%rip), %rdi     # 0x202e9
movb $0x1, %al
callq 0x3060
jmp 0x4696
leaq -0x48(%rbp), %rdi
callq 0x6050
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x6080
movq -0xa8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x60a0
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x6080
movq -0xb8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x4(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x60d0
testb $0x1, %al
jne 0x470f
jmp 0x4969
xorps %xmm0, %xmm0
movsd %xmm0, -0xc8(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl 0x28a6e(%rip), %eax     # 0x2d198
jge 0x4790
movq -0x100(%rbp), %rax
movslq -0x8(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x140(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x6100
movq -0x140(%rbp), %rdi
movq %rax, %rsi
callq 0x6170
movq %rax, -0x138(%rbp)
jmp 0x476a
movq -0x138(%rbp), %rax
cvtsi2sdl (%rax), %xmm0
addsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x4721
cvtsi2sdl 0x28a00(%rip), %xmm1 # 0x2d198
movsd -0xc8(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xd0(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl 0x289d1(%rip), %eax     # 0x2d198
jge 0x48b6
movq -0x100(%rbp), %rax
movslq -0x8(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x150(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x6100
movq -0x150(%rbp), %rdi
movq %rax, %rsi
callq 0x6170
movq %rax, -0x148(%rbp)
jmp 0x480b
movq -0x100(%rbp), %rax
movq -0x148(%rbp), %rcx
cvtsi2sdl (%rcx), %xmm0
movsd -0xc8(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x168(%rbp)
movslq -0x8(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x160(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x6100
movq -0x160(%rbp), %rdi
movq %rax, %rsi
callq 0x6170
movq %rax, -0x158(%rbp)
jmp 0x4868
movsd -0x168(%rbp), %xmm0
movq -0x158(%rbp), %rax
cvtsi2sdl (%rax), %xmm1
subsd -0xc8(%rbp), %xmm1
mulsd %xmm1, %xmm0
movl 0x2890b(%rip), %eax     # 0x2d198
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
addsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x47be
movsd -0xd0(%rbp), %xmm0
callq 0x31f0
movsd %xmm0, -0xd0(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x6100
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cvtsi2sdl 0x20(%rcx), %xmm0
subsd -0xc8(%rbp), %xmm0
divsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0xc8(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
imulq $0x28, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movsd %xmm0, 0x10(%rcx)
movsd -0xd0(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
imulq $0x28, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movsd %xmm0, 0x18(%rcx)
movsd -0xd8(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
leaq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x6130
movq %rax, -0xe0(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x46f9
movq -0x100(%rbp), %rcx
movq -0x108(%rbp), %rax
imulq $0x30, %rax, %rdx
movq %rcx, %rax
addq %rdx, %rax
cmpq %rax, %rcx
movq %rax, -0x170(%rbp)
je 0x49be
movq -0x170(%rbp), %rdi
addq $-0x30, %rdi
movq %rdi, -0x178(%rbp)
callq 0x6250
movq -0x100(%rbp), %rcx
movq -0x178(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x170(%rbp)
jne 0x498d
movq -0x98(%rbp), %rax
movq %rax, %rsp
jmp 0x4a00
movq -0x130(%rbp), %rdi
addq $-0x30, %rdi
movq %rdi, -0x180(%rbp)
callq 0x6250
movq -0x100(%rbp), %rcx
movq -0x180(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x130(%rbp)
jne 0x49ca
jmp 0x4ad8
leaq -0x48(%rbp), %rdi
callq 0x6030
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
leaq -0xcca(%rip), %rcx      # 0x3d50
movl $0x28, %edx
callq 0x34b0
jmp 0x4a26
leaq -0x48(%rbp), %rdi
callq 0x6030
movq -0xf0(%rbp), %rdi
movl %eax, %esi
callq 0x4af0
jmp 0x4a3f
leaq 0x1b8c8(%rip), %rdi     # 0x2030e
leaq 0x27f43(%rip), %rsi     # 0x2c990
xorl %eax, %eax
callq 0x3060
jmp 0x4a56
testb $0x1, 0x28734(%rip)     # 0x2d191
je 0x4a78
leaq 0x1b8c6(%rip), %rdi     # 0x2032c
leaq 0x28323(%rip), %rsi     # 0x2cd90
xorl %eax, %eax
callq 0x3060
jmp 0x4a76
jmp 0x4a78
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x184(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x6030
movq %rax, %rcx
movl -0x184(%rbp), %eax
cmpl %ecx, %eax
jge 0x4ac3
movq -0xf0(%rbp), %rax
movslq -0x4(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x3320
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x4a7f
movq -0x60(%rbp), %rax
movq %rax, %rsp
leaq -0x48(%rbp), %rdi
callq 0x6250
movq %rbp, %rsp
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x6250
movq -0x50(%rbp), %rdi
callq 0x3440
nopw (%rax,%rax)