#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, int);
int pow(int, int);
int /*<<< orphan*/ print_results(int, 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 iter;
  int len;
  int i;
  int j;
  srand(time(NULL));
  print_version();
  count = 0;
  for (i = 1; i <= 6; i++) {
    len = pow(10, i);
    iter = 1000000;
    for (j = 0; j < 3; j++) {
      count += 1;
      printf("# c::%s:len=%d\n", "dmaxsorted", len);
      elapsed = benchmark(iter, len);
      print_results(iter, elapsed);
      printf("ok %d benchmark finished\n", count);
    }
  }
  print_summary(count, count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%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,-0x14(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0x6,-0x20(%rbp)
jg     1256 <main+0xd6>
mov    -0x20(%rbp),%esi
mov    $0xa,%edi
call   1090 <pow@plt>
mov    %eax,-0x1c(%rbp)
movl   $0xf4240,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1243 <main+0xc3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%edx
lea    0xe07(%rip),%rdi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1080 <benchmark@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
call   1050 <print_results@plt>
mov    -0x14(%rbp),%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11dc <main+0x5c>
jmp    1248 <main+0xc8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b4 <main+0x34>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10a0 <print_summary@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1030 <print_version@plt>
mov    $0x1,%r13d
mov    $0x3,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r13d,%esi
call   1090 <pow@plt>
mov    %eax,%ebp
lea    -0x2(%rbx),%r14d
lea    0xe36(%rip),%rdi
lea    0xe3f(%rip),%r15
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xf4240,%edi
mov    %ebp,%esi
call   1080 <benchmark@plt>
mov    $0xf4240,%edi
call   1050 <print_results@plt>
lea    0xe21(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%rbx),%r14d
lea    0xdf1(%rip),%r12
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xf4240,%edi
mov    %ebp,%esi
call   1080 <benchmark@plt>
mov    $0xf4240,%edi
call   1050 <print_results@plt>
lea    0xde0(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xf4240,%edi
mov    %ebp,%esi
call   1080 <benchmark@plt>
mov    $0xf4240,%edi
call   1050 <print_results@plt>
lea    0xdaa(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13d
add    $0x3,%ebx
cmp    $0x15,%ebx
jne    11b0 <main+0x30>
mov    $0x12,%edi
mov    $0x12,%esi
call   10a0 <print_summary@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"# c::%s:len=%d\0A\00"
@.str.1 = [11 x i8] c"dmaxsorted\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
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
%10 = call i32 (...) @print_version()
store i32 0, i32* %3
store i32 1, i32* %6
br label %11
11: ; preds = %37, %0
%12 = load i32, i32* %6
%13 = icmp sle i32 %12, 6
br i1 %13, label %14, label %40
14: ; preds = %11
%15 = load i32, i32* %6
%16 = call i32 @pow(i32 10, i32 %15)
store i32 %16, i32* %5
store i32 1000000, i32* %4
store i32 0, i32* %7
br label %17
17: ; preds = %33, %14
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %36
20: ; preds = %17
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call double @benchmark(i32 %25, i32 %26)
store double %27, double* %2
%28 = load i32, i32* %4
%29 = load double, double* %2
%30 = call i32 @print_results(i32 %28, double %29)
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %20
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %17
36: ; preds = %17
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %11
40: ; preds = %11
%41 = load i32, i32* %3
%42 = load i32, i32* %3
%43 = call i32 @print_summary(i32 %41, i32 %42)
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [16 x i8] c"# c::%s:len=%d\0A\00"
@.str.1 = [11 x i8] c"dmaxsorted\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()
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 1, %0 ], [ %23, %4 ]
%6 = phi i32 [ 0, %0 ], [ %18, %4 ]
%7 = tail call i32 @pow(i32 10, i32 %5)
%8 = add nuw nsw i32 %6, 1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%10 = tail call double @benchmark(i32 1000000, i32 %7)
%11 = tail call i32 @print_results(i32 1000000, double %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%13 = add nuw nsw i32 %6, 2
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%15 = tail call double @benchmark(i32 1000000, i32 %7)
%16 = tail call i32 @print_results(i32 1000000, double %15)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%18 = add nuw nsw i32 %6, 3
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%20 = tail call double @benchmark(i32 1000000, i32 %7)
%21 = tail call i32 @print_results(i32 1000000, double %20)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%23 = add nuw nsw i32 %5, 1
%24 = icmp eq i32 %23, 7
br i1 %24, label %25, label %4
25: ; preds = %4
%26 = tail call i32 @print_summary(i32 18, i32 18)
ret i32 0
}