#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 benchmark();
int /*<<< orphan*/ print_results(double);
int /*<<< orphan*/ print_summary(int, int);
int /*<<< orphan*/ print_version();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  double elapsed;
  int count;
  int i;
  count = 0;
  srand(time(NULL));
  print_version();
  for (i = 0; i < 3; i++) {
    count += 1;
    printf("# c::%s\n", "base/uniform");
    elapsed = benchmark();
    print_results(elapsed);
    printf("ok %d benchmark finished\n", count);
  }
  print_summary(count, count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   1030 <print_version@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1201 <main+0x91>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe42(%rip),%rdi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <benchmark@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <print_results@plt>
mov    -0x14(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a4 <main+0x34>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1090 <print_summary@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1030 <print_version@plt>
lea    0xe6f(%rip),%r15
lea    0xe71(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1080 <benchmark@plt>
call   1050 <print_results@plt>
lea    0xe5e(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1080 <benchmark@plt>
call   1050 <print_results@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1080 <benchmark@plt>
call   1050 <print_results@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3,%edi
mov    $0x3,%esi
call   1090 <print_summary@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"# c::%s\0A\00"
@.str.1 = [13 x i8] c"base/uniform\00"
@.str.2 = [26 x i8] c"ok %d benchmark finished\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
%7 = call i32 (...) @print_version()
store i32 0, i32* %4
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%15 = call double (...) @benchmark()
store double %15, double* %2
%16 = load double, double* %2
%17 = call i32 @print_results(double %16)
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %11
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %8
%24 = load i32, i32* %3
%25 = load i32, i32* %3
%26 = call i32 @print_summary(i32 %24, i32 %25)
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [9 x i8] c"# c::%s\0A\00"
@.str.1 = [13 x i8] c"base/uniform\00"
@.str.2 = [26 x i8] c"ok %d benchmark finished\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 (...) @print_version()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call double (...) @benchmark()
%6 = tail call i32 @print_results(double %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 1)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call double (...) @benchmark()
%10 = tail call i32 @print_results(double %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 2)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call double (...) @benchmark()
%14 = tail call i32 @print_results(double %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 3)
%16 = tail call i32 @print_summary(i32 3, i32 3)
ret i32 0
}