#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();
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:order=row-major\n", "shape2strides");
    elapsed = benchmark1();
    print_results(elapsed);
    printf("ok %d benchmark finished\n", count);
  }
  for (i = 0; i < 3; i++) {
    count += 1;
    printf("# c::native::%s:order=column-major\n", "shape2strides");
    elapsed = benchmark2();
    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   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    $0x0,%al
call   1030 <print_version@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1211 <main+0x91>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe32(%rip),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <benchmark1@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <print_results@plt>
mov    -0x14(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b4 <main+0x34>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1275 <main+0xf5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe17(%rip),%rdi
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1090 <benchmark2@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <print_results@plt>
mov    -0x14(%rbp),%esi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1218 <main+0x98>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10a0 <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   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
xor    %eax,%eax
call   1030 <print_version@plt>
lea    0xe5f(%rip),%rbx
lea    0xe79(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <benchmark1@plt>
call   1060 <print_results@plt>
lea    0xe67(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <benchmark1@plt>
call   1060 <print_results@plt>
mov    %r15,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <benchmark1@plt>
call   1060 <print_results@plt>
mov    %r15,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1b(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <benchmark2@plt>
call   1060 <print_results@plt>
mov    %r15,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <benchmark2@plt>
call   1060 <print_results@plt>
mov    %r15,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1090 <benchmark2@plt>
call   1060 <print_results@plt>
mov    %r15,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x6,%edi
mov    $0x6,%esi
call   10a0 <print_summary@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"# c::native::%s:order=row-major\0A\00"
@.str.1 = [14 x i8] c"shape2strides\00"
@.str.2 = [26 x i8] c"ok %d benchmark finished\0A\00"
@.str.3 = [36 x i8] c"# c::native::%s:order=column-major\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 ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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
%40 = load i32, i32* %3
%41 = load i32, i32* %3
%42 = call i32 @print_summary(i32 %40, i32 %41)
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [33 x i8] c"# c::native::%s:order=row-major\0A\00"
@.str.1 = [14 x i8] c"shape2strides\00"
@.str.2 = [26 x i8] c"ok %d benchmark finished\0A\00"
@.str.3 = [36 x i8] c"# c::native::%s:order=column-major\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 ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 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 @print_summary(i32 6, i32 6)
ret i32 0
}