// File: /workspace/github_c_makefile_star2_O3/LPD-EPFL[P]mctop/src/mctop.c
// Function: print_mem_bw_tables
void
print_mem_bw_tables(double** mem_bw_table, double** mem_bw_table1, size_t n_sockets,
		    const char* rw, test_format_t test_format, const char* hostname)
{
  if (test_format != NONE)
    {
      printf("## Mem. bw table (%-6s)###################################################\n", rw);
    }
  switch (test_format)
    {
    case C_STRUCT:
      printf("size_t mem_bw_table[%zu][%zu] = \n{\n", n_sockets, n_sockets);
      for (int x = 0; x < n_sockets; x++)
	{
	  printf("  { ");
	  for (int y = 0; y < n_sockets; y++)
	    {
	      printf("%-10.6f, ", mem_bw_table[x][y]);
	    }
	  printf("},\n");
	}
      printf("};\n");
      break;
    case LAT_TABLE:
      printf("     ");
      for (int y = 0; y < n_sockets; y++)
	{
	  printf("%-3d ", y);
	}
      printf("\n");

      /* print lat table */
      for (int x = 0; x < n_sockets; x++)
	{
	  printf("[%02d] ", x);
	  for (int y = 0; y < n_sockets; y++)
	    {
	      printf("%-10.6f, ", mem_bw_table[x][y]);
	    }
	  printf("\n");
	}
      break;
    case MCT_FILE:
      {
	char out_file[50];
	sprintf(out_file, "./desc/%s.mct", hostname);
	printf("## MCTOP output in: %s\n", out_file);

	int ofp_open = 1;
	FILE* ofp = fopen(out_file, "a");
	if (ofp == NULL) 
	  {
	    ofp_open = 0;
	    fprintf(stderr, "MCTOP Error: Cannot open output file %s! Using stderr instead.\n", out_file);
	    ofp = stderr;
	  }
	fprintf(ofp, "#Mem_bw-%s %zu\n", rw, n_sockets);
	for (int x = 0; x < n_sockets; x++)
	  {
	    for (int y = 0; y < n_sockets; y++)
	      {
		fprintf(ofp, "%-4d %-4d %f\n", x, y, mem_bw_table[x][y]);
	      }
	  }
	fprintf(ofp, "#Mem_bw1-%s %zu\n", rw, n_sockets);
	for (int x = 0; x < n_sockets; x++)
	  {
	    for (int y = 0; y < n_sockets; y++)
	      {
		fprintf(ofp, "%-4d %-4d %f\n", x, y, mem_bw_table1[x][y]);
	      }
	  }
	if (ofp_open)
	  {
	    fclose(ofp);
	  }
      }
    case NONE:
      break;
    }
  if (test_format != NONE)
    {
      printf("##########################################################################\n");
    }
}

// Assembly:
testl %r8d, %r8d
je 0x54e2
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r12
movl %r8d, %ebp
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r14
leaq 0x5791(%rip), %rdi      # 0xa9ea
movq %rcx, %rsi
xorl %eax, %eax
callq 0x2100
cmpl $0x3, %ebp
je 0x5387
cmpl $0x2, %ebp
je 0x52f5
cmpl $0x1, %ebp
jne 0x54c8
leaq 0x57b1(%rip), %rdi      # 0xaa36
movq %rbx, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
testq %rbx, %rbx
je 0x52e4
leaq 0x57bc(%rip), %r12      # 0xaa5a
leaq 0x63ed(%rip), %r13      # 0xb692
xorl %ebp, %ebp
leaq 0x549c(%rip), %rdi      # 0xa74a
xorl %eax, %eax
callq 0x2100
xorl %r15d, %r15d
movq (%r14,%rbp,8), %rax
movsd (%rax,%r15,8), %xmm0
movq %r12, %rdi
movb $0x1, %al
callq 0x2100
incq %r15
cmpq %r15, %rbx
jne 0x52b8
movq %r13, %rdi
callq 0x2080
incq %rbp
cmpq %rbx, %rbp
jne 0x52a7
leaq 0x63a4(%rip), %rdi      # 0xb68f
callq 0x2080
jmp 0x54c8
leaq 0x6ab2(%rip), %rdi      # 0xbdae
xorl %eax, %eax
callq 0x2100
testq %rbx, %rbx
je 0x5495
leaq 0x5444(%rip), %r15      # 0xa757
xorl %r12d, %r12d
movq %r15, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x2100
incq %r12
cmpq %r12, %rbx
jne 0x5316
movl $0xa, %edi
callq 0x2040
leaq 0x5421(%rip), %r15      # 0xa75d
leaq 0x5717(%rip), %r12      # 0xaa5a
xorl %r13d, %r13d
movq %r15, %rdi
movl %r13d, %esi
xorl %eax, %eax
callq 0x2100
xorl %ebp, %ebp
movq (%r14,%r13,8), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r12, %rdi
movb $0x1, %al
callq 0x2100
incq %rbp
cmpq %rbp, %rbx
jne 0x5355
movl $0xa, %edi
callq 0x2040
incq %r13
cmpq %rbx, %r13
jne 0x5346
jmp 0x54c8
movq %r15, 0x8(%rsp)
leaq 0x53d9(%rip), %rsi      # 0xa76c
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x53ce(%rip), %rdi      # 0xa77a
movq %r15, %rsi
xorl %eax, %eax
callq 0x2100
leaq 0x5448(%rip), %rsi      # 0xa805
movq %r15, %rdi
callq 0x2240
movq %rax, %rbp
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x54e3
leaq 0x5687(%rip), %rsi      # 0xaa64
movq %rbp, %rdi
movq 0x8(%rsp), %r15
movq %r15, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2170
testq %rbx, %rbx
je 0x54a1
movq %r13, 0x10(%rsp)
xorl %r12d, %r12d
leaq 0x566a(%rip), %r13      # 0xaa74
xorl %r15d, %r15d
movq (%r14,%r12,8), %rax
movsd (%rax,%r15,8), %xmm0
movq %rbp, %rdi
movq %r13, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movb $0x1, %al
callq 0x2170
incq %r15
cmpq %r15, %rbx
jne 0x540d
incq %r12
cmpq %rbx, %r12
jne 0x540a
leaq 0x5641(%rip), %rsi      # 0xaa82
xorl %r14d, %r14d
movq %rbp, %rdi
movq 0x8(%rsp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2170
leaq 0x5617(%rip), %r12      # 0xaa74
movq 0x10(%rsp), %r13
xorl %r15d, %r15d
movq (%r13,%r14,8), %rax
movsd (%rax,%r15,8), %xmm0
movq %rbp, %rdi
movq %r12, %rsi
movl %r14d, %edx
movl %r15d, %ecx
movb $0x1, %al
callq 0x2170
incq %r15
cmpq %r15, %rbx
jne 0x5465
incq %r14
cmpq %rbx, %r14
jne 0x5462
jmp 0x54b8
movl $0xa, %edi
callq 0x2040
jmp 0x54c8
leaq 0x55da(%rip), %rsi      # 0xaa82
movq %rbp, %rdi
movq %r15, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2170
cmpq $0x0, 0x18(%rsp)
je 0x54c8
movq %rbp, %rdi
callq 0x20e0
leaq 0x625c(%rip), %rdi      # 0xb72b
callq 0x2080
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xab06(%rip), %r15      # 0xfff0
movq (%r15), %rdi
leaq 0x52a1(%rip), %rsi      # 0xa795
leaq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x2170
movq (%r15), %rbp
jmp 0x53d6