#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 */
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ stackDynMatrixMult();
int /*<<< orphan*/ staticMatrixMult();
long time(int /*<<< orphan*/ *);
void main() {
  int i = 0;
  long start = 0;
  long end = 0;
  start = time(NULL);
  for (i = 0; i < 5000; i++) {
    staticMatrixMult();
  }
  end = time(NULL);
  printf("%ld seconds\n", (end - start));
  start = time(NULL);
  for (i = 0; i < 5000; i++) {
    stackDynMatrixMult();
  }
  end = time(NULL);
  printf("%ld seconds\n", (end - start));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x1388,-0x4(%rbp)
jge    1195 <main+0x55>
mov    $0x0,%al
call   1030 <staticMatrixMult@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1173 <main+0x33>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
sub    -0x10(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x1388,-0x4(%rbp)
jge    11ec <main+0xac>
mov    $0x0,%al
call   1060 <stackDynMatrixMult@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11ca <main+0x8a>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
sub    -0x10(%rbp),%rsi
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rbx
mov    $0x1388,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <staticMatrixMult@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x20>
xor    %edi,%edi
call   1050 <time@plt>
sub    %rbx,%rax
lea    0xe83(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,%rbx
mov    $0x1388,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <stackDynMatrixMult@plt>
add    $0xffffffff,%ebp
jne    11a0 <main+0x60>
xor    %edi,%edi
call   1050 <time@plt>
sub    %rbx,%rax
lea    0xe43(%rip),%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%ld seconds\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
%4 = call i64 @time(i32* null)
store i64 %4, i64* %2
store i32 0, i32* %1
br label %5
5: ; preds = %10, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 5000
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = call i32 (...) @staticMatrixMult()
br label %10
10: ; preds = %8
%11 = load i32, i32* %1
%12 = add nsw i32 %11, 1
store i32 %12, i32* %1
br label %5
13: ; preds = %5
%14 = call i64 @time(i32* null)
store i64 %14, i64* %3
%15 = load i64, i64* %3
%16 = load i64, i64* %2
%17 = sub nsw i64 %15, %16
%18 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 %17)
%19 = call i64 @time(i32* null)
store i64 %19, i64* %2
store i32 0, i32* %1
br label %20
20: ; preds = %25, %13
%21 = load i32, i32* %1
%22 = icmp slt i32 %21, 5000
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = call i32 (...) @stackDynMatrixMult()
br label %25
25: ; preds = %23
%26 = load i32, i32* %1
%27 = add nsw i32 %26, 1
store i32 %27, i32* %1
br label %20
28: ; preds = %20
%29 = call i64 @time(i32* null)
store i64 %29, i64* %3
%30 = load i64, i64* %3
%31 = load i64, i64* %2
%32 = sub nsw i64 %30, %31
%33 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 %32)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%ld seconds\0A\00"
define void @main() {
%1 = tail call i64 @time(i32* null)
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %5, %2 ]
%4 = tail call i32 (...) @staticMatrixMult()
%5 = add nuw nsw i32 %3, 1
%6 = icmp eq i32 %5, 5000
br i1 %6, label %7, label %2
7: ; preds = %2
%8 = tail call i64 @time(i32* null)
%9 = sub nsw i64 %8, %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = tail call i64 @time(i32* null)
br label %12
12: ; preds = %7, %12
%13 = phi i32 [ 0, %7 ], [ %15, %12 ]
%14 = tail call i32 (...) @stackDynMatrixMult()
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, 5000
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = tail call i64 @time(i32* null)
%19 = sub nsw i64 %18, %11
%20 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 %19)
ret void
}