#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 */

/* Variables and functions */
scalar_t__ do_run_memory_bench();
int /*<<< orphan*/ printf(char *, double);
double run_memory_bench() {
  double secs = 0;
  int i;
  for (i = 0; i < 10; i++) {
    secs += do_run_memory_bench();
  }
  printf("Time to run memory bench: %.2f[secs]\n", secs);
  return secs;
}


x86 assembly (clang, -O0):
<run_memory_bench>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1165 <run_memory_bench+0x45>
mov    $0x0,%al
call   1030 <do_run_memory_bench@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1137 <run_memory_bench+0x17>
movsd  -0x8(%rbp),%xmm0
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_memory_bench>:
push   %rax
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <do_run_memory_bench@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Time to run memory bench: %.2f[secs]\0A\00"
define double @run_memory_bench() {
%1 = alloca double
%2 = alloca i32
store double 0.000000e+00, double* %1
store i32 0, i32* %2
br label %3
3: ; preds = %11, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = call i64 (...) @do_run_memory_bench()
%8 = sitofp i64 %7 to double
%9 = load double, double* %1
%10 = fadd double %9, %8
store double %10, double* %1
br label %11
11: ; preds = %6
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
br label %3
14: ; preds = %3
%15 = load double, double* %1
%16 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %15)
%17 = load double, double* %1
ret double %17
}

LLVM IR (-O2):
@.str = [38 x i8] c"Time to run memory bench: %.2f[secs]\0A\00"
define double @run_memory_bench() {
%1 = tail call i64 (...) @do_run_memory_bench()
%2 = sitofp i64 %1 to double
%3 = tail call i64 (...) @do_run_memory_bench()
%4 = sitofp i64 %3 to double
%5 = fadd double %2, %4
%6 = tail call i64 (...) @do_run_memory_bench()
%7 = sitofp i64 %6 to double
%8 = fadd double %5, %7
%9 = tail call i64 (...) @do_run_memory_bench()
%10 = sitofp i64 %9 to double
%11 = fadd double %8, %10
%12 = tail call i64 (...) @do_run_memory_bench()
%13 = sitofp i64 %12 to double
%14 = fadd double %11, %13
%15 = tail call i64 (...) @do_run_memory_bench()
%16 = sitofp i64 %15 to double
%17 = fadd double %14, %16
%18 = tail call i64 (...) @do_run_memory_bench()
%19 = sitofp i64 %18 to double
%20 = fadd double %17, %19
%21 = tail call i64 (...) @do_run_memory_bench()
%22 = sitofp i64 %21 to double
%23 = fadd double %20, %22
%24 = tail call i64 (...) @do_run_memory_bench()
%25 = sitofp i64 %24 to double
%26 = fadd double %23, %25
%27 = tail call i64 (...) @do_run_memory_bench()
%28 = sitofp i64 %27 to double
%29 = fadd double %26, %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %29)
ret double %29
}