#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*/ _mm_free(double *);
scalar_t__ _mm_malloc(int, int);
int atoi(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
double time_ddot(int, double *, int, double *, int);
int /*<<< orphan*/ vector_init(double *, int, int);
int main(int argc, char *argv[]) {
  double mflop_s, mflop_b;
  int N;
  if (argc == 2) {
    N = atoi(argv[1]);
  } else {
    N = 8192;
  }
  int incx = 1;
  int incy = 1;
  double *A = (double *)_mm_malloc(N * sizeof(double), 64);
  double *B = (double *)_mm_malloc(N * sizeof(double), 64);
  vector_init(A, N, 1.);
  vector_init(B, N, 1.);
  printf("Size: %g KB: ", 2 * N * 8 / 1024.);
  fflush(stdout);
  double dot = time_ddot(N, A, incx, B, incy);
  printf("\n");
  _mm_free(A);
  _mm_free(B);
  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)
cmpl   $0x2,-0x8(%rbp)
jne    11a5 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    11ac <main+0x3c>
movl   $0x2000,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
mov    $0x40,%esi
call   1080 <_mm_malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
mov    $0x40,%esi
call   1080 <_mm_malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
call   1030 <vector_init@plt>
mov    -0x40(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
call   1030 <vector_init@plt>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
shl    $0x3,%eax
cvtsi2sd %eax,%xmm0
movsd  0xddf(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xddc(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x24(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x40(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1060 <time_ddot@plt>
movsd  %xmm0,-0x48(%rbp)
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1090 <_mm_free@plt>
mov    -0x40(%rbp),%rdi
call   1090 <_mm_free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x2000,%ebx
cmp    $0x2,%edi
jne    119c <main+0x1c>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
lea    0x0(,%rbx,8),%ebp
mov    %ebp,%edi
mov    $0x40,%esi
call   1090 <_mm_malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
mov    $0x40,%esi
call   1090 <_mm_malloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <vector_init@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <vector_init@plt>
mov    %ebx,%eax
shl    $0x4,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe10(%rip),%xmm0
lea    0xe11(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %r15,%rcx
mov    $0x1,%r8d
call   1070 <time_ddot@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   10a0 <_mm_free@plt>
mov    %r15,%rdi
call   10a0 <_mm_free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Size: %g KB: \00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %8
br label %22
21: ; preds = %2
store i32 8192, i32* %8
br label %22
22: ; preds = %21, %16
store i32 1, i32* %9
store i32 1, i32* %10
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 8
%26 = trunc i64 %25 to i32
%27 = call i64 @_mm_malloc(i32 %26, i32 64)
%28 = inttoptr i64 %27 to double*
store double* %28, double** %11
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 8
%32 = trunc i64 %31 to i32
%33 = call i64 @_mm_malloc(i32 %32, i32 64)
%34 = inttoptr i64 %33 to double*
store double* %34, double** %12
%35 = load double*, double** %11
%36 = load i32, i32* %8
%37 = call i32 @vector_init(double* %35, i32 %36, i32 1)
%38 = load double*, double** %12
%39 = load i32, i32* %8
%40 = call i32 @vector_init(double* %38, i32 %39, i32 1)
%41 = load i32, i32* %8
%42 = mul nsw i32 2, %41
%43 = mul nsw i32 %42, 8
%44 = sitofp i32 %43 to double
%45 = fdiv double %44, 1.024000e+03
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %45)
%47 = load i32, i32* @stdout
%48 = call i32 @fflush(i32 %47)
%49 = load i32, i32* %8
%50 = load double*, double** %11
%51 = load i32, i32* %9
%52 = load double*, double** %12
%53 = load i32, i32* %10
%54 = call double @time_ddot(i32 %49, double* %50, i32 %51, double* %52, i32 %53)
store double %54, double* %13
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%56 = load double*, double** %11
%57 = call i32 @_mm_free(double* %56)
%58 = load double*, double** %12
%59 = call i32 @_mm_free(double* %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Size: %g KB: \00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %2, %4
%9 = phi i32 [ %7, %4 ], [ 8192, %2 ]
%10 = shl i32 %9, 3
%11 = tail call i64 @_mm_malloc(i32 %10, i32 64)
%12 = inttoptr i64 %11 to double*
%13 = tail call i64 @_mm_malloc(i32 %10, i32 64)
%14 = inttoptr i64 %13 to double*
%15 = tail call i32 @vector_init(double* %12, i32 %9, i32 1)
%16 = tail call i32 @vector_init(double* %14, i32 %9, i32 1)
%17 = shl nsw i32 %9, 4
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 0x3F50000000000000
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %19)
%21 = load i32, i32* @stdout
%22 = tail call i32 @fflush(i32 %21)
%23 = tail call double @time_ddot(i32 %9, double* %12, i32 1, double* %14, i32 1)
%24 = tail call i32 @putchar(i32 10)
%25 = tail call i32 @_mm_free(double* %12)
%26 = tail call i32 @_mm_free(double* %14)
ret i32 0
}