#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 *calloc(int, int);
int /*<<< orphan*/ free(double *);
double get_time();
int /*<<< orphan*/ morpheus_identity(int, double *);
int /*<<< orphan*/ printf(char *, char const *, double);
void bench_morpheus_identity(int n, const char *message, int size) {
  double *x = calloc(size * size, sizeof(double));
  double start = get_time();
  for (int i = 0; i < n; ++i) {
    x[0] = i;
    morpheus_identity(size, x);
  }
  double finish = get_time();
  free(x);
  double ms = (finish - start) / n;
  printf("Benchmark %s: %f ms\n", message, ms);
}


x86 assembly (clang, -O0):
<bench_morpheus_identity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
imul   -0x14(%rbp),%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <get_time@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bd <bench_morpheus_identity+0x6d>
cvtsi2sdl -0x2c(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1060 <morpheus_identity@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118a <bench_morpheus_identity+0x3a>
mov    $0x0,%al
call   1050 <get_time@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x38(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rsi
movsd  -0x40(%rbp),%xmm0
lea    0xe06(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bench_morpheus_identity>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r12d
mov    %rsi,%r14
mov    %edi,%r15d
mov    %edx,%edi
imul   %edx,%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1050 <get_time@plt>
movsd  %xmm0,0x8(%rsp)
test   %r15d,%r15d
jle    11b7 <bench_morpheus_identity+0x67>
xorpd  %xmm0,%xmm0
mov    %r15d,%ebx
movsd  %xmm0,(%rsp)
movsd  %xmm0,0x0(%rbp)
mov    %r12d,%edi
mov    %rbp,%rsi
call   1060 <morpheus_identity@plt>
movsd  (%rsp),%xmm0
addsd  0xe4e(%rip),%xmm0
add    $0xffffffff,%ebx
jne    1190 <bench_morpheus_identity+0x40>
xor    %eax,%eax
call   1050 <get_time@plt>
movsd  %xmm0,(%rsp)
mov    %rbp,%rdi
call   1030 <free@plt>
movsd  (%rsp),%xmm1
subsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    0xe1b(%rip),%rdi
mov    %r14,%rsi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Benchmark %s: %f ms\0A\00"
define void @bench_morpheus_identity(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%12 = load i32, i32* %6
%13 = load i32, i32* %6
%14 = mul nsw i32 %12, %13
%15 = call double* @calloc(i32 %14, i32 8)
store double* %15, double** %7
%16 = call double (...) @get_time()
store double %16, double* %8
store i32 0, i32* %9
br label %17
17: ; preds = %29, %3
%18 = load i32, i32* %9
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = load i32, i32* %9
%23 = sitofp i32 %22 to double
%24 = load double*, double** %7
%25 = getelementptr inbounds double, double* %24, i64 0
store double %23, double* %25
%26 = load i32, i32* %6
%27 = load double*, double** %7
%28 = call i32 @morpheus_identity(i32 %26, double* %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %17
32: ; preds = %17
%33 = call double (...) @get_time()
store double %33, double* %10
%34 = load double*, double** %7
%35 = call i32 @free(double* %34)
%36 = load double, double* %10
%37 = load double, double* %8
%38 = fsub double %36, %37
%39 = load i32, i32* %4
%40 = sitofp i32 %39 to double
%41 = fdiv double %38, %40
store double %41, double* %11
%42 = load i8*, i8** %5
%43 = load double, double* %11
%44 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %42, double %43)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Benchmark %s: %f ms\0A\00"
define void @bench_morpheus_identity(i32 %0, i8* %1, i32 %2) {
%4 = mul nsw i32 %2, %2
%5 = tail call double* @calloc(i32 %4, i32 8)
%6 = tail call double (...) @get_time()
%7 = icmp sgt i32 %0, 0
br i1 %7, label %15, label %8
8: ; preds = %15, %3
%9 = tail call double (...) @get_time()
%10 = tail call i32 @free(double* %5)
%11 = fsub double %9, %6
%12 = sitofp i32 %0 to double
%13 = fdiv double %11, %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %1, double %13)
ret void
15: ; preds = %3, %15
%16 = phi i32 [ %19, %15 ], [ 0, %3 ]
%17 = sitofp i32 %16 to double
store double %17, double* %5
%18 = tail call i32 @morpheus_identity(i32 %2, double* %5)
%19 = add nuw nsw i32 %16, 1
%20 = icmp eq i32 %19, %0
br i1 %20, label %8, label %15
}