// File: /workspace/github_c_makefile_star2_O2/ComplexNetworks-DCC-FCUP[P]gtrieScanner/CmdLine.cpp
// Function: CmdLine::show_results(ResultType*, int)
void CmdLine::show_results(ResultType *res, int nres) {
  int i, j, k;
  bool html = (output==HTML)?true:false;

  if (html) fprintf(f_output, "<html><head>\n"
		    "<title>%s results</title>\n"
		    "<style type=\"text/css\">"
		    "p,body,td,th,li  {font-size: 13px; font-family: arial, geneva, \"sans serif\";color: black; font-weight: normal;}\n"
		    "body, tr {background-color: #fbfbfb;}\n"
		    "hr {color: black;}\n"
		    "table {background-color: black;}\n"
		    "th {color:white;}\n"
		    "td {text-align: right;}\n"
		    ".odd  {background-color: #d1d1d1;}\n"
		    ".even {background-color: #f2f2f2;}\n"
		    ".hd   {background-color: #444444; color: white;}\n"
		    ".pre  {white-space: pre;}\n"
		    "</style>"
		    "</head>\n<body>",
		    PROGRAM_NAME);

  fprintf(f_output, "%s%s Results%s\n", html?"<h1>":"", PROGRAM_NAME, html?"</h1>":"");
  
  if (html) fprintf(f_output, "<hr>\n");
  else      fprintf(f_output, "%s\n", SEPARATOR);

  fprintf(f_output, "%sGeneral Information%s\n", html?"<h2>":"", html?"</h2>":"\n");

  time_t t_end = time(0);
  struct tm *tm_start = localtime(&t_start);
  fprintf(f_output, "%sStart of Computation:%s %02dh%02dm%02ds %02d/%02d/%02d\n",
	  html?"<li><b>":"",html?"</b>":"",
	  tm_start->tm_hour, tm_start->tm_min, tm_start->tm_sec,
	  tm_start->tm_mday, tm_start->tm_mon+1, 1900+tm_start->tm_year);
  struct tm *tm_end   = localtime(&t_end);
  fprintf(f_output, "%sEnd of Computation:%s %02dh%02dm%02ds %02d/%02d/%02d\n",
	  html?"<li><b>":"",html?"</b>":"",
	  tm_end->tm_hour, tm_end->tm_min, tm_end->tm_sec,
	  tm_end->tm_mday, tm_end->tm_mon+1, 1900+tm_end->tm_year);

  if (html) fprintf(f_output, "<br>&nbsp;\n");
  else      fprintf(f_output, "\n");

  fprintf(f_output, "%sSubgraph Size:%s %d\n", html?"<li><b>":"", html?"</b>":"", motif_size);
  fprintf(f_output, "%sGraph File:%s \"%s\"\n", html?"<li><b>":"", html?"</b>":"",graph_file);
  fprintf(f_output, "%sDirected:%s %s\n", html?"<li><b>":"", html?"</b>":"",dir?"YES":"NO");
  fprintf(f_output, "%sNr Nodes:%s %d\n", html?"<li><b>":"", html?"</b>":"",g->numNodes());
  fprintf(f_output, "%sNr Edges:%s %d\n", html?"<li><b>":"", html?"</b>":"",dir?g->numEdges():g->numEdges()/2);
  
  if (html) fprintf(f_output, "<br>&nbsp;\n");
  else      fprintf(f_output, "\n");

  fprintf(f_output, "%sMethod:%s ", html?"<li><b>":"", html?"</b>":"");
  if (method == ESU)
    fprintf(f_output, "ESU on original network\n");
  else if (method == GTRIE)
    fprintf(f_output, "GTRIE with file containing complete g-trie\n");
  else if (method == SUBGRAPHS)
    fprintf(f_output, "GTRIE with subgraphs read from file\n");

  fprintf(f_output, "%sDifferent Types of Subgraphs Found [Original Network]:%s %d\n", html?"<li><b>":"", html?"</b>":"", sg_original.countGraphs());
  fprintf(f_output, "%sSubgraph Occurrences Found [Original Network]:%s %.0f\n", html?"<li><b>":"", html?"</b>":"", sg_original.countOccurrences());
  fprintf(f_output, "%sTime for computing census on original network%s: %.6fs\n", html?"<li><b>":"", html?"</b>":"", time_original);
  fprintf(f_output, "%sAverage time for census on random network%s: %.6fs\n", html?"<li><b>":"", html?"</b>":"", time_random);

  if (html) fprintf(f_output, "<br>&nbsp;\n");
  else      fprintf(f_output, "\n");

  fprintf(f_output, "%sNumber of random networks:%s %d\n", html?"<li><b>":"", html?"</b>":"", random_number);
  fprintf(f_output, "%sRandom seed:%s %d\n", html?"<li><b>":"", html?"</b>":"", random_seed);
  fprintf(f_output, "%sExchanges per edge:%s %d\n", html?"<li><b>":"", html?"</b>":"", random_exchanges);
  fprintf(f_output, "%sNumber of tries per exchange:%s %d\n", html?"<li><b>":"", html?"</b>":"", random_tries);

  if (html) fprintf(f_output, "<hr>\n");
  else      fprintf(f_output, "%s\n", SEPARATOR);

  fprintf(f_output, "%sMotif Analysis Results%s\n", html?"<h2>":"", html?"</h2>":"");

  char adj[motif_size*motif_size+motif_size];

  if (html) fprintf(f_output, "<table cellpadding=\"3\" cellspacing=\"2\">\n<tr class=\"hd\"><th colspan=\"2\">Subgraph</th><th>Org. Frequency</th><th>Z-score</th><th>Rnd. Frequency</th></tr>\n");
  else fprintf(f_output, "\nGraph%*s   Org_Freq |  Z-score |    Rnd_Avg +/-    Rnd_Dev\n\n", motif_size>5?motif_size-5:0, "");
  for (i=0; i<nres; i++) {

    for (j=0, k=0; res[i].s[j]; j++, k++) {
      if (j>0 && j%motif_size==0) adj[k++] = '\n';
      adj[k] = res[i].s[j];
    }
    adj[k]=0;

    if (html) 
      fprintf(f_output, "<tr class=\"%s\"><td><img src=\"http://www.dcc.fc.up.pt/gtries/graph.php?%swidth=75&height=75&adj=%s\"></td><td class=\"pre\">%s</td><td>%d</td><td>%.2f</td><td>%.2f +/- %.2f</td></tr>\n",
	      (i%2)?"odd":"even", dir?"dir&":"",
	      res[i].s, adj, res[i].f_original,
	      res[i].z_score, res[i].avg_random, res[i].dev_random);
    else
      fprintf(f_output, "%s%*s %10d | %8.2f | %10.2f +/- %10.2f\n\n",
	      adj, motif_size<5?5-motif_size:0, "", res[i].f_original,
	      res[i].z_score, res[i].avg_random, res[i].dev_random);
  }
  if (html) fprintf(f_output, "</table>\n");


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, -0x50(%rbp)
movq %rdi, %r14
movl 0x1648c(%rip), %eax     # 0x19750
movq 0x16495(%rip), %rdi     # 0x19760
movl %eax, -0x2c(%rbp)
cmpl $0x2, %eax
jne 0x334c
leaq 0xcff0(%rip), %rsi      # 0x102ca
leaq 0xd1c3(%rip), %rbx      # 0x104a4
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2310
movq 0x1646e(%rip), %rdi     # 0x19760
leaq 0xd1b8(%rip), %rsi      # 0x104b1
leaq 0xd1c1(%rip), %rdx      # 0x104c1
leaq 0xd1bf(%rip), %r8       # 0x104c6
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x16448(%rip), %rcx     # 0x19760
leaq 0xd1ad(%rip), %rdi      # 0x104cc
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
callq 0x2420
leaq 0xd1e5(%rip), %rdx      # 0x10516
leaq 0xd1e3(%rip), %rcx      # 0x1051b
leaq 0xd21c(%rip), %rax      # 0x1055b
movq %rax, -0x38(%rbp)
leaq 0xd219(%rip), %r12      # 0x10563
jmp 0x339b
leaq 0xd15e(%rip), %rsi      # 0x104b1
leaq 0xd14a(%rip), %rcx      # 0x104a4
leaq 0xcd47(%rip), %rbx      # 0x100a8
movq %rbx, %rdx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2310
movq 0x163eb(%rip), %rdi     # 0x19760
leaq 0xe141(%rip), %rsi      # 0x114bd
leaq 0xd14f(%rip), %rdx      # 0x104d2
xorl %eax, %eax
callq 0x2310
leaq 0xcd16(%rip), %rcx      # 0x100a7
movq %rbx, -0x38(%rbp)
movq %rbx, %r12
movq %rbx, %rdx
movq 0x163be(%rip), %rdi     # 0x19760
leaq 0xd154(%rip), %rsi      # 0x104fd
movq %rdx, -0x48(%rbp)
xorl %eax, %eax
callq 0x2310
xorl %edi, %edi
callq 0x21d0
leaq -0x58(%rbp), %rcx
movq %rax, (%rcx)
leaq 0x163bf(%rip), %rdi     # 0x19788
callq 0x2180
movq 0x1638b(%rip), %rdi     # 0x19760
movl 0x8(%rax), %r8d
movl (%rax), %r10d
movl 0x4(%rax), %r9d
movl 0xc(%rax), %r11d
movl 0x10(%rax), %ebx
incl %ebx
movl $0x76c, %r15d           # imm = 0x76C
movl 0x14(%rax), %r13d
addl %r15d, %r13d
leaq 0xd124(%rip), %rsi      # 0x10521
movq -0x38(%rbp), %rdx
movq %r12, %rcx
xorl %eax, %eax
pushq %r13
pushq %rbx
pushq %r11
pushq %r10
callq 0x2310
addq $0x20, %rsp
leaq -0x58(%rbp), %rdi
callq 0x2180
movq 0x1633a(%rip), %rdi     # 0x19760
movl 0x8(%rax), %r8d
movl (%rax), %r10d
movl 0x4(%rax), %r9d
movl 0xc(%rax), %r11d
movl 0x10(%rax), %ebx
incl %ebx
addl 0x14(%rax), %r15d
leaq 0xd123(%rip), %rsi      # 0x10568
movq -0x38(%rbp), %r13
movq %r13, %rdx
movq %r12, -0x40(%rbp)
movq %r12, %rcx
xorl %eax, %eax
pushq %r15
pushq %rbx
pushq %r11
pushq %r10
callq 0x2310
addq $0x20, %rsp
movq 0x162f4(%rip), %rcx     # 0x19760
cmpl $0x2, -0x2c(%rbp)
jne 0x3486
leaq 0xd127(%rip), %rdi      # 0x105a0
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
callq 0x2420
jmp 0x3491
pushq $0xa
popq %rdi
movq %rcx, %rsi
callq 0x22a0
movq 0x162c8(%rip), %rdi     # 0x19760
movl 0x16285(%rip), %r8d     # 0x19724
leaq 0xd106(%rip), %rsi      # 0x105ac
movq %r13, %rdx
movq -0x40(%rbp), %r12
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x162a2(%rip), %rdi     # 0x19760
leaq 0xd0fe(%rip), %rsi      # 0x105c3
leaq 0x14e54(%rip), %r8      # 0x18320
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x16280(%rip), %rdi     # 0x19760
leaq 0xd104(%rip), %rax      # 0x105eb
leaq 0xd101(%rip), %r8       # 0x105ef
cmpb $0x0, 0x1622b(%rip)     # 0x19720
cmovneq %rax, %r8
leaq 0xd0d9(%rip), %rsi      # 0x105d9
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x1624c(%rip), %rbx     # 0x19760
movq 0x1623d(%rip), %rdi     # 0x19758
movq (%rdi), %rax
callq *0x40(%rax)
leaq 0xd0ca(%rip), %rsi      # 0x105f2
movq %rbx, %rdi
movq %r13, %rdx
movq %r12, %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x2310
movq 0x1621e(%rip), %rbx     # 0x19760
movq 0x1620f(%rip), %rdi     # 0x19758
movq (%rdi), %rax
movb 0x161cd(%rip), %r15b    # 0x19720
callq *0x48(%rax)
movl %eax, %r8d
pushq $0x2
popq %rcx
cltd
idivl %ecx
testb %r15b, %r15b
cmovel %eax, %r8d
leaq 0xd097(%rip), %rsi      # 0x10604
movq %rbx, %rdi
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x161dc(%rip), %rcx     # 0x19760
cmpl $0x2, -0x2c(%rbp)
jne 0x359e
leaq 0xd00f(%rip), %rdi      # 0x105a0
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
callq 0x2420
jmp 0x35a9
pushq $0xa
popq %rdi
movq %rcx, %rsi
callq 0x22a0
movq 0x161b0(%rip), %rdi     # 0x19760
leaq 0xd05f(%rip), %rsi      # 0x10616
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movl 0x1617e(%rip), %eax     # 0x19748
cmpl $0x3, %eax
je 0x35fd
cmpl $0x2, %eax
je 0x35eb
cmpl $0x1, %eax
jne 0x3616
movq 0x16180(%rip), %rcx     # 0x19760
leaq 0xd03c(%rip), %rdi      # 0x10623
pushq $0x18
jmp 0x360d
movq 0x1616e(%rip), %rcx     # 0x19760
leaq 0xd043(%rip), %rdi      # 0x1063c
pushq $0x2b
jmp 0x360d
movq 0x1615c(%rip), %rcx     # 0x19760
leaq 0xd05d(%rip), %rdi      # 0x10668
pushq $0x24
popq %rsi
pushq $0x1
popq %rdx
callq 0x2420
movq 0x16143(%rip), %rbx     # 0x19760
leaq 0x1615c(%rip), %r15     # 0x19780
movq %r15, %rdi
callq 0xb5da
leaq 0xd05a(%rip), %rsi      # 0x1068d
movq %rbx, %rdi
movq %r13, %rdx
movq %r12, %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x2310
movq 0x16113(%rip), %rbx     # 0x19760
movq %r15, %rdi
callq 0xb5d2
leaq 0xd070(%rip), %rsi      # 0x106cc
movq %rbx, %rdi
movq %r13, %rdx
movq %r12, %rcx
movb $0x1, %al
callq 0x2310
movq 0x160ed(%rip), %rdi     # 0x19760
movsd 0x160bd(%rip), %xmm0    # 0x19738
leaq 0xd083(%rip), %rsi      # 0x10705
movq %r13, %rdx
movq %r12, %rcx
movb $0x1, %al
callq 0x2310
movq 0x160ca(%rip), %rdi     # 0x19760
movsd 0x160a2(%rip), %xmm0    # 0x19740
leaq 0xd09a(%rip), %rsi      # 0x1073f
movq %r13, %rdx
movq %r12, %rcx
movb $0x1, %al
callq 0x2310
movq 0x160a7(%rip), %rcx     # 0x19760
cmpl $0x2, -0x2c(%rbp)
jne 0x36d3
leaq 0xceda(%rip), %rdi      # 0x105a0
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
callq 0x2420
jmp 0x36de
pushq $0xa
popq %rdi
movq %rcx, %rsi
callq 0x22a0
movq 0x1607b(%rip), %rdi     # 0x19760
movl 0x1603c(%rip), %r8d     # 0x19728
leaq 0xd082(%rip), %rsi      # 0x10775
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x16059(%rip), %rdi     # 0x19760
movl 0x1601e(%rip), %r8d     # 0x1972c
leaq 0xd083(%rip), %rsi      # 0x10798
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x16037(%rip), %rdi     # 0x19760
movl 0x16000(%rip), %r8d     # 0x19730
leaq 0xd076(%rip), %rsi      # 0x107ad
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x16015(%rip), %rdi     # 0x19760
movl 0x15fe2(%rip), %r8d     # 0x19734
leaq 0xd070(%rip), %rsi      # 0x107c9
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2310
movq 0x15ff3(%rip), %rcx     # 0x19760
cmpl $0x2, -0x2c(%rbp)
jne 0x378e
leaq 0xcd52(%rip), %rdi      # 0x104cc
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
callq 0x2420
leaq 0xcd8f(%rip), %rcx      # 0x1051b
jmp 0x37ad
leaq 0xdd28(%rip), %rsi      # 0x114bd
leaq 0xcd36(%rip), %rdx      # 0x104d2
movq %rcx, %rdi
xorl %eax, %eax
callq 0x2310
leaq 0xc8fb(%rip), %rcx      # 0x100a8
movq 0x15fac(%rip), %rdi     # 0x19760
leaq 0xd034(%rip), %rsi      # 0x107ef
xorl %ebx, %ebx
movq -0x48(%rbp), %rdx
xorl %eax, %eax
callq 0x2310
movq %rsp, -0x38(%rbp)
movl 0x15f52(%rip), %eax     # 0x19724
leal 0x1(%rax), %ecx
imull %eax, %ecx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %r15
subq %rcx, %r15
movq %r15, %rsp
movq 0x15f70(%rip), %rcx     # 0x19760
cmpl $0x2, -0x2c(%rbp)
jne 0x380c
leaq 0xd00e(%rip), %rdi      # 0x1080b
pushq $0x1
popq %rdx
movl $0x98, %esi
callq 0x2420
jmp 0x3836
movl 0x15f12(%rip), %eax     # 0x19724
leal -0x5(%rax), %edx
cmpl $0x6, %eax
cmovll %ebx, %edx
leaq 0xd082(%rip), %rsi      # 0x108a4
leaq 0xc87f(%rip), %rax      # 0x100a8
movq %rcx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x2310
xorl %eax, %eax
movq -0x50(%rbp), %rbx
testl %ebx, %ebx
cmovlel %eax, %ebx
leaq 0xc860(%rip), %r12      # 0x100a8
xorl %r13d, %r13d
cmpq %rbx, %r13
je 0x394d
imulq $0x28, %r13, %rax
leaq (%r14,%rax), %rsi
movq (%r14,%rax), %r8
xorl %ecx, %ecx
movl 0x15ebb(%rip), %r9d     # 0x19724
xorl %edi, %edi
movb (%r8,%rcx), %r10b
movslq %edi, %r11
testb %r10b, %r10b
je 0x38a1
testq %rcx, %rcx
je 0x3893
movl %ecx, %eax
cltd
idivl %r9d
testl %edx, %edx
jne 0x3893
leal 0x1(%r11), %edi
movb $0xa, (%r15,%r11)
movb (%r8,%rcx), %r10b
movslq %edi, %rdi
movb %r10b, (%r15,%rdi)
incq %rcx
incl %edi
jmp 0x386b
movb $0x0, (%r15,%r11)
movq 0x15eb3(%rip), %rdi     # 0x19760
cmpl $0x2, -0x2c(%rbp)
jne 0x390c
testb $0x1, %r13b
leaq 0xd0d8(%rip), %rdx      # 0x10996
leaq 0xd0d5(%rip), %rax      # 0x1099a
cmoveq %rax, %rdx
cmpb $0x0, 0x15e50(%rip)     # 0x19720
movq %r12, %rcx
leaq 0xd0c5(%rip), %rax      # 0x1099f
cmovneq %rax, %rcx
movl 0x8(%rsi), %r10d
movsd 0x20(%rsi), %xmm0
movsd 0x10(%rsi), %xmm1
movsd 0x18(%rsi), %xmm2
subq $0x8, %rsp
leaq 0xcfe6(%rip), %rsi      # 0x108e2
movq %r15, %r9
movb $0x3, %al
pushq %r10
callq 0x2310
popq %rcx
popq %rdx
jmp 0x3945
leal -0x5(%r9), %ecx
negl %ecx
cmpl $0x5, %r9d
movl $0x0, %eax
cmovgel %eax, %ecx
movl 0x8(%rsi), %r9d
movsd 0x20(%rsi), %xmm0
movsd 0x10(%rsi), %xmm1
movsd 0x18(%rsi), %xmm2
leaq 0xd06c(%rip), %rsi      # 0x109a4
movq %r15, %rdx
movq %r12, %r8
movb $0x3, %al
callq 0x2310
incq %r13
jmp 0x384b
cmpl $0x2, -0x2c(%rbp)
jne 0x396c
movq 0x15e06(%rip), %rcx     # 0x19760
leaq 0xd06c(%rip), %rdi      # 0x109cd
pushq $0x9
popq %rsi
pushq $0x1
popq %rdx
callq 0x2420
movq -0x38(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop