double quad_3(const double x0, const double g[3], const double H[6],
              const double r[3]) {
  return x0 + (g[0] * r[0] + g[1] * r[1] + g[2] * r[2]) +
         (r[0] * (H[0] * r[0] + H[1] * r[1] + H[2] * r[2]) +
          r[1] * (H[1] * r[0] + H[3] * r[1] + H[4] * r[2]) +
          r[2] * (H[2] * r[0] + H[4] * r[1] + H[5] * r[2])) /
             2;
}


x86 assembly (clang, -O0):
<quad_3>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm4
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm3
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm3
mulsd  %xmm4,%xmm1
addsd  %xmm3,%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm3
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm4
mulsd  %xmm4,%xmm3
addsd  %xmm1,%xmm3
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm5
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm6
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm4
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm4
mulsd  %xmm6,%xmm5
addsd  %xmm4,%xmm5
mov    -0x18(%rbp),%rax
movsd  0x20(%rax),%xmm4
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm6
mulsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm4
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm5
mov    -0x18(%rbp),%rax
movsd  0x20(%rax),%xmm3
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm3
mulsd  %xmm5,%xmm4
addsd  %xmm3,%xmm4
mov    -0x18(%rbp),%rax
movsd  0x28(%rax),%xmm3
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm5
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xd9a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<quad_3>:
movsd  (%rdx),%xmm2
movsd  0x8(%rdx),%xmm4
movsd  0x10(%rdx),%xmm1
movsd  0x8(%rsi),%xmm5
movsd  0x10(%rsi),%xmm9
movapd %xmm4,%xmm6
mulsd  %xmm5,%xmm6
movsd  (%rsi),%xmm7
mulsd  %xmm2,%xmm7
addsd  %xmm6,%xmm7
movapd %xmm9,%xmm6
mulsd  %xmm1,%xmm6
addsd  %xmm7,%xmm6
movsd  0x18(%rsi),%xmm7
mulsd  %xmm4,%xmm7
mulsd  %xmm2,%xmm5
addsd  %xmm7,%xmm5
movsd  0x20(%rsi),%xmm8
movsd  0x8(%rdi),%xmm10
unpcklpd %xmm4,%xmm10
movapd %xmm4,%xmm3
mulsd  %xmm8,%xmm4
mulsd  %xmm1,%xmm8
addsd  %xmm5,%xmm8
movsd  (%rdi),%xmm5
movsd  0x10(%rdi),%xmm7
unpcklpd %xmm8,%xmm3
mulpd  %xmm10,%xmm3
unpcklpd %xmm2,%xmm5
mulsd  %xmm2,%xmm9
unpcklpd %xmm6,%xmm2
mulpd  %xmm5,%xmm2
addpd  %xmm3,%xmm2
addsd  %xmm9,%xmm4
movsd  0x28(%rsi),%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm4,%xmm3
unpcklpd %xmm1,%xmm7
unpcklpd %xmm3,%xmm1
mulpd  %xmm7,%xmm1
addpd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
mulsd  0xe37(%rip),%xmm1
addsd  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
define double @quad_3(double %0, double* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = load double, double* %1
%6 = load double, double* %3
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %3, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %1, i64 2
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %3, i64 2
%14 = load double, double* %13
%15 = load double, double* %2
%16 = getelementptr inbounds double, double* %2, i64 1
%17 = load double, double* %16
%18 = fmul double %10, %17
%19 = tail call double @llvm.fmuladd.f64(double %15, double %6, double %18)
%20 = getelementptr inbounds double, double* %2, i64 2
%21 = load double, double* %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double %14, double %19)
%23 = getelementptr inbounds double, double* %2, i64 3
%24 = load double, double* %23
%25 = fmul double %10, %24
%26 = tail call double @llvm.fmuladd.f64(double %17, double %6, double %25)
%27 = getelementptr inbounds double, double* %2, i64 4
%28 = load double, double* %27
%29 = tail call double @llvm.fmuladd.f64(double %28, double %14, double %26)
%30 = insertelement <2 x double> poison, double %8, i64 0
%31 = insertelement <2 x double> %30, double %10, i64 1
%32 = insertelement <2 x double> poison, double %10, i64 0
%33 = insertelement <2 x double> %32, double %29, i64 1
%34 = fmul <2 x double> %31, %33
%35 = insertelement <2 x double> poison, double %5, i64 0
%36 = insertelement <2 x double> %35, double %6, i64 1
%37 = insertelement <2 x double> poison, double %6, i64 0
%38 = insertelement <2 x double> %37, double %22, i64 1
%39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %38, <2 x double> %34)
%40 = fmul double %10, %28
%41 = tail call double @llvm.fmuladd.f64(double %21, double %6, double %40)
%42 = getelementptr inbounds double, double* %2, i64 5
%43 = load double, double* %42
%44 = tail call double @llvm.fmuladd.f64(double %43, double %14, double %41)
%45 = insertelement <2 x double> poison, double %12, i64 0
%46 = insertelement <2 x double> %45, double %14, i64 1
%47 = insertelement <2 x double> poison, double %14, i64 0
%48 = insertelement <2 x double> %47, double %44, i64 1
%49 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %46, <2 x double> %48, <2 x double> %39)
%50 = extractelement <2 x double> %49, i64 0
%51 = fadd double %50, %0
%52 = extractelement <2 x double> %49, i64 1
%53 = fmul double %52, 5.000000e-01
%54 = fadd double %51, %53
ret double %54
}