// File: /workspace/github_c_makefile_star2_O2/LPD-EPFL[P]mctop/src/mctop.c
// Function: print_pow_table
void 
print_pow_table(double*** pt, const uint n_sockets, test_format_t test_format, const char* hostname)
{
  if (test_format == MCT_FILE)
    {
      printf("## Power info ############################################################\n");
      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, "#Power_measurements %d\n", MCTOP_POW_TYPE_NUM);
      for (uint s = 0; s <= n_sockets; s++)
	{
	  const char* text = (s < n_sockets) ? "sockt" : "total";
	  uint type = 0;
	  double* d = pt[type++][s];
	  fprintf(ofp, "Power_%s_%d_idle \t"P5DOUBLEP"\n", text, s, G5DOUBLE(d));
	  d = pt[type++][s];
	  fprintf(ofp, "Power_%s_%d_1stcore \t"P5DOUBLEP"\n", text, s, G5DOUBLE(d));
	  d = pt[type++][s];
	  fprintf(ofp, "Power_%s_%d_2ndcore \t"P5DOUBLEP"\n", text, s, G5DOUBLE(d));
	  d = pt[type++][s];
	  fprintf(ofp, "Power_%s_%d_2ndhwc \t"P5DOUBLEP"\n", text, s, G5DOUBLE(d));
	  d = pt[type++][s];
	  fprintf(ofp, "Power_%s_%d_allcor \t"P5DOUBLEP"\n", text, s, G5DOUBLE(d));
	  d = pt[type++][s];
	  fprintf(ofp, "Power_%s_%d_allhwc \t"P5DOUBLEP"\n", text, s, G5DOUBLE(d));
	}
      if (ofp_open)
	{
	  fclose(ofp);
	}
      printf("##########################################################################\n");
    }
}

// Assembly:
cmpl $0x3, %edx
jne 0x5118
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r15
movl %esi, %ebx
movq %rdi, %r14
leaq 0x67be(%rip), %rdi      # 0xb6e0
callq 0x2080
leaq 0x583e(%rip), %rsi      # 0xa76c
xorl %ebp, %ebp
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x5831(%rip), %rdi      # 0xa77a
movq %r12, %rsi
xorl %eax, %eax
callq 0x2100
leaq 0x58ab(%rip), %rsi      # 0xa805
movq %r12, %rdi
callq 0x2240
movq %rax, %r12
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x5119
leaq 0x58db(%rip), %rsi      # 0xa855
pushq $0x6
popq %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0x2170
cmpl %ebx, %ebp
ja 0x50ee
leaq 0x58dd(%rip), %r13      # 0xa873
leaq 0x58d0(%rip), %rax      # 0xa86d
cmovbq %rax, %r13
movq (%r14), %rax
movl %ebp, %r15d
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x18(%rax), %xmm3
movsd 0x20(%rax), %xmm4
movq %r12, %rdi
leaq 0x58ac(%rip), %rsi      # 0xa879
movq %r13, %rdx
movl %ebp, %ecx
movb $0x5, %al
callq 0x2170
movq 0x8(%r14), %rax
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x18(%rax), %xmm3
movsd 0x20(%rax), %xmm4
movq %r12, %rdi
leaq 0x58a8(%rip), %rsi      # 0xa8ab
movq %r13, %rdx
movl %ebp, %ecx
movb $0x5, %al
callq 0x2170
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x18(%rax), %xmm3
movsd 0x20(%rax), %xmm4
movq %r12, %rdi
leaq 0x58a7(%rip), %rsi      # 0xa8e0
movq %r13, %rdx
movl %ebp, %ecx
movb $0x5, %al
callq 0x2170
movq 0x18(%r14), %rax
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x18(%rax), %xmm3
movsd 0x20(%rax), %xmm4
movq %r12, %rdi
leaq 0x58a6(%rip), %rsi      # 0xa915
movq %r13, %rdx
movl %ebp, %ecx
movb $0x5, %al
callq 0x2170
movq 0x20(%r14), %rax
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x18(%rax), %xmm3
movsd 0x20(%rax), %xmm4
movq %r12, %rdi
leaq 0x58a4(%rip), %rsi      # 0xa949
movq %r13, %rdx
movl %ebp, %ecx
movb $0x5, %al
callq 0x2170
movq 0x28(%r14), %rax
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
movsd 0x18(%rax), %xmm3
movsd 0x20(%rax), %xmm4
movq %r12, %rdi
leaq 0x58a2(%rip), %rsi      # 0xa97d
movq %r13, %rdx
movl %ebp, %ecx
movb $0x5, %al
callq 0x2170
incl %ebp
jmp 0x4f87
cmpq $0x0, 0x8(%rsp)
je 0x50fe
movq %r12, %rdi
callq 0x20e0
leaq 0x6626(%rip), %rdi      # 0xb72b
callq 0x2080
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xaed0(%rip), %r15      # 0xfff0
movq (%r15), %rdi
leaq 0x566b(%rip), %rsi      # 0xa795
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2170
movq (%r15), %r12
jmp 0x4f73
nop