double dot_prod(double *x, double *y) {
  double sum = 0;
  for (int i = 0; i < (128 * 11 / 64 + 3); ++i)
    sum += x[i] * y[i];
  return sum;
}


x86 assembly (clang, -O0):
<dot_prod>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x19,-0x1c(%rbp)
jge    115f <dot_prod+0x5f>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    111b <dot_prod+0x1b>
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<dot_prod>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
mulsd  (%rsi),%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
mulsd  0x8(%rsi),%xmm1
addsd  %xmm2,%xmm1
movsd  0x10(%rdi),%xmm0
mulsd  0x10(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x18(%rdi),%xmm1
mulsd  0x18(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0x20(%rdi),%xmm0
mulsd  0x20(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x28(%rdi),%xmm1
mulsd  0x28(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0x30(%rdi),%xmm0
mulsd  0x30(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x38(%rdi),%xmm1
mulsd  0x38(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0x40(%rdi),%xmm0
mulsd  0x40(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x48(%rdi),%xmm1
mulsd  0x48(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0x50(%rdi),%xmm0
mulsd  0x50(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x58(%rdi),%xmm1
mulsd  0x58(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0x60(%rdi),%xmm0
mulsd  0x60(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x68(%rdi),%xmm1
mulsd  0x68(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0x70(%rdi),%xmm0
mulsd  0x70(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x78(%rdi),%xmm1
mulsd  0x78(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0x80(%rdi),%xmm0
mulsd  0x80(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x88(%rdi),%xmm1
mulsd  0x88(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0x90(%rdi),%xmm0
mulsd  0x90(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x98(%rdi),%xmm1
mulsd  0x98(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0xa0(%rdi),%xmm0
mulsd  0xa0(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0xa8(%rdi),%xmm1
mulsd  0xa8(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0xb0(%rdi),%xmm0
mulsd  0xb0(%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0xb8(%rdi),%xmm1
mulsd  0xb8(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  0xc0(%rdi),%xmm0
mulsd  0xc0(%rsi),%xmm0
addsd  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
define double @dot_prod(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = load double, double* %1
%5 = tail call double @llvm.fmuladd.f64(double %3, double %4, double 0.000000e+00)
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = tail call double @llvm.fmuladd.f64(double %7, double %9, double %5)
%11 = getelementptr inbounds double, double* %0, i64 2
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %1, i64 2
%14 = load double, double* %13
%15 = tail call double @llvm.fmuladd.f64(double %12, double %14, double %10)
%16 = getelementptr inbounds double, double* %0, i64 3
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 3
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %17, double %19, double %15)
%21 = getelementptr inbounds double, double* %0, i64 4
%22 = load double, double* %21
%23 = getelementptr inbounds double, double* %1, i64 4
%24 = load double, double* %23
%25 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %20)
%26 = getelementptr inbounds double, double* %0, i64 5
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %1, i64 5
%29 = load double, double* %28
%30 = tail call double @llvm.fmuladd.f64(double %27, double %29, double %25)
%31 = getelementptr inbounds double, double* %0, i64 6
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %1, i64 6
%34 = load double, double* %33
%35 = tail call double @llvm.fmuladd.f64(double %32, double %34, double %30)
%36 = getelementptr inbounds double, double* %0, i64 7
%37 = load double, double* %36
%38 = getelementptr inbounds double, double* %1, i64 7
%39 = load double, double* %38
%40 = tail call double @llvm.fmuladd.f64(double %37, double %39, double %35)
%41 = getelementptr inbounds double, double* %0, i64 8
%42 = load double, double* %41
%43 = getelementptr inbounds double, double* %1, i64 8
%44 = load double, double* %43
%45 = tail call double @llvm.fmuladd.f64(double %42, double %44, double %40)
%46 = getelementptr inbounds double, double* %0, i64 9
%47 = load double, double* %46
%48 = getelementptr inbounds double, double* %1, i64 9
%49 = load double, double* %48
%50 = tail call double @llvm.fmuladd.f64(double %47, double %49, double %45)
%51 = getelementptr inbounds double, double* %0, i64 10
%52 = load double, double* %51
%53 = getelementptr inbounds double, double* %1, i64 10
%54 = load double, double* %53
%55 = tail call double @llvm.fmuladd.f64(double %52, double %54, double %50)
%56 = getelementptr inbounds double, double* %0, i64 11
%57 = load double, double* %56
%58 = getelementptr inbounds double, double* %1, i64 11
%59 = load double, double* %58
%60 = tail call double @llvm.fmuladd.f64(double %57, double %59, double %55)
%61 = getelementptr inbounds double, double* %0, i64 12
%62 = load double, double* %61
%63 = getelementptr inbounds double, double* %1, i64 12
%64 = load double, double* %63
%65 = tail call double @llvm.fmuladd.f64(double %62, double %64, double %60)
%66 = getelementptr inbounds double, double* %0, i64 13
%67 = load double, double* %66
%68 = getelementptr inbounds double, double* %1, i64 13
%69 = load double, double* %68
%70 = tail call double @llvm.fmuladd.f64(double %67, double %69, double %65)
%71 = getelementptr inbounds double, double* %0, i64 14
%72 = load double, double* %71
%73 = getelementptr inbounds double, double* %1, i64 14
%74 = load double, double* %73
%75 = tail call double @llvm.fmuladd.f64(double %72, double %74, double %70)
%76 = getelementptr inbounds double, double* %0, i64 15
%77 = load double, double* %76
%78 = getelementptr inbounds double, double* %1, i64 15
%79 = load double, double* %78
%80 = tail call double @llvm.fmuladd.f64(double %77, double %79, double %75)
%81 = getelementptr inbounds double, double* %0, i64 16
%82 = load double, double* %81
%83 = getelementptr inbounds double, double* %1, i64 16
%84 = load double, double* %83
%85 = tail call double @llvm.fmuladd.f64(double %82, double %84, double %80)
%86 = getelementptr inbounds double, double* %0, i64 17
%87 = load double, double* %86
%88 = getelementptr inbounds double, double* %1, i64 17
%89 = load double, double* %88
%90 = tail call double @llvm.fmuladd.f64(double %87, double %89, double %85)
%91 = getelementptr inbounds double, double* %0, i64 18
%92 = load double, double* %91
%93 = getelementptr inbounds double, double* %1, i64 18
%94 = load double, double* %93
%95 = tail call double @llvm.fmuladd.f64(double %92, double %94, double %90)
%96 = getelementptr inbounds double, double* %0, i64 19
%97 = load double, double* %96
%98 = getelementptr inbounds double, double* %1, i64 19
%99 = load double, double* %98
%100 = tail call double @llvm.fmuladd.f64(double %97, double %99, double %95)
%101 = getelementptr inbounds double, double* %0, i64 20
%102 = load double, double* %101
%103 = getelementptr inbounds double, double* %1, i64 20
%104 = load double, double* %103
%105 = tail call double @llvm.fmuladd.f64(double %102, double %104, double %100)
%106 = getelementptr inbounds double, double* %0, i64 21
%107 = load double, double* %106
%108 = getelementptr inbounds double, double* %1, i64 21
%109 = load double, double* %108
%110 = tail call double @llvm.fmuladd.f64(double %107, double %109, double %105)
%111 = getelementptr inbounds double, double* %0, i64 22
%112 = load double, double* %111
%113 = getelementptr inbounds double, double* %1, i64 22
%114 = load double, double* %113
%115 = tail call double @llvm.fmuladd.f64(double %112, double %114, double %110)
%116 = getelementptr inbounds double, double* %0, i64 23
%117 = load double, double* %116
%118 = getelementptr inbounds double, double* %1, i64 23
%119 = load double, double* %118
%120 = tail call double @llvm.fmuladd.f64(double %117, double %119, double %115)
%121 = getelementptr inbounds double, double* %0, i64 24
%122 = load double, double* %121
%123 = getelementptr inbounds double, double* %1, i64 24
%124 = load double, double* %123
%125 = tail call double @llvm.fmuladd.f64(double %122, double %124, double %120)
ret double %125
}