// File: /workspace/github_c_makefile_star2_O1/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
movl %esi, -0x3c(%rbp)
movq %rdi, %rbx
movl 0x16145(%rip), %eax     # 0x19730
movq 0x1614e(%rip), %rdi     # 0x19740
movl %eax, -0x2c(%rbp)
cmpl $0x2, %eax
jne 0x3677
leaq 0xdcc9(%rip), %rsi      # 0x112ca
leaq 0xde9c(%rip), %r14      # 0x114a4
movq %r14, %rdx
xorl %eax, %eax
callq 0x22d0
movq 0x16127(%rip), %rdi     # 0x19740
leaq 0xde91(%rip), %rsi      # 0x114b1
leaq 0xde9a(%rip), %rdx      # 0x114c1
leaq 0xde98(%rip), %r8       # 0x114c6
movq %r14, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x16101(%rip), %rcx     # 0x19740
leaq 0xde86(%rip), %rdi      # 0x114cc
movl $0x5, %esi
movl $0x1, %edx
callq 0x23e0
leaq 0xdeba(%rip), %rdx      # 0x11516
leaq 0xdeb8(%rip), %rcx      # 0x1151b
leaq 0xdef1(%rip), %rax      # 0x1155b
movq %rax, -0x38(%rbp)
leaq 0xdeee(%rip), %r12      # 0x11563
jmp 0x36c6
leaq 0xde33(%rip), %rsi      # 0x114b1
leaq 0xde1f(%rip), %rcx      # 0x114a4
leaq 0xda1c(%rip), %r14      # 0x110a8
movq %r14, %rdx
movq %r14, %r8
xorl %eax, %eax
callq 0x22d0
movq 0x160a0(%rip), %rdi     # 0x19740
leaq 0xee36(%rip), %rsi      # 0x124dd
leaq 0xde24(%rip), %rdx      # 0x114d2
xorl %eax, %eax
callq 0x22d0
leaq 0xd9eb(%rip), %rcx      # 0x110a7
movq %r14, -0x38(%rbp)
movq %r14, %r12
movq %r14, %rdx
movq 0x16073(%rip), %rdi     # 0x19740
leaq 0xde29(%rip), %rsi      # 0x114fd
movq %rdx, -0x50(%rbp)
xorl %eax, %eax
callq 0x22d0
xorl %edi, %edi
callq 0x21c0
leaq -0x58(%rbp), %rcx
movq %rax, (%rcx)
leaq 0x16074(%rip), %rdi     # 0x19768
callq 0x2170
movq 0x16040(%rip), %rdi     # 0x19740
movl 0x8(%rax), %r8d
movl (%rax), %r10d
movl 0x4(%rax), %r9d
movl 0xc(%rax), %r11d
movl 0x10(%rax), %r14d
incl %r14d
movl $0x76c, %r15d           # imm = 0x76C
movl 0x14(%rax), %r13d
addl %r15d, %r13d
leaq 0xddf7(%rip), %rsi      # 0x11521
movq -0x38(%rbp), %rdx
movq %r12, %rcx
xorl %eax, %eax
pushq %r13
pushq %r14
pushq %r11
pushq %r10
callq 0x22d0
addq $0x20, %rsp
leaq -0x58(%rbp), %rdi
callq 0x2170
movq 0x15fec(%rip), %rdi     # 0x19740
movl 0x8(%rax), %r8d
movl (%rax), %r10d
movl 0x4(%rax), %r9d
movl 0xc(%rax), %r11d
movl 0x10(%rax), %r14d
incl %r14d
addl 0x14(%rax), %r15d
leaq 0xddf3(%rip), %rsi      # 0x11568
movq -0x38(%rbp), %r13
movq %r13, %rdx
movq %r12, -0x48(%rbp)
movq %r12, %rcx
xorl %eax, %eax
pushq %r15
pushq %r14
pushq %r11
pushq %r10
callq 0x22d0
addq $0x20, %rsp
movq 0x15fa3(%rip), %rcx     # 0x19740
cmpl $0x2, -0x2c(%rbp)
jne 0x37bb
leaq 0xddf6(%rip), %rdi      # 0x115a0
movl $0xb, %esi
movl $0x1, %edx
callq 0x23e0
jmp 0x37c8
movl $0xa, %edi
movq %rcx, %rsi
callq 0x2280
movq 0x15f71(%rip), %rdi     # 0x19740
movl 0x15f2e(%rip), %r8d     # 0x19704
leaq 0xddcf(%rip), %rsi      # 0x115ac
movq %r13, %rdx
movq -0x48(%rbp), %r12
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x15f4b(%rip), %rdi     # 0x19740
leaq 0xddc7(%rip), %rsi      # 0x115c3
leaq 0x14afd(%rip), %r8      # 0x18300
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x15f29(%rip), %rdi     # 0x19740
leaq 0xddcd(%rip), %rax      # 0x115eb
leaq 0xddca(%rip), %r8       # 0x115ef
cmpb $0x0, 0x15ed4(%rip)     # 0x19700
cmovneq %rax, %r8
leaq 0xdda2(%rip), %rsi      # 0x115d9
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x15ef5(%rip), %r14     # 0x19740
movq 0x15ee6(%rip), %rdi     # 0x19738
movq (%rdi), %rax
callq *0x40(%rax)
leaq 0xdd93(%rip), %rsi      # 0x115f2
movq %r14, %rdi
movq %r13, %rdx
movq %r12, %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x22d0
movq 0x15ec7(%rip), %r14     # 0x19740
movq 0x15eb8(%rip), %rdi     # 0x19738
movq (%rdi), %rax
movb 0x15e76(%rip), %r15b    # 0x19700
callq *0x48(%rax)
movl %eax, %r8d
shrl $0x1f, %r8d
addl %eax, %r8d
sarl %r8d
testb %r15b, %r15b
cmovnel %eax, %r8d
leaq 0xdd5c(%rip), %rsi      # 0x11604
movq %r14, %rdi
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x15e81(%rip), %rcx     # 0x19740
cmpl $0x2, -0x2c(%rbp)
jne 0x38dd
leaq 0xdcd4(%rip), %rdi      # 0x115a0
movl $0xb, %esi
movl $0x1, %edx
callq 0x23e0
jmp 0x38ea
movl $0xa, %edi
movq %rcx, %rsi
callq 0x2280
movq 0x15e4f(%rip), %rdi     # 0x19740
leaq 0xdd1e(%rip), %rsi      # 0x11616
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movl 0x15e1d(%rip), %eax     # 0x19728
cmpl $0x3, %eax
je 0x3944
cmpl $0x2, %eax
je 0x392f
cmpl $0x1, %eax
jne 0x3961
movq 0x15e1f(%rip), %rcx     # 0x19740
leaq 0xdcfb(%rip), %rdi      # 0x11623
movl $0x18, %esi
jmp 0x3957
movq 0x15e0a(%rip), %rcx     # 0x19740
leaq 0xdcff(%rip), %rdi      # 0x1163c
movl $0x2b, %esi
jmp 0x3957
movq 0x15df5(%rip), %rcx     # 0x19740
leaq 0xdd16(%rip), %rdi      # 0x11668
movl $0x24, %esi
movl $0x1, %edx
callq 0x23e0
movq 0x15dd8(%rip), %r14     # 0x19740
leaq 0x15df1(%rip), %r15     # 0x19760
movq %r15, %rdi
callq 0xbd72
leaq 0xdd0f(%rip), %rsi      # 0x1168d
movq %r14, %rdi
movq %r13, %rdx
movq %r12, %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x22d0
movq 0x15da8(%rip), %r14     # 0x19740
movq %r15, %rdi
callq 0xbd6a
leaq 0xdd25(%rip), %rsi      # 0x116cc
movq %r14, %rdi
movq %r13, %rdx
movq %r12, %rcx
movb $0x1, %al
callq 0x22d0
movq 0x15d82(%rip), %rdi     # 0x19740
movsd 0x15d52(%rip), %xmm0    # 0x19718
leaq 0xdd38(%rip), %rsi      # 0x11705
movq %r13, %rdx
movq %r12, %rcx
movb $0x1, %al
callq 0x22d0
movq 0x15d5f(%rip), %rdi     # 0x19740
movsd 0x15d37(%rip), %xmm0    # 0x19720
leaq 0xdd4f(%rip), %rsi      # 0x1173f
movq %r13, %rdx
movq %r12, %rcx
movb $0x1, %al
callq 0x22d0
movq 0x15d3c(%rip), %rcx     # 0x19740
cmpl $0x2, -0x2c(%rbp)
jne 0x3a22
leaq 0xdb8f(%rip), %rdi      # 0x115a0
movl $0xb, %esi
movl $0x1, %edx
callq 0x23e0
jmp 0x3a2f
movl $0xa, %edi
movq %rcx, %rsi
callq 0x2280
movq 0x15d0a(%rip), %rdi     # 0x19740
movl 0x15ccb(%rip), %r8d     # 0x19708
leaq 0xdd31(%rip), %rsi      # 0x11775
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x15ce8(%rip), %rdi     # 0x19740
movl 0x15cad(%rip), %r8d     # 0x1970c
leaq 0xdd32(%rip), %rsi      # 0x11798
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x15cc6(%rip), %rdi     # 0x19740
movl 0x15c8f(%rip), %r8d     # 0x19710
leaq 0xdd25(%rip), %rsi      # 0x117ad
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x15ca4(%rip), %rdi     # 0x19740
movl 0x15c71(%rip), %r8d     # 0x19714
leaq 0xdd1f(%rip), %rsi      # 0x117c9
movq %r13, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x22d0
movq 0x15c82(%rip), %rcx     # 0x19740
cmpl $0x2, -0x2c(%rbp)
jne 0x3ae3
leaq 0xda01(%rip), %rdi      # 0x114cc
movl $0x5, %esi
movl $0x1, %edx
callq 0x23e0
leaq 0xda3a(%rip), %rcx      # 0x1151b
jmp 0x3b02
leaq 0xe9f3(%rip), %rsi      # 0x124dd
leaq 0xd9e1(%rip), %rdx      # 0x114d2
movq %rcx, %rdi
xorl %eax, %eax
callq 0x22d0
leaq 0xd5a6(%rip), %rcx      # 0x110a8
movq 0x15c37(%rip), %rdi     # 0x19740
leaq 0xdcdf(%rip), %rsi      # 0x117ef
xorl %r14d, %r14d
movq -0x50(%rbp), %rdx
xorl %eax, %eax
callq 0x22d0
movq %rsp, -0x38(%rbp)
movl 0x15bdc(%rip), %eax     # 0x19704
leal 0x1(%rax), %ecx
imull %eax, %ecx
addq $0xf, %rcx
andq $-0x10, %rcx
movq %rsp, %r15
subq %rcx, %r15
movq %r15, %rsp
movq 0x15bfa(%rip), %rcx     # 0x19740
cmpl $0x2, -0x2c(%rbp)
jne 0x3b64
leaq 0xdcb8(%rip), %rdi      # 0x1180b
movl $0x98, %esi
movl $0x1, %edx
callq 0x23e0
jmp 0x3b8f
movl 0x15b9a(%rip), %eax     # 0x19704
leal -0x5(%rax), %edx
cmpl $0x6, %eax
cmovll %r14d, %edx
leaq 0xdd29(%rip), %rsi      # 0x118a4
leaq 0xd526(%rip), %rax      # 0x110a8
movq %rcx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x22d0
movl -0x3c(%rbp), %eax
testl %eax, %eax
jle 0x3cbb
movl %eax, %r12d
leaq 0xd504(%rip), %r14      # 0x110a8
xorl %r13d, %r13d
leaq (,%r13,4), %rsi
addq %r13, %rsi
movq (%rbx,%rsi,8), %r8
cmpb $0x0, (%r8)
je 0x3bff
xorl %ecx, %ecx
movl 0x15b40(%rip), %edi     # 0x19704
xorl %r9d, %r9d
testq %rcx, %rcx
je 0x3be0
movl %ecx, %eax
cltd
idivl %edi
testl %edx, %edx
jne 0x3be0
movslq %r9d, %rax
incl %r9d
movb $0xa, (%r15,%rax)
movb (%r8,%rcx), %al
movslq %r9d, %r9
movb %al, (%r15,%r9)
incl %r9d
cmpb $0x0, 0x1(%r8,%rcx)
leaq 0x1(%rcx), %rcx
jne 0x3bc7
movslq %r9d, %rcx
jmp 0x3c01
xorl %ecx, %ecx
leaq (%rbx,%rsi,8), %rax
movb $0x0, (%r15,%rcx)
movq 0x15b2f(%rip), %rdi     # 0x19740
cmpl $0x2, -0x2c(%rbp)
jne 0x3c72
testb $0x1, %r13b
leaq 0xdd74(%rip), %rdx      # 0x11996
leaq 0xdd71(%rip), %rcx      # 0x1199a
cmoveq %rcx, %rdx
cmpb $0x0, 0x15acc(%rip)     # 0x19700
movq %r14, %rcx
leaq 0xdd61(%rip), %rsi      # 0x1199f
cmovneq %rsi, %rcx
movl 0x8(%rax), %r10d
movsd 0x20(%rax), %xmm0
movsd 0x10(%rax), %xmm1
movsd 0x18(%rax), %xmm2
subq $0x8, %rsp
leaq 0xdc82(%rip), %rsi      # 0x118e2
movq %r15, %r9
movb $0x3, %al
pushq %r10
callq 0x22d0
addq $0x10, %rsp
jmp 0x3caf
movl 0x15a8c(%rip), %edx     # 0x19704
leal -0x5(%rdx), %ecx
negl %ecx
cmpl $0x5, %edx
movl $0x0, %edx
cmovgel %edx, %ecx
movl 0x8(%rax), %r9d
movsd 0x20(%rax), %xmm0
movsd 0x10(%rax), %xmm1
movsd 0x18(%rax), %xmm2
leaq 0xdd02(%rip), %rsi      # 0x119a4
movq %r15, %rdx
movq %r14, %r8
movb $0x3, %al
callq 0x22d0
incq %r13
cmpq %r12, %r13
jne 0x3ba7
cmpl $0x2, -0x2c(%rbp)
jne 0x3cde
movq 0x15a78(%rip), %rcx     # 0x19740
leaq 0xdcfe(%rip), %rdi      # 0x119cd
movl $0x9, %esi
movl $0x1, %edx
callq 0x23e0
movq -0x38(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop