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


x86 assembly (clang, -O0):
<quad_2>:
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),%xmm1
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm3
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm4
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm2
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm4
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm6
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm5
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm5
mulsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xe3e(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<quad_2>:
movsd  (%rdx),%xmm1
movsd  0x8(%rdx),%xmm2
movsd  0x8(%rdi),%xmm3
mulsd  %xmm2,%xmm3
movsd  (%rdi),%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
addsd  %xmm4,%xmm0
movsd  0x8(%rsi),%xmm3
movapd %xmm2,%xmm4
mulsd  %xmm3,%xmm4
movsd  (%rsi),%xmm5
mulsd  %xmm1,%xmm5
addsd  %xmm4,%xmm5
movsd  0x10(%rsi),%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm1,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm5
addsd  %xmm3,%xmm5
mulsd  0xea0(%rip),%xmm5
addsd  %xmm5,%xmm0
ret

LLVM IR (-O0):
define double @quad_2(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 = fadd double %9, %23
%25 = load double*, double** %8
%26 = getelementptr inbounds double, double* %25, i64 0
%27 = load double, double* %26
%28 = load double*, double** %7
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = load double*, double** %8
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = load double*, double** %7
%35 = getelementptr inbounds double, double* %34, i64 1
%36 = load double, double* %35
%37 = load double*, double** %8
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = fmul double %36, %39
%41 = call double @llvm.fmuladd.f64(double %30, double %33, double %40)
%42 = load double*, double** %8
%43 = getelementptr inbounds double, double* %42, i64 1
%44 = load double, double* %43
%45 = load double*, double** %7
%46 = getelementptr inbounds double, double* %45, i64 1
%47 = load double, double* %46
%48 = load double*, double** %8
%49 = getelementptr inbounds double, double* %48, i64 0
%50 = load double, double* %49
%51 = load double*, double** %7
%52 = getelementptr inbounds double, double* %51, i64 2
%53 = load double, double* %52
%54 = load double*, double** %8
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = fmul double %53, %56
%58 = call double @llvm.fmuladd.f64(double %47, double %50, double %57)
%59 = fmul double %44, %58
%60 = call double @llvm.fmuladd.f64(double %27, double %41, double %59)
%61 = fdiv double %60, 2.000000e+00
%62 = fadd double %24, %61
ret double %62
}

LLVM IR (-O2):
define double @quad_2(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 = fmul double %8, %10
%12 = tail call double @llvm.fmuladd.f64(double %5, double %6, double %11)
%13 = fadd double %12, %0
%14 = load double, double* %2
%15 = getelementptr inbounds double, double* %2, i64 1
%16 = load double, double* %15
%17 = fmul double %10, %16
%18 = tail call double @llvm.fmuladd.f64(double %14, double %6, double %17)
%19 = getelementptr inbounds double, double* %2, i64 2
%20 = load double, double* %19
%21 = fmul double %10, %20
%22 = tail call double @llvm.fmuladd.f64(double %16, double %6, double %21)
%23 = fmul double %10, %22
%24 = tail call double @llvm.fmuladd.f64(double %6, double %18, double %23)
%25 = fmul double %24, 5.000000e-01
%26 = fadd double %13, %25
ret double %26
}