#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 */
double get_median(double *, int);
double get_stddev(double *, int);
int /*<<< orphan*/ printf(char *, char const *, int, double, double);
void measure_30_times(double (*measure)(int), int num_threads,
                      const char *name) {
  double measure_array[30];
  for (int m = 0; m < 30; ++m) {
    measure_array[m] = measure(100);
  }
  printf("%s (%d): std_dev = %f, median = %f\n", name, num_threads,
         get_stddev(measure_array, 30), get_median(measure_array, 30));
}


x86 assembly (clang, -O0):
<measure_30_times>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x114(%rbp)
cmpl   $0x1e,-0x114(%rbp)
jge    1189 <measure_30_times+0x59>
mov    $0x64,%edi
call   *-0x8(%rbp)
movslq -0x114(%rbp),%rax
movsd  %xmm0,-0x110(%rbp,%rax,8)
ff ff
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1150 <measure_30_times+0x20>
mov    -0x18(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x124(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0x1e,%esi
call   1030 <get_stddev@plt>
movsd  %xmm0,-0x120(%rbp)
ff
lea    -0x110(%rbp),%rdi
mov    $0x1e,%esi
call   1050 <get_median@plt>
mov    -0x130(%rbp),%rsi
mov    -0x124(%rbp),%edx
movaps %xmm0,%xmm1
movsd  -0x120(%rbp),%xmm0
ff
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<measure_30_times>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x64,%edi
call   *%rbx
movsd  %xmm0,0x10(%rsp,%rbp,8)
add    $0x1,%rbp
cmp    $0x1e,%rbp
jne    1150 <measure_30_times+0x20>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1030 <get_stddev@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1050 <get_median@plt>
movaps %xmm0,%xmm1
lea    0xe6a(%rip),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
movsd  0x8(%rsp),%xmm0
call   1040 <printf@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"%s (%d): std_dev = %f, median = %f\0A\00"
define void @measure_30_times(double (i32)* %0, i32 %1, i8* %2) {
%4 = alloca double (i32)*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [30 x double]
%8 = alloca i32
store double (i32)* %0, double (i32)** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %8
br label %9
9: ; preds = %18, %3
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 30
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load double (i32)*, double (i32)** %4
%14 = call double %13(i32 100)
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 %16
store double %14, double* %17
br label %18
18: ; preds = %12
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 1
store i32 %20, i32* %8
br label %9
21: ; preds = %9
%22 = load i8*, i8** %6
%23 = load i32, i32* %5
%24 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%25 = call double @get_stddev(double* %24, i32 30)
%26 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%27 = call double @get_median(double* %26, i32 30)
%28 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %22, i32 %23, double %25, double %27)
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"%s (%d): std_dev = %f, median = %f\0A\00"
define void @measure_30_times(double (i32)* nocapture %0, i32 %1, i8* %2) {
%4 = alloca [30 x double]
%5 = bitcast [30 x double]* %4 to i8*
br label %11
6: ; preds = %11
%7 = getelementptr inbounds [30 x double], [30 x double]* %4, i64 0, i64 0
%8 = call double @get_stddev(double* %7, i32 30)
%9 = call double @get_median(double* %7, i32 30)
%10 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1, double %8, double %9)
ret void
11: ; preds = %3, %11
%12 = phi i64 [ 0, %3 ], [ %15, %11 ]
%13 = tail call double %0(i32 100)
%14 = getelementptr inbounds [30 x double], [30 x double]* %4, i64 0, i64 %12
store double %13, double* %14
%15 = add nuw nsw i64 %12, 1
%16 = icmp eq i64 %15, 30
br i1 %16, label %6, label %11
}