#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*/ check(float, float);
float dotprod(float *, float *, int);
float dotprod_ref(float *, float *, int);
int /*<<< orphan*/ free(float *);
int /*<<< orphan*/ init(float *, float *, int);
scalar_t__ malloc(int);
int main() {
  float *v1 = (float *)malloc(1024 * 1024 * sizeof(float));
  float *v2 = (float *)malloc(1024 * 1024 * sizeof(float));
  float p1, p2;
  init(v1, v2, 1024 * 1024);
  p1 = dotprod_ref(v1, v2, 1024 * 1024);
  p2 = dotprod(v1, v2, 1024 * 1024);
  check(p1, p2);
  free(v1);
  free(v2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x400000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x400000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x100000,%edx
call   1060 <init@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x100000,%edx
call   1030 <dotprod_ref@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x100000,%edx
call   1050 <dotprod@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
call   1080 <check@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x400000,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x400000,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x100000,%edx
call   1060 <init@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x100000,%edx
call   1030 <dotprod_ref@plt>
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x100000,%edx
call   1050 <dotprod@plt>
movaps %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
call   1080 <check@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca float*
%3 = alloca float*
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
%6 = call i64 @malloc(i32 4194304)
%7 = inttoptr i64 %6 to float*
store float* %7, float** %2
%8 = call i64 @malloc(i32 4194304)
%9 = inttoptr i64 %8 to float*
store float* %9, float** %3
%10 = load float*, float** %2
%11 = load float*, float** %3
%12 = call i32 @init(float* %10, float* %11, i32 1048576)
%13 = load float*, float** %2
%14 = load float*, float** %3
%15 = call float @dotprod_ref(float* %13, float* %14, i32 1048576)
store float %15, float* %4
%16 = load float*, float** %2
%17 = load float*, float** %3
%18 = call float @dotprod(float* %16, float* %17, i32 1048576)
store float %18, float* %5
%19 = load float, float* %4
%20 = load float, float* %5
%21 = call i32 @check(float %19, float %20)
%22 = load float*, float** %2
%23 = call i32 @free(float* %22)
%24 = load float*, float** %3
%25 = call i32 @free(float* %24)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 4194304)
%2 = inttoptr i64 %1 to float*
%3 = tail call i64 @malloc(i32 4194304)
%4 = inttoptr i64 %3 to float*
%5 = tail call i32 @init(float* %2, float* %4, i32 1048576)
%6 = tail call float @dotprod_ref(float* %2, float* %4, i32 1048576)
%7 = tail call float @dotprod(float* %2, float* %4, i32 1048576)
%8 = tail call i32 @check(float %6, float %7)
%9 = tail call i32 @free(float* %2)
%10 = tail call i32 @free(float* %4)
ret i32 0
}