// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %rbx
movl %r8d, %ebp
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
testl %r8d, %r8d
je 0x5287
leaq 0x676d(%rip), %rdi      # 0xb9ea
movq %r13, %rsi
xorl %eax, %eax
callq 0x2100
cmpl $0x3, %ebp
movl %ebp, 0x4(%rsp)
je 0x53b2
cmpl $0x2, %ebp
je 0x531d
cmpl $0x1, %ebp
jne 0x54c6
leaq 0x6789(%rip), %rdi      # 0xba36
movq %r14, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2100
testq %r14, %r14
je 0x530c
leaq 0x6794(%rip), %r13      # 0xba5a
leaq 0x73c5(%rip), %rbp      # 0xc692
xorl %ebx, %ebx
leaq 0x6474(%rip), %rdi      # 0xb74a
xorl %eax, %eax
callq 0x2100
xorl %r12d, %r12d
movq (%r15,%rbx,8), %rax
movsd (%rax,%r12,8), %xmm0
movq %r13, %rdi
movb $0x1, %al
callq 0x2100
incq %r12
cmpq %r12, %r14
jne 0x52e0
movq %rbp, %rdi
callq 0x2080
incq %rbx
cmpq %r14, %rbx
jne 0x52cf
leaq 0x737c(%rip), %rdi      # 0xc68f
callq 0x2080
jmp 0x54c6
leaq 0x7a8a(%rip), %rdi      # 0xcdae
xorl %eax, %eax
callq 0x2100
testq %r14, %r14
je 0x534f
leaq 0x6420(%rip), %rbx      # 0xb757
xorl %r12d, %r12d
movq %rbx, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x2100
incq %r12
cmpq %r12, %r14
jne 0x533a
movl $0xa, %edi
callq 0x2040
testq %r14, %r14
je 0x54c6
leaq 0x63f4(%rip), %r12      # 0xb75d
leaq 0x66ea(%rip), %r13      # 0xba5a
xorl %ebp, %ebp
movq %r12, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x2100
xorl %ebx, %ebx
movq (%r15,%rbp,8), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r13, %rdi
movb $0x1, %al
callq 0x2100
incq %rbx
cmpq %rbx, %r14
jne 0x5380
movl $0xa, %edi
callq 0x2040
incq %rbp
cmpq %r14, %rbp
jne 0x5372
jmp 0x54c6
movq %r13, 0x8(%rsp)
movq %r12, 0x18(%rsp)
leaq 0x63a9(%rip), %rsi      # 0xb76c
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x639e(%rip), %rdi      # 0xb77a
movq %r12, %rsi
xorl %eax, %eax
callq 0x2100
leaq 0x6418(%rip), %rsi      # 0xb805
movq %r12, %rdi
callq 0x2240
movq %rax, %r13
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x54e8
leaq 0x6657(%rip), %rsi      # 0xba64
movq %r13, %rdi
movq 0x8(%rsp), %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2170
testq %r14, %r14
je 0x545c
xorl %ebp, %ebp
leaq 0x6647(%rip), %rbx      # 0xba74
xorl %r12d, %r12d
movq (%r15,%rbp,8), %rax
movsd (%rax,%r12,8), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movl %r12d, %ecx
movb $0x1, %al
callq 0x2170
incq %r12
cmpq %r12, %r14
jne 0x5430
incq %rbp
cmpq %r14, %rbp
jne 0x542d
leaq 0x661f(%rip), %rsi      # 0xba82
movq %r13, %rdi
movq 0x8(%rsp), %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2170
testq %r14, %r14
movq 0x18(%rsp), %r12
je 0x54b6
xorl %r15d, %r15d
leaq 0x65eb(%rip), %rbp      # 0xba74
xorl %ebx, %ebx
movq (%r12,%r15,8), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r13, %rdi
movq %rbp, %rsi
movl %r15d, %edx
movl %ebx, %ecx
movb $0x1, %al
callq 0x2170
incq %rbx
cmpq %rbx, %r14
jne 0x548b
incq %r15
cmpq %r14, %r15
jne 0x5489
cmpq $0x0, 0x10(%rsp)
je 0x54c6
movq %r13, %rdi
callq 0x20e0
cmpl $0x0, 0x4(%rsp)
je 0x54d9
leaq 0x7257(%rip), %rdi      # 0xc72b
callq 0x2080
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xbb01(%rip), %rbx      # 0x10ff0
movq (%rbx), %rdi
leaq 0x629c(%rip), %rsi      # 0xb795
leaq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x2170
movq (%rbx), %r13
jmp 0x5406