double math_diff3(double x0, double x1, double x2, double y0, double y1,
                  double y2) {
  const double h1 = x1 - x0;
  const double h2 = x2 - x0;
  const double delta = h1 * h2 * (h2 - h1);
  const double c1 = h2 * h2 / delta;
  const double c2 = -h1 * h1 / delta;
  const double c0 = -(c1 + c2);
  return c0 * y0 + c1 * y1 + c2 * y2;
}


x86 assembly (clang, -O0):
<math_diff3>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x38(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<math_diff3>:
unpcklpd %xmm1,%xmm2
unpcklpd %xmm0,%xmm0
subpd  %xmm0,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm2,%xmm6
subsd  %xmm0,%xmm6
xorpd  0xed4(%rip),%xmm0
mulsd  %xmm1,%xmm6
movapd %xmm2,%xmm1
unpcklpd %xmm0,%xmm1
mulpd  %xmm2,%xmm1
unpcklpd %xmm6,%xmm6
divpd  %xmm6,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
movapd %xmm1,%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm5,%xmm0
addsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @math_diff3(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%19 = load double, double* %8
%20 = load double, double* %7
%21 = fsub double %19, %20
store double %21, double* %13
%22 = load double, double* %9
%23 = load double, double* %7
%24 = fsub double %22, %23
store double %24, double* %14
%25 = load double, double* %13
%26 = load double, double* %14
%27 = fmul double %25, %26
%28 = load double, double* %14
%29 = load double, double* %13
%30 = fsub double %28, %29
%31 = fmul double %27, %30
store double %31, double* %15
%32 = load double, double* %14
%33 = load double, double* %14
%34 = fmul double %32, %33
%35 = load double, double* %15
%36 = fdiv double %34, %35
store double %36, double* %16
%37 = load double, double* %13
%38 = fneg double %37
%39 = load double, double* %13
%40 = fmul double %38, %39
%41 = load double, double* %15
%42 = fdiv double %40, %41
store double %42, double* %17
%43 = load double, double* %16
%44 = load double, double* %17
%45 = fadd double %43, %44
%46 = fneg double %45
store double %46, double* %18
%47 = load double, double* %18
%48 = load double, double* %10
%49 = load double, double* %16
%50 = load double, double* %11
%51 = fmul double %49, %50
%52 = call double @llvm.fmuladd.f64(double %47, double %48, double %51)
%53 = load double, double* %17
%54 = load double, double* %12
%55 = call double @llvm.fmuladd.f64(double %53, double %54, double %52)
ret double %55
}

LLVM IR (-O2):
define double @math_diff3(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = insertelement <2 x double> poison, double %2, i64 0
%8 = insertelement <2 x double> %7, double %1, i64 1
%9 = insertelement <2 x double> poison, double %0, i64 0
%10 = shufflevector <2 x double> %9, <2 x double> poison, <2 x i32> zeroinitializer
%11 = fsub <2 x double> %8, %10
%12 = extractelement <2 x double> %11, i64 0
%13 = extractelement <2 x double> %11, i64 1
%14 = fmul double %13, %12
%15 = fsub double %12, %13
%16 = fmul double %14, %15
%17 = fneg double %13
%18 = insertelement <2 x double> %11, double %17, i64 1
%19 = fmul <2 x double> %11, %18
%20 = insertelement <2 x double> poison, double %16, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = fdiv <2 x double> %19, %21
%23 = extractelement <2 x double> %22, i64 0
%24 = extractelement <2 x double> %22, i64 1
%25 = fadd double %23, %24
%26 = fneg double %25
%27 = fmul double %23, %4
%28 = tail call double @llvm.fmuladd.f64(double %26, double %3, double %27)
%29 = tail call double @llvm.fmuladd.f64(double %24, double %5, double %28)
ret double %29
}