#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 */
int /*<<< orphan*/ printf(char *, char *, double, double);
double run(char *);
double timed_run(char *prog) {
  double avg, m, d, x;
  int i, n;
  avg = 0;
  m = 0;
  n = 0;
  for (i = 0; i < 10; i++) {
    n++;
    x = run(prog);
    d = (x - avg);
    avg += d / n;
    m = m + d * (x - avg);
  }
  printf("%s:\t%fs (σ^2: %f)\n", prog, avg, m / (n - 1));
  return avg;
}


x86 assembly (clang, -O0):
<timed_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xa,-0x2c(%rbp)
jge    11c1 <timed_run+0xa1>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <run@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
subsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114a <timed_run+0x2a>
mov    -0x8(%rbp),%rsi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
divsd  %xmm2,%xmm1
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timed_run>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <run@plt>
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
movapd %xmm0,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
movsd  0xe8f(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
movapd %xmm1,%xmm2
divsd  0xe55(%rip),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
movsd  0xe23(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
movapd %xmm1,%xmm2
divsd  0xde9(%rip),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
movapd %xmm1,%xmm2
divsd  0xdb3(%rip),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
movapd %xmm1,%xmm2
divsd  0xd7d(%rip),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
movsd  0xd4b(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm2
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm2
movapd %xmm2,%xmm1
divsd  0xd11(%rip),%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm1,(%rsp)
subsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm2
addsd  0x8(%rsp),%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <run@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
movapd %xmm1,%xmm2
divsd  0xcdb(%rip),%xmm2
addsd  %xmm3,%xmm2
subsd  %xmm2,%xmm0
movsd  %xmm2,(%rsp)
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
divsd  0xcb4(%rip),%xmm1
lea    0xcbd(%rip),%rdi
mov    %rbx,%rsi
movapd %xmm2,%xmm0
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"%s:\09%fs (\CF\83^2: %f)\0A\00"
define double @timed_run(i8* %0) {
%2 = alloca i8*
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
store i32 0, i32* %8
store i32 0, i32* %7
br label %9
9: ; preds = %32, %1
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %35
12: ; preds = %9
%13 = load i32, i32* %8
%14 = add nsw i32 %13, 1
store i32 %14, i32* %8
%15 = load i8*, i8** %2
%16 = call double @run(i8* %15)
store double %16, double* %6
%17 = load double, double* %6
%18 = load double, double* %3
%19 = fsub double %17, %18
store double %19, double* %5
%20 = load double, double* %5
%21 = load i32, i32* %8
%22 = sitofp i32 %21 to double
%23 = fdiv double %20, %22
%24 = load double, double* %3
%25 = fadd double %24, %23
store double %25, double* %3
%26 = load double, double* %4
%27 = load double, double* %5
%28 = load double, double* %6
%29 = load double, double* %3
%30 = fsub double %28, %29
%31 = call double @llvm.fmuladd.f64(double %27, double %30, double %26)
store double %31, double* %4
br label %32
32: ; preds = %12
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %9
35: ; preds = %9
%36 = load i8*, i8** %2
%37 = load double, double* %3
%38 = load double, double* %4
%39 = load i32, i32* %8
%40 = sub nsw i32 %39, 1
%41 = sitofp i32 %40 to double
%42 = fdiv double %38, %41
%43 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %36, double %37, double %42)
%44 = load double, double* %3
ret double %44
}

LLVM IR (-O2):
@.str = [20 x i8] c"%s:\09%fs (\CF\83^2: %f)\0A\00"
define double @timed_run(i8* %0) {
%2 = tail call double @run(i8* %0)
%3 = fadd double %2, 0.000000e+00
%4 = fsub double %2, %3
%5 = tail call double @llvm.fmuladd.f64(double %2, double %4, double 0.000000e+00)
%6 = tail call double @run(i8* %0)
%7 = fsub double %6, %3
%8 = fmul double %7, 5.000000e-01
%9 = fadd double %3, %8
%10 = fsub double %6, %9
%11 = tail call double @llvm.fmuladd.f64(double %7, double %10, double %5)
%12 = tail call double @run(i8* %0)
%13 = fsub double %12, %9
%14 = fdiv double %13, 3.000000e+00
%15 = fadd double %9, %14
%16 = fsub double %12, %15
%17 = tail call double @llvm.fmuladd.f64(double %13, double %16, double %11)
%18 = tail call double @run(i8* %0)
%19 = fsub double %18, %15
%20 = fmul double %19, 2.500000e-01
%21 = fadd double %15, %20
%22 = fsub double %18, %21
%23 = tail call double @llvm.fmuladd.f64(double %19, double %22, double %17)
%24 = tail call double @run(i8* %0)
%25 = fsub double %24, %21
%26 = fdiv double %25, 5.000000e+00
%27 = fadd double %21, %26
%28 = fsub double %24, %27
%29 = tail call double @llvm.fmuladd.f64(double %25, double %28, double %23)
%30 = tail call double @run(i8* %0)
%31 = fsub double %30, %27
%32 = fdiv double %31, 6.000000e+00
%33 = fadd double %27, %32
%34 = fsub double %30, %33
%35 = tail call double @llvm.fmuladd.f64(double %31, double %34, double %29)
%36 = tail call double @run(i8* %0)
%37 = fsub double %36, %33
%38 = fdiv double %37, 7.000000e+00
%39 = fadd double %33, %38
%40 = fsub double %36, %39
%41 = tail call double @llvm.fmuladd.f64(double %37, double %40, double %35)
%42 = tail call double @run(i8* %0)
%43 = fsub double %42, %39
%44 = fmul double %43, 1.250000e-01
%45 = fadd double %39, %44
%46 = fsub double %42, %45
%47 = tail call double @llvm.fmuladd.f64(double %43, double %46, double %41)
%48 = tail call double @run(i8* %0)
%49 = fsub double %48, %45
%50 = fdiv double %49, 9.000000e+00
%51 = fadd double %45, %50
%52 = fsub double %48, %51
%53 = tail call double @llvm.fmuladd.f64(double %49, double %52, double %47)
%54 = tail call double @run(i8* %0)
%55 = fsub double %54, %51
%56 = fdiv double %55, 1.000000e+01
%57 = fadd double %51, %56
%58 = fsub double %54, %57
%59 = tail call double @llvm.fmuladd.f64(double %55, double %58, double %53)
%60 = fdiv double %59, 9.000000e+00
%61 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0, double %57, double %60)
ret double %57
}