#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 get_time();
int /*<<< orphan*/ init_data(float **, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ pencil_saxpy_nn(int, int, int, float **, int, float **);
int main() {
  double start_time, end_time;
  float(*A)[1024 * 1024 * 10][1] =
      (float(*)[1024 * 1024 * 10][1]) malloc(1024 * 1024 * 10 * sizeof(float));
  float(*B)[1024 * 1024 * 10][1] =
      (float(*)[1024 * 1024 * 10][1]) malloc(1024 * 1024 * 10 * sizeof(float));
  init_data(*A, 1024 * 1024 * 10);
  init_data(*B, 1024 * 1024 * 10);
  start_time = get_time();
  pencil_saxpy_nn(1024 * 1024 * 10, 10, 1, *A, 1, *B);
  end_time = get_time();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2800000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x2800000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0xa00000,%esi
call   1030 <init_data@plt>
mov    -0x28(%rbp),%rdi
mov    $0xa00000,%esi
call   1030 <init_data@plt>
mov    $0x0,%al
call   1040 <get_time@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r9
mov    $0xa00000,%edi
mov    $0xa,%esi
mov    $0x1,%r8d
mov    %r8d,%edx
call   1060 <pencil_saxpy_nn@plt>
mov    $0x0,%al
call   1040 <get_time@plt>
movsd  %xmm0,-0x18(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x2800000,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x2800000,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0xa00000,%esi
call   1030 <init_data@plt>
mov    %rbx,%rdi
mov    $0xa00000,%esi
call   1030 <init_data@plt>
xor    %eax,%eax
call   1040 <get_time@plt>
mov    $0xa00000,%edi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
mov    $0x1,%r8d
mov    %rbx,%r9
call   1060 <pencil_saxpy_nn@plt>
xor    %eax,%eax
call   1040 <get_time@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca [10485760 x [1 x float]]*
%5 = alloca [10485760 x [1 x float]]*
store i32 0, i32* %1
%6 = call i64 @malloc(i32 41943040)
%7 = inttoptr i64 %6 to [10485760 x [1 x float]]*
store [10485760 x [1 x float]]* %7, [10485760 x [1 x float]]** %4
%8 = call i64 @malloc(i32 41943040)
%9 = inttoptr i64 %8 to [10485760 x [1 x float]]*
store [10485760 x [1 x float]]* %9, [10485760 x [1 x float]]** %5
%10 = load [10485760 x [1 x float]]*, [10485760 x [1 x float]]** %4
%11 = getelementptr inbounds [10485760 x [1 x float]], [10485760 x [1 x float]]* %10, i64 0, i64 0
%12 = bitcast [1 x float]* %11 to float**
%13 = call i32 @init_data(float** %12, i32 10485760)
%14 = load [10485760 x [1 x float]]*, [10485760 x [1 x float]]** %5
%15 = getelementptr inbounds [10485760 x [1 x float]], [10485760 x [1 x float]]* %14, i64 0, i64 0
%16 = bitcast [1 x float]* %15 to float**
%17 = call i32 @init_data(float** %16, i32 10485760)
%18 = call double (...) @get_time()
store double %18, double* %2
%19 = load [10485760 x [1 x float]]*, [10485760 x [1 x float]]** %4
%20 = getelementptr inbounds [10485760 x [1 x float]], [10485760 x [1 x float]]* %19, i64 0, i64 0
%21 = bitcast [1 x float]* %20 to float**
%22 = load [10485760 x [1 x float]]*, [10485760 x [1 x float]]** %5
%23 = getelementptr inbounds [10485760 x [1 x float]], [10485760 x [1 x float]]* %22, i64 0, i64 0
%24 = bitcast [1 x float]* %23 to float**
%25 = call i32 @pencil_saxpy_nn(i32 10485760, i32 10, i32 1, float** %21, i32 1, float** %24)
%26 = call double (...) @get_time()
store double %26, double* %3
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 41943040)
%2 = tail call i64 @malloc(i32 41943040)
%3 = inttoptr i64 %1 to float**
%4 = tail call i32 @init_data(float** %3, i32 10485760)
%5 = inttoptr i64 %2 to float**
%6 = tail call i32 @init_data(float** %5, i32 10485760)
%7 = tail call double (...) @get_time()
%8 = tail call i32 @pencil_saxpy_nn(i32 10485760, i32 10, i32 1, float** %3, i32 1, float** %5)
%9 = tail call double (...) @get_time()
ret i32 0
}