#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 benchmark1();
double benchmark2();
double benchmark3();
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::native::%s:mode=error\n", "ind");
    elapsed = benchmark1();
    print_results(elapsed);
    printf("ok %d benchmark finished\n", count);
  }
  for (i = 0; i < 3; i++) {
    count += 1;
    printf("# c::native::%s:mode=clamp\n", "ind");
    elapsed = benchmark2();
    print_results(elapsed);
    printf("ok %d benchmark finished\n", count);
  }
  for (i = 0; i < 3; i++) {
    count += 1;
    printf("# c::native::%s:mode=wrap\n", "ind");
    elapsed = benchmark3();
    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   1090 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
mov    $0x0,%al
call   1030 <print_version@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1221 <main+0x91>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe22(%rip),%rdi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <benchmark1@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <print_results@plt>
mov    -0x14(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c4 <main+0x34>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1285 <main+0xf5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xdf8(%rip),%rdi
lea    0xdd3(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10a0 <benchmark2@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <print_results@plt>
mov    -0x14(%rbp),%esi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1228 <main+0x98>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    12e9 <main+0x159>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xdb0(%rip),%rdi
lea    0xd6f(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <benchmark3@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <print_results@plt>
mov    -0x14(%rbp),%esi
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    128c <main+0xfc>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10b0 <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   1090 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
xor    %eax,%eax
call   1030 <print_version@plt>
lea    0xe4f(%rip),%rbx
lea    0xe64(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1040 <benchmark1@plt>
call   1070 <print_results@plt>
lea    0xe48(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1040 <benchmark1@plt>
call   1070 <print_results@plt>
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1040 <benchmark1@plt>
call   1070 <print_results@plt>
mov    %r15,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdfc(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <benchmark2@plt>
call   1070 <print_results@plt>
mov    %r15,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <benchmark2@plt>
call   1070 <print_results@plt>
mov    %r15,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <benchmark2@plt>
call   1070 <print_results@plt>
mov    %r15,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd99(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <benchmark3@plt>
call   1070 <print_results@plt>
mov    %r15,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <benchmark3@plt>
call   1070 <print_results@plt>
mov    %r15,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <benchmark3@plt>
call   1070 <print_results@plt>
mov    %r15,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x9,%edi
mov    $0x9,%esi
call   10b0 <print_summary@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"# c::native::%s:mode=error\0A\00"
@.str.1 = [4 x i8] c"ind\00"
@.str.2 = [26 x i8] c"ok %d benchmark finished\0A\00"
@.str.3 = [28 x i8] c"# c::native::%s:mode=clamp\0A\00"
@.str.4 = [27 x i8] c"# c::native::%s:mode=wrap\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 ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = call double (...) @benchmark1()
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
store i32 0, i32* %4
br label %24
24: ; preds = %36, %23
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 3
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%31 = call double (...) @benchmark2()
store double %31, double* %2
%32 = load double, double* %2
%33 = call i32 @print_results(double %32)
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %27
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %24
39: ; preds = %24
store i32 0, i32* %4
br label %40
40: ; preds = %52, %39
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 3
br i1 %42, label %43, label %55
43: ; preds = %40
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%47 = call double (...) @benchmark3()
store double %47, double* %2
%48 = load double, double* %2
%49 = call i32 @print_results(double %48)
%50 = load i32, i32* %3
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %43
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
store i32 %54, i32* %4
br label %40
55: ; preds = %40
%56 = load i32, i32* %3
%57 = load i32, i32* %3
%58 = call i32 @print_summary(i32 %56, i32 %57)
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@.str = [28 x i8] c"# c::native::%s:mode=error\0A\00"
@.str.1 = [4 x i8] c"ind\00"
@.str.2 = [26 x i8] c"ok %d benchmark finished\0A\00"
@.str.3 = [28 x i8] c"# c::native::%s:mode=clamp\0A\00"
@.str.4 = [27 x i8] c"# c::native::%s:mode=wrap\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 ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call double (...) @benchmark1()
%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 ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call double (...) @benchmark1()
%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 ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call double (...) @benchmark1()
%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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call double (...) @benchmark2()
%18 = tail call i32 @print_results(double %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 4)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call double (...) @benchmark2()
%22 = tail call i32 @print_results(double %21)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 5)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%25 = tail call double (...) @benchmark2()
%26 = tail call i32 @print_results(double %25)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 6)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%29 = tail call double (...) @benchmark3()
%30 = tail call i32 @print_results(double %29)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 7)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%33 = tail call double (...) @benchmark3()
%34 = tail call i32 @print_results(double %33)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 8)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%37 = tail call double (...) @benchmark3()
%38 = tail call i32 @print_results(double %37)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 9)
%40 = tail call i32 @print_summary(i32 9, i32 9)
ret i32 0
}