// File: /workspace/github_c_makefile_star2_O2/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 0x4dd1
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r12
movl %r8d, %ebp
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x5e6b(%rip), %rdi      # 0xa9ea
movq %rcx, %rsi
xorl %eax, %eax
callq 0x2100
cmpl $0x3, %ebp
je 0x4c93
cmpl $0x2, %ebp
je 0x4c09
cmpl $0x1, %ebp
jne 0x4db7
leaq 0x5e8f(%rip), %rdi      # 0xaa36
movq %rbx, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2100
leaq 0x6ad7(%rip), %r12      # 0xb692
leaq 0x5e98(%rip), %r13      # 0xaa5a
xorl %ebp, %ebp
cmpq %rbx, %rbp
je 0x4dab
leaq 0x5b76(%rip), %rdi      # 0xa74a
xorl %eax, %eax
callq 0x2100
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0x4bfc
movq (%r14,%rbp,8), %rax
movsd (%rax,%r15,8), %xmm0
movq %r13, %rdi
movb $0x1, %al
callq 0x2100
incq %r15
jmp 0x4bde
movq %r12, %rdi
callq 0x2080
incq %rbp
jmp 0x4bc4
leaq 0x719e(%rip), %rdi      # 0xbdae
xorl %eax, %eax
callq 0x2100
leaq 0x5b39(%rip), %r15      # 0xa757
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0x4c38
movq %r15, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x2100
incq %r12
jmp 0x4c21
pushq $0xa
popq %rdi
callq 0x2040
leaq 0x5b16(%rip), %r15      # 0xa75d
leaq 0x5e0c(%rip), %r12      # 0xaa5a
xorl %r13d, %r13d
cmpq %rbx, %r13
je 0x4db7
movq %r15, %rdi
movl %r13d, %esi
xorl %eax, %eax
callq 0x2100
xorl %ebp, %ebp
cmpq %rbp, %rbx
je 0x4c86
movq (%r14,%r13,8), %rax
movsd (%rax,%rbp,8), %xmm0
movq %r12, %rdi
movb $0x1, %al
callq 0x2100
incq %rbp
jmp 0x4c69
pushq $0xa
popq %rdi
callq 0x2040
incq %r13
jmp 0x4c51
movq %r15, 0x18(%rsp)
leaq 0x5acd(%rip), %rsi      # 0xa76c
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x5ac2(%rip), %rdi      # 0xa77a
movq %r15, %rsi
xorl %eax, %eax
callq 0x2100
leaq 0x5b3c(%rip), %rsi      # 0xa805
movq %r15, %rdi
callq 0x2240
movq %rax, %rbp
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x4dd2
leaq 0x5d7b(%rip), %rsi      # 0xaa64
xorl %r12d, %r12d
movq %rbp, %rdi
movq %r13, 0x8(%rsp)
movq %r13, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2170
leaq 0x5d6c(%rip), %r13      # 0xaa74
cmpq %rbx, %r12
je 0x4d3c
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0x4d37
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
jmp 0x4d10
incq %r12
jmp 0x4d08
leaq 0x5d3f(%rip), %rsi      # 0xaa82
xorl %r14d, %r14d
movq %rbp, %rdi
movq 0x8(%rsp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2170
leaq 0x5d15(%rip), %r12      # 0xaa74
movq 0x18(%rsp), %r13
cmpq %rbx, %r14
je 0x4d99
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0x4d94
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
jmp 0x4d6c
incq %r14
jmp 0x4d64
cmpq $0x0, 0x10(%rsp)
je 0x4db7
movq %rbp, %rdi
callq 0x20e0
jmp 0x4db7
leaq 0x68dd(%rip), %rdi      # 0xb68f
callq 0x2080
leaq 0x696d(%rip), %rdi      # 0xb72b
callq 0x2080
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb217(%rip), %r15      # 0xfff0
movq (%r15), %rdi
leaq 0x59b2(%rip), %rsi      # 0xa795
leaq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x2170
movq (%r15), %rbp
jmp 0x4ce2