void spline1DExtrapolateRight(double x1, double x2, double x3, double x4,
                              double x5, double y1, double y2, double y3,
                              double *y4, double *y5) {
  const double a = x2 - x1;
  const double b = x3 - x2;
  const double c = x4 - x3;
  if (a == 0. || b == 0. || c == 0.) {
    *y4 = y3;
    *y5 = y3;
  } else {
    const double d = x5 - x4;
    const double e = y2 - y1;
    const double f = y3 - y2;
    *y4 = c * (2 * f / b - e / a) + y3;
    *y5 = *y4 + d * ((*y4 - y3) / c + f / b - e / a);
  }
}


x86 assembly (clang, -O0):
<spline1DExtrapolateRight>:
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  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
mov    %rdi,-0x48(%rbp)
mov    %rsi,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117e <spline1DExtrapolateRight+0x7e>
jp     117e <spline1DExtrapolateRight+0x7e>
jmp    11b3 <spline1DExtrapolateRight+0xb3>
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    119b <spline1DExtrapolateRight+0x9b>
jp     119b <spline1DExtrapolateRight+0x9b>
jmp    11b3 <spline1DExtrapolateRight+0xb3>
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d2 <spline1DExtrapolateRight+0xd2>
jp     11d2 <spline1DExtrapolateRight+0xd2>
movsd  -0x40(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1284 <spline1DExtrapolateRight+0x184>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xdf4(%rip),%xmm2
mulsd  -0x80(%rbp),%xmm2
divsd  -0x60(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
divsd  -0x58(%rbp),%xmm1
subsd  %xmm1,%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x70(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm2
subsd  -0x40(%rbp),%xmm2
divsd  -0x68(%rbp),%xmm2
movsd  -0x80(%rbp),%xmm3
divsd  -0x60(%rbp),%xmm3
addsd  %xmm3,%xmm2
movsd  -0x78(%rbp),%xmm3
divsd  -0x58(%rbp),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<spline1DExtrapolateRight>:
movapd %xmm2,%xmm8
unpcklpd %xmm1,%xmm8
unpcklpd %xmm0,%xmm1
subpd  %xmm1,%xmm8
movapd %xmm8,%xmm1
unpckhpd %xmm8,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1129 <spline1DExtrapolateRight+0x29>
jnp    11a5 <spline1DExtrapolateRight+0xa5>
ucomisd %xmm0,%xmm8
jne    1132 <spline1DExtrapolateRight+0x32>
jnp    11a5 <spline1DExtrapolateRight+0xa5>
movapd %xmm3,%xmm0
subsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1146 <spline1DExtrapolateRight+0x46>
jnp    11a5 <spline1DExtrapolateRight+0xa5>
subsd  %xmm3,%xmm4
movapd %xmm7,%xmm1
unpcklpd %xmm6,%xmm1
unpcklpd %xmm5,%xmm6
subpd  %xmm6,%xmm1
movapd %xmm1,%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm8,%xmm2
divpd  %xmm8,%xmm1
movapd %xmm1,%xmm3
unpckhpd %xmm1,%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm7,%xmm2
movsd  %xmm2,(%rdi)
movapd %xmm2,%xmm5
subsd  %xmm7,%xmm5
divsd  %xmm0,%xmm5
addsd  %xmm1,%xmm5
subsd  %xmm3,%xmm5
mulsd  %xmm4,%xmm5
addsd  %xmm2,%xmm5
movsd  %xmm5,(%rsi)
ret
movsd  %xmm7,(%rdi)
movsd  %xmm7,(%rsi)
ret

LLVM IR (-O0):
define void @spline1DExtrapolateRight(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* %8, double* %9) {
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double*
%20 = alloca double*
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
store double %0, double* %11
store double %1, double* %12
store double %2, double* %13
store double %3, double* %14
store double %4, double* %15
store double %5, double* %16
store double %6, double* %17
store double %7, double* %18
store double* %8, double** %19
store double* %9, double** %20
%27 = load double, double* %12
%28 = load double, double* %11
%29 = fsub double %27, %28
store double %29, double* %21
%30 = load double, double* %13
%31 = load double, double* %12
%32 = fsub double %30, %31
store double %32, double* %22
%33 = load double, double* %14
%34 = load double, double* %13
%35 = fsub double %33, %34
store double %35, double* %23
%36 = load double, double* %21
%37 = fcmp oeq double %36, 0.000000e+00
br i1 %37, label %44, label %38
38: ; preds = %10
%39 = load double, double* %22
%40 = fcmp oeq double %39, 0.000000e+00
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load double, double* %23
%43 = fcmp oeq double %42, 0.000000e+00
br i1 %43, label %44, label %49
44: ; preds = %41, %38, %10
%45 = load double, double* %18
%46 = load double*, double** %19
store double %45, double* %46
%47 = load double, double* %18
%48 = load double*, double** %20
store double %47, double* %48
br label %90
49: ; preds = %41
%50 = load double, double* %15
%51 = load double, double* %14
%52 = fsub double %50, %51
store double %52, double* %24
%53 = load double, double* %17
%54 = load double, double* %16
%55 = fsub double %53, %54
store double %55, double* %25
%56 = load double, double* %18
%57 = load double, double* %17
%58 = fsub double %56, %57
store double %58, double* %26
%59 = load double, double* %23
%60 = load double, double* %26
%61 = fmul double 2.000000e+00, %60
%62 = load double, double* %22
%63 = fdiv double %61, %62
%64 = load double, double* %25
%65 = load double, double* %21
%66 = fdiv double %64, %65
%67 = fsub double %63, %66
%68 = load double, double* %18
%69 = call double @llvm.fmuladd.f64(double %59, double %67, double %68)
%70 = load double*, double** %19
store double %69, double* %70
%71 = load double*, double** %19
%72 = load double, double* %71
%73 = load double, double* %24
%74 = load double*, double** %19
%75 = load double, double* %74
%76 = load double, double* %18
%77 = fsub double %75, %76
%78 = load double, double* %23
%79 = fdiv double %77, %78
%80 = load double, double* %26
%81 = load double, double* %22
%82 = fdiv double %80, %81
%83 = fadd double %79, %82
%84 = load double, double* %25
%85 = load double, double* %21
%86 = fdiv double %84, %85
%87 = fsub double %83, %86
%88 = call double @llvm.fmuladd.f64(double %73, double %87, double %72)
%89 = load double*, double** %20
store double %88, double* %89
br label %90
90: ; preds = %49, %44
ret void
}

LLVM IR (-O2):
define void @spline1DExtrapolateRight(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double* nocapture writeonly %8, double* nocapture writeonly %9) {
%11 = insertelement <2 x double> poison, double %2, i64 0
%12 = insertelement <2 x double> %11, double %1, i64 1
%13 = insertelement <2 x double> poison, double %1, i64 0
%14 = insertelement <2 x double> %13, double %0, i64 1
%15 = fsub <2 x double> %12, %14
%16 = fsub double %3, %2
%17 = extractelement <2 x double> %15, i64 1
%18 = fcmp oeq double %17, 0.000000e+00
%19 = extractelement <2 x double> %15, i64 0
%20 = fcmp oeq double %19, 0.000000e+00
%21 = or i1 %18, %20
%22 = fcmp oeq double %16, 0.000000e+00
%23 = or i1 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %10
store double %7, double* %8
br label %45
25: ; preds = %10
%26 = fsub double %4, %3
%27 = insertelement <2 x double> poison, double %7, i64 0
%28 = insertelement <2 x double> %27, double %6, i64 1
%29 = insertelement <2 x double> poison, double %6, i64 0
%30 = insertelement <2 x double> %29, double %5, i64 1
%31 = fsub <2 x double> %28, %30
%32 = extractelement <2 x double> %31, i64 0
%33 = fmul double %32, 2.000000e+00
%34 = fdiv double %33, %19
%35 = fdiv <2 x double> %31, %15
%36 = extractelement <2 x double> %35, i64 1
%37 = fsub double %34, %36
%38 = tail call double @llvm.fmuladd.f64(double %16, double %37, double %7)
store double %38, double* %8
%39 = fsub double %38, %7
%40 = fdiv double %39, %16
%41 = extractelement <2 x double> %35, i64 0
%42 = fadd double %41, %40
%43 = fsub double %42, %36
%44 = tail call double @llvm.fmuladd.f64(double %26, double %43, double %38)
br label %45
45: ; preds = %25, %24
%46 = phi double [ %44, %25 ], [ %7, %24 ]
store double %46, double* %9
ret void
}