#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct timeval {
  int dummy;
};

/* Variables and functions */
double convert_time_to_sec(struct timeval);
scalar_t__ is_supported_domain(int);
int /*<<< orphan*/ print_global_header(int, double const);
int /*<<< orphan*/ print_header(int, double const);
int /*<<< orphan*/ print_value(int, int, double);
void print_results(int num_node, double cum_energy_J[num_node][5],
                   struct timeval measurement_start_time,
                   struct timeval measurement_end_time) {
  const double duration = convert_time_to_sec(measurement_end_time) -
                          convert_time_to_sec(measurement_start_time);
  print_global_header(num_node, duration);
  for (int i = 0; i < num_node; i++) {
    print_header(i, duration);
    for (int domain = 0; domain < 5; ++domain) {
      if (is_supported_domain(domain)) {
        print_value(i, domain, cum_energy_J[i][domain]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<print_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edx,-0x8(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <convert_time_to_sec@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <convert_time_to_sec@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%edi
movsd  -0x28(%rbp),%xmm0
call   1060 <print_global_header@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1224 <print_results+0xd4>
mov    -0x2c(%rbp),%edi
movsd  -0x28(%rbp),%xmm0
call   1070 <print_header@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x5,-0x30(%rbp)
jge    1211 <print_results+0xc1>
mov    -0x30(%rbp),%edi
call   1050 <is_supported_domain@plt>
cmp    $0x0,%rax
je     11fe <print_results+0xae>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <print_value@plt>
jmp    1203 <print_results+0xb3>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11bf <print_results+0x6f>
jmp    1216 <print_results+0xc6>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119f <print_results+0x4f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_results>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %edi,%ebx
mov    %ecx,%edi
call   1030 <convert_time_to_sec@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1030 <convert_time_to_sec@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mov    %ebx,%edi
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1060 <print_global_header@plt>
test   %ebx,%ebx
jle    1265 <print_results+0x115>
mov    %ebx,%ebp
add    $0x20,%r14
xor    %ebx,%ebx
jmp    11b1 <print_results+0x61>
add    $0x1,%rbx
add    $0x28,%r14
cmp    %rbx,%rbp
je     1265 <print_results+0x115>
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
call   1070 <print_header@plt>
xor    %edi,%edi
call   1050 <is_supported_domain@plt>
test   %rax,%rax
je     11d9 <print_results+0x89>
movsd  -0x20(%r14),%xmm0
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <print_value@plt>
mov    $0x1,%edi
call   1050 <is_supported_domain@plt>
test   %rax,%rax
je     11fa <print_results+0xaa>
movsd  -0x18(%r14),%xmm0
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <print_value@plt>
mov    $0x2,%edi
call   1050 <is_supported_domain@plt>
test   %rax,%rax
je     121b <print_results+0xcb>
movsd  -0x10(%r14),%xmm0
mov    %ebx,%edi
mov    $0x2,%esi
call   1040 <print_value@plt>
mov    $0x3,%edi
call   1050 <is_supported_domain@plt>
test   %rax,%rax
je     123c <print_results+0xec>
movsd  -0x8(%r14),%xmm0
mov    %ebx,%edi
mov    $0x3,%esi
call   1040 <print_value@plt>
mov    $0x4,%edi
call   1050 <is_supported_domain@plt>
test   %rax,%rax
je     11a0 <print_results+0x50>
movsd  (%r14),%xmm0
mov    %ebx,%edi
mov    $0x4,%esi
call   1040 <print_value@plt>
jmp    11a0 <print_results+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
define void @print_results(i32 %0, [5 x double]* %1, i32 %2, i32 %3) {
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca i32
%8 = alloca [5 x double]*
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
store i32 %2, i32* %12
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
store i32 %3, i32* %13
store i32 %0, i32* %7
store [5 x double]* %1, [5 x double]** %8
%14 = load i32, i32* %7
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%17 = load i32, i32* %16
%18 = call double @convert_time_to_sec(i32 %17)
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call double @convert_time_to_sec(i32 %20)
%22 = fsub double %18, %21
store double %22, double* %9
%23 = load i32, i32* %7
%24 = load double, double* %9
%25 = call i32 @print_global_header(i32 %23, double %24)
store i32 0, i32* %10
br label %26
26: ; preds = %58, %4
%27 = load i32, i32* %10
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %61
30: ; preds = %26
%31 = load i32, i32* %10
%32 = load double, double* %9
%33 = call i32 @print_header(i32 %31, double %32)
store i32 0, i32* %11
br label %34
34: ; preds = %54, %30
%35 = load i32, i32* %11
%36 = icmp slt i32 %35, 5
br i1 %36, label %37, label %57
37: ; preds = %34
%38 = load i32, i32* %11
%39 = call i64 @is_supported_domain(i32 %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = load i32, i32* %10
%43 = load i32, i32* %11
%44 = load [5 x double]*, [5 x double]** %8
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [5 x double], [5 x double]* %44, i64 %46
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [5 x double], [5 x double]* %47, i64 0, i64 %49
%51 = load double, double* %50
%52 = call i32 @print_value(i32 %42, i32 %43, double %51)
br label %53
53: ; preds = %41, %37
br label %54
54: ; preds = %53
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
store i32 %56, i32* %11
br label %34
57: ; preds = %34
br label %58
58: ; preds = %57
%59 = load i32, i32* %10
%60 = add nsw i32 %59, 1
store i32 %60, i32* %10
br label %26
61: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @print_results(i32 %0, [5 x double]* nocapture %1, i32 %2, i32 %3) {
%5 = tail call double @convert_time_to_sec(i32 %3)
%6 = tail call double @convert_time_to_sec(i32 %2)
%7 = fsub double %5, %6
%8 = tail call i32 @print_global_header(i32 %0, double %7)
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = zext i32 %0 to i64
br label %13
12: ; preds = %51, %4
ret void
13: ; preds = %10, %51
%14 = phi i64 [ 0, %10 ], [ %52, %51 ]
%15 = trunc i64 %14 to i32
%16 = tail call i32 @print_header(i32 %15, double %7)
%17 = tail call i64 @is_supported_domain(i32 0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %13
%20 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 %14, i64 0
%21 = load double, double* %20
%22 = tail call i32 @print_value(i32 %15, i32 0, double %21)
br label %23
23: ; preds = %13, %19
%24 = tail call i64 @is_supported_domain(i32 1)
%25 = icmp eq i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 %14, i64 1
%28 = load double, double* %27
%29 = tail call i32 @print_value(i32 %15, i32 1, double %28)
br label %30
30: ; preds = %26, %23
%31 = tail call i64 @is_supported_domain(i32 2)
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %30
%34 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 %14, i64 2
%35 = load double, double* %34
%36 = tail call i32 @print_value(i32 %15, i32 2, double %35)
br label %37
37: ; preds = %33, %30
%38 = tail call i64 @is_supported_domain(i32 3)
%39 = icmp eq i64 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 %14, i64 3
%42 = load double, double* %41
%43 = tail call i32 @print_value(i32 %15, i32 3, double %42)
br label %44
44: ; preds = %40, %37
%45 = tail call i64 @is_supported_domain(i32 4)
%46 = icmp eq i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %44
%48 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 %14, i64 4
%49 = load double, double* %48
%50 = tail call i32 @print_value(i32 %15, i32 4, double %49)
br label %51
51: ; preds = %47, %44
%52 = add nuw nsw i64 %14, 1
%53 = icmp eq i64 %52, %11
br i1 %53, label %12, label %13
}