#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*/ assert(double const *);
double vectord_dot_product(const double *self, const double *vector2,
                           size_t size) {
  assert(self);
  assert(vector2);
  double result = 0.0;
  for (size_t i = 0; i < size; i++)
    result += self[i] * vector2[i];
  return result;
}


x86 assembly (clang, -O0):
<vectord_dot_product>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1191 <vectord_dot_product+0x81>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1146 <vectord_dot_product+0x36>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectord_dot_product>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    %r14,%rdi
call   1030 <assert@plt>
test   %r15,%r15
je     1148 <vectord_dot_product+0x38>
lea    -0x1(%r15),%rcx
mov    %r15d,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jae    1151 <vectord_dot_product+0x41>
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
jmp    11ab <vectord_dot_product+0x9b>
xorpd  %xmm0,%xmm0
jmp    11d7 <vectord_dot_product+0xc7>
and    $0xfffffffffffffffc,%r15
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rcx,8),%xmm1
movsd  0x8(%rbx,%rcx,8),%xmm2
mulsd  (%r14,%rcx,8),%xmm1
mulsd  0x8(%r14,%rcx,8),%xmm2
addsd  %xmm0,%xmm1
movsd  0x10(%rbx,%rcx,8),%xmm3
mulsd  0x10(%r14,%rcx,8),%xmm3
addsd  %xmm1,%xmm2
movsd  0x18(%rbx,%rcx,8),%xmm0
mulsd  0x18(%r14,%rcx,8),%xmm0
addsd  %xmm2,%xmm3
addsd  %xmm3,%xmm0
add    $0x4,%rcx
cmp    %rcx,%r15
jne    1160 <vectord_dot_product+0x50>
test   %rax,%rax
je     11d7 <vectord_dot_product+0xc7>
lea    (%r14,%rcx,8),%rdx
lea    (%rbx,%rcx,8),%rcx
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movsd  (%rcx,%rsi,8),%xmm1
mulsd  (%rdx,%rsi,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rsi
cmp    %rsi,%rax
jne    11c0 <vectord_dot_product+0xb0>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @vectord_dot_product(double* %0, double* %1, i64 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i64
%7 = alloca double
%8 = alloca i64
store double* %0, double** %4
store double* %1, double** %5
store i64 %2, i64* %6
%9 = load double*, double** %4
%10 = call i32 @assert(double* %9)
%11 = load double*, double** %5
%12 = call i32 @assert(double* %11)
store double 0.000000e+00, double* %7
store i64 0, i64* %8
br label %13
13: ; preds = %28, %3
%14 = load i64, i64* %8
%15 = load i64, i64* %6
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = load double*, double** %4
%19 = load i64, i64* %8
%20 = getelementptr inbounds double, double* %18, i64 %19
%21 = load double, double* %20
%22 = load double*, double** %5
%23 = load i64, i64* %8
%24 = getelementptr inbounds double, double* %22, i64 %23
%25 = load double, double* %24
%26 = load double, double* %7
%27 = call double @llvm.fmuladd.f64(double %21, double %25, double %26)
store double %27, double* %7
br label %28
28: ; preds = %17
%29 = load i64, i64* %8
%30 = add i64 %29, 1
store i64 %30, i64* %8
br label %13
31: ; preds = %13
%32 = load double, double* %7
ret double %32
}

LLVM IR (-O2):
define double @vectord_dot_product(double* %0, double* %1, i64 %2) {
%4 = tail call i32 @assert(double* %0)
%5 = tail call i32 @assert(double* %1)
%6 = icmp eq i64 %2, 0
br i1 %6, label %30, label %7
7: ; preds = %3
%8 = add i64 %2, -1
%9 = and i64 %2, 3
%10 = icmp ult i64 %8, 3
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = and i64 %2, -4
br label %32
13: ; preds = %32, %7
%14 = phi double [ undef, %7 ], [ %58, %32 ]
%15 = phi i64 [ 0, %7 ], [ %59, %32 ]
%16 = phi double [ 0.000000e+00, %7 ], [ %58, %32 ]
%17 = icmp eq i64 %9, 0
br i1 %17, label %30, label %18
18: ; preds = %13, %18
%19 = phi i64 [ %27, %18 ], [ %15, %13 ]
%20 = phi double [ %26, %18 ], [ %16, %13 ]
%21 = phi i64 [ %28, %18 ], [ 0, %13 ]
%22 = getelementptr inbounds double, double* %0, i64 %19
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %1, i64 %19
%25 = load double, double* %24
%26 = tail call double @llvm.fmuladd.f64(double %23, double %25, double %20)
%27 = add nuw i64 %19, 1
%28 = add i64 %21, 1
%29 = icmp eq i64 %28, %9
br i1 %29, label %30, label %18
30: ; preds = %13, %18, %3
%31 = phi double [ 0.000000e+00, %3 ], [ %14, %13 ], [ %26, %18 ]
ret double %31
32: ; preds = %32, %11
%33 = phi i64 [ 0, %11 ], [ %59, %32 ]
%34 = phi double [ 0.000000e+00, %11 ], [ %58, %32 ]
%35 = phi i64 [ 0, %11 ], [ %60, %32 ]
%36 = getelementptr inbounds double, double* %0, i64 %33
%37 = load double, double* %36
%38 = getelementptr inbounds double, double* %1, i64 %33
%39 = load double, double* %38
%40 = tail call double @llvm.fmuladd.f64(double %37, double %39, double %34)
%41 = or i64 %33, 1
%42 = getelementptr inbounds double, double* %0, i64 %41
%43 = load double, double* %42
%44 = getelementptr inbounds double, double* %1, i64 %41
%45 = load double, double* %44
%46 = tail call double @llvm.fmuladd.f64(double %43, double %45, double %40)
%47 = or i64 %33, 2
%48 = getelementptr inbounds double, double* %0, i64 %47
%49 = load double, double* %48
%50 = getelementptr inbounds double, double* %1, i64 %47
%51 = load double, double* %50
%52 = tail call double @llvm.fmuladd.f64(double %49, double %51, double %46)
%53 = or i64 %33, 3
%54 = getelementptr inbounds double, double* %0, i64 %53
%55 = load double, double* %54
%56 = getelementptr inbounds double, double* %1, i64 %53
%57 = load double, double* %56
%58 = tail call double @llvm.fmuladd.f64(double %55, double %57, double %52)
%59 = add nuw i64 %33, 4
%60 = add i64 %35, 4
%61 = icmp eq i64 %60, %12
br i1 %61, label %13, label %32
}