#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 */
struct timespec {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ compute(unsigned long **, unsigned long **, unsigned long **,
                           unsigned long **, int);
int /*<<< orphan*/ free(unsigned long **);
unsigned long **get_int64_twodim_array(int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ ts_diff(struct timespec, struct timespec);
int /*<<< orphan*/ ts_to_double(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int N = 3000;
  unsigned long **a = get_int64_twodim_array(N + 1);
  unsigned long **b = get_int64_twodim_array(N + 1);
  unsigned long **c = get_int64_twodim_array(N + 1);
  unsigned long **d = get_int64_twodim_array(N + 1);
  struct timespec begin, end;
  clock_gettime(CLOCK_REALTIME, &begin);
  compute(a, b, c, d, N);
  clock_gettime(CLOCK_REALTIME, &end);
  printf("\nProcessing Time: %.3lf seconds", ts_to_double(ts_diff(begin, end)));
  free(a);
  free(b);
  free(c);
  free(d);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xbb8,-0x14(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1080 <get_int64_twodim_array@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1080 <get_int64_twodim_array@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1080 <get_int64_twodim_array@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1080 <get_int64_twodim_array@plt>
mov    %rax,-0x38(%rbp)
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x14(%rbp),%r8d
call   1090 <compute@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    -0x48(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x40(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1060 <ts_diff@plt>
mov    %eax,%edi
call   1070 <ts_to_double@plt>
mov    %eax,%esi
lea    0xddf(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0xbb9,%edi
call   1080 <get_int64_twodim_array@plt>
mov    %rax,%r14
mov    $0xbb9,%edi
call   1080 <get_int64_twodim_array@plt>
mov    %rax,%r15
mov    $0xbb9,%edi
call   1080 <get_int64_twodim_array@plt>
mov    %rax,%r12
mov    $0xbb9,%edi
call   1080 <get_int64_twodim_array@plt>
mov    %rax,%rbx
mov    0x2e28(%rip),%r13
mov    0x0(%r13),%edi
lea    0x8(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    $0xbb8,%r8d
call   1090 <compute@plt>
mov    0x0(%r13),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    0x8(%rsp),%edi
mov    (%rsp),%esi
call   1060 <ts_diff@plt>
mov    %eax,%edi
call   1070 <ts_to_double@plt>
lea    0xdfd(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@CLOCK_REALTIME = global i32 0
@.str = [32 x i8] c"\0AProcessing Time: %.3lf seconds\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64**
%8 = alloca i64**
%9 = alloca i64**
%10 = alloca i64**
%11 = alloca %struct.timespec
%12 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3000, i32* %6
%13 = load i32, i32* %6
%14 = add nsw i32 %13, 1
%15 = call i64** @get_int64_twodim_array(i32 %14)
store i64** %15, i64*** %7
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
%18 = call i64** @get_int64_twodim_array(i32 %17)
store i64** %18, i64*** %8
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
%21 = call i64** @get_int64_twodim_array(i32 %20)
store i64** %21, i64*** %9
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
%24 = call i64** @get_int64_twodim_array(i32 %23)
store i64** %24, i64*** %10
%25 = load i32, i32* @CLOCK_REALTIME
%26 = call i32 @clock_gettime(i32 %25, %struct.timespec* %11)
%27 = load i64**, i64*** %7
%28 = load i64**, i64*** %8
%29 = load i64**, i64*** %9
%30 = load i64**, i64*** %10
%31 = load i32, i32* %6
%32 = call i32 @compute(i64** %27, i64** %28, i64** %29, i64** %30, i32 %31)
%33 = load i32, i32* @CLOCK_REALTIME
%34 = call i32 @clock_gettime(i32 %33, %struct.timespec* %12)
%35 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.timespec, %struct.timespec* %12, i32 0, i32 0
%38 = load i32, i32* %37
%39 = call i32 @ts_diff(i32 %36, i32 %38)
%40 = call i32 @ts_to_double(i32 %39)
%41 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = load i64**, i64*** %7
%43 = call i32 @free(i64** %42)
%44 = load i64**, i64*** %8
%45 = call i32 @free(i64** %44)
%46 = load i64**, i64*** %9
%47 = call i32 @free(i64** %46)
%48 = load i64**, i64*** %10
%49 = call i32 @free(i64** %48)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@CLOCK_REALTIME = global i32 0
@.str = [32 x i8] c"\0AProcessing Time: %.3lf seconds\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = tail call i64** @get_int64_twodim_array(i32 3001)
%6 = tail call i64** @get_int64_twodim_array(i32 3001)
%7 = tail call i64** @get_int64_twodim_array(i32 3001)
%8 = tail call i64** @get_int64_twodim_array(i32 3001)
%9 = bitcast %struct.timespec* %3 to i8*
%10 = bitcast %struct.timespec* %4 to i8*
%11 = load i32, i32* @CLOCK_REALTIME
%12 = call i32 @clock_gettime(i32 %11, %struct.timespec* %3)
%13 = call i32 @compute(i64** %5, i64** %6, i64** %7, i64** %8, i32 3000)
%14 = load i32, i32* @CLOCK_REALTIME
%15 = call i32 @clock_gettime(i32 %14, %struct.timespec* %4)
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @ts_diff(i32 %17, i32 %19)
%21 = call i32 @ts_to_double(i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = call i32 @free(i64** %5)
%24 = call i32 @free(i64** %6)
%25 = call i32 @free(i64** %7)
%26 = call i32 @free(i64** %8)
ret i32 0
}