double s6dotprod(double v1[6], double v2[6]) {
  return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2] + v1[3] * v2[3] +
         v1[4] * v2[4] + v1[5] * v2[5];
}


x86 assembly (clang, -O0):
<s6dotprod>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<s6dotprod>:
movsd  0x8(%rdi),%xmm0
mulsd  0x8(%rsi),%xmm0
movsd  (%rdi),%xmm1
mulsd  (%rsi),%xmm1
addsd  %xmm0,%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),%xmm2
mulsd  0x20(%rsi),%xmm2
addsd  %xmm1,%xmm2
movsd  0x28(%rdi),%xmm0
mulsd  0x28(%rsi),%xmm0
addsd  %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @s6dotprod(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
store double* %0, double** %3
store double* %1, double** %4
%5 = load double*, double** %3
%6 = getelementptr inbounds double, double* %5, i64 0
%7 = load double, double* %6
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = load double*, double** %3
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double, double* %12
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = fmul double %13, %16
%18 = call double @llvm.fmuladd.f64(double %7, double %10, double %17)
%19 = load double*, double** %3
%20 = getelementptr inbounds double, double* %19, i64 2
%21 = load double, double* %20
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = call double @llvm.fmuladd.f64(double %21, double %24, double %18)
%26 = load double*, double** %3
%27 = getelementptr inbounds double, double* %26, i64 3
%28 = load double, double* %27
%29 = load double*, double** %4
%30 = getelementptr inbounds double, double* %29, i64 3
%31 = load double, double* %30
%32 = call double @llvm.fmuladd.f64(double %28, double %31, double %25)
%33 = load double*, double** %3
%34 = getelementptr inbounds double, double* %33, i64 4
%35 = load double, double* %34
%36 = load double*, double** %4
%37 = getelementptr inbounds double, double* %36, i64 4
%38 = load double, double* %37
%39 = call double @llvm.fmuladd.f64(double %35, double %38, double %32)
%40 = load double*, double** %3
%41 = getelementptr inbounds double, double* %40, i64 5
%42 = load double, double* %41
%43 = load double*, double** %4
%44 = getelementptr inbounds double, double* %43, i64 5
%45 = load double, double* %44
%46 = call double @llvm.fmuladd.f64(double %42, double %45, double %39)
ret double %46
}

LLVM IR (-O2):
define double @s6dotprod(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = load double, double* %1
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = fmul double %6, %8
%10 = tail call double @llvm.fmuladd.f64(double %3, double %4, double %9)
%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)
ret double %30
}