double cuberp(double x, double *f) {
  double M[4][4] = {{-1.0, 3.0, -2.0, 0.0},
                    {3.0, -6.0, -3.0, 1.0},
                    {-3.0, 3.0, 6.0, 0.0},
                    {1.0, 0.0, -1.0, 0.0}};
  double coeff[4] = {0.0, 0.0, 0.0, 0.0};
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      coeff[i] += f[i] * M[j][i];
    }
  }
  return coeff[3] + x * (coeff[2] + x * (coeff[1] + x * coeff[0]));
}


x86 assembly (clang, -O0):
<cuberp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xebe(%rip),%rsi
mov    $0x80,%edx
call   1040 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x4,-0xb4(%rbp)
jge    120c <cuberp+0xec>
movl   $0x0,-0xb8(%rbp)
cmpl   $0x4,-0xb8(%rbp)
jge    11f3 <cuberp+0xd3>
mov    -0x10(%rbp),%rax
movslq -0xb4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xb8(%rbp),%rcx
lea    -0x90(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0xb4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movslq -0xb4(%rbp),%rax
movsd  -0xb0(%rbp,%rax,8),%xmm1
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp,%rax,8)
ff ff
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    1180 <cuberp+0x60>
jmp    11f8 <cuberp+0xd8>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1169 <cuberp+0x49>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x8(%rbp),%xmm0
movsd  -0xa0(%rbp),%xmm3
ff
movsd  -0x8(%rbp),%xmm2
movsd  -0xa8(%rbp),%xmm5
ff
movsd  -0x8(%rbp),%xmm4
movsd  -0xb0(%rbp),%xmm6
ff
mulsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cuberp>:
movsd  (%rdi),%xmm5
movsd  0x8(%rdi),%xmm2
xorpd  %xmm1,%xmm1
xorpd  %xmm3,%xmm3
subsd  %xmm5,%xmm3
movsd  0xee3(%rip),%xmm6
movapd %xmm5,%xmm7
mulsd  %xmm6,%xmm7
addsd  %xmm3,%xmm7
movsd  0xed7(%rip),%xmm4
movapd %xmm5,%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm7,%xmm3
addsd  %xmm5,%xmm3
mulsd  %xmm2,%xmm6
movapd %xmm6,%xmm5
addsd  %xmm1,%xmm5
movsd  0xebb(%rip),%xmm7
mulsd  %xmm2,%xmm7
addsd  %xmm5,%xmm7
addsd  %xmm6,%xmm7
mulsd  %xmm1,%xmm2
addsd  %xmm7,%xmm2
movsd  0x10(%rdi),%xmm5
movapd %xmm5,%xmm6
addsd  %xmm5,%xmm6
xorpd  %xmm7,%xmm7
subsd  %xmm6,%xmm7
mulsd  %xmm5,%xmm4
addsd  %xmm7,%xmm4
movsd  0xe8a(%rip),%xmm6
mulsd  %xmm5,%xmm6
addsd  %xmm4,%xmm6
subsd  %xmm5,%xmm6
movsd  0x18(%rdi),%xmm4
movapd %xmm4,%xmm5
mulsd  %xmm1,%xmm5
addsd  %xmm5,%xmm1
addsd  %xmm4,%xmm1
addsd  %xmm5,%xmm1
addsd  %xmm5,%xmm1
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm6,%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
@__const.cuberp.M = [4 x [4 x double]] [[4 x double] [double -1.000000e+00, double 3.000000e+00, double -2.000000e+00, double 0.000000e+00], [4 x double] [double 3.000000e+00, double -6.000000e+00, double -3.000000e+00, double 1.000000e+00], [4 x double] [double -3.000000e+00, double 3.000000e+00, double 6.000000e+00, double 0.000000e+00], [4 x double] [double 1.000000e+00, double 0.000000e+00, double -1.000000e+00, double 0.000000e+00]]
define double @cuberp(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca [4 x [4 x double]]
%6 = alloca [4 x double]
%7 = alloca i32
%8 = alloca i32
store double %0, double* %3
store double* %1, double** %4
%9 = bitcast [4 x [4 x double]]* %5 to i8*
%10 = bitcast [4 x double]* %6 to i8*
store i32 0, i32* %7
br label %11
11: ; preds = %40, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %43
14: ; preds = %11
store i32 0, i32* %8
br label %15
15: ; preds = %36, %14
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %39
18: ; preds = %15
%19 = load double*, double** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %5, i64 0, i64 %25
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x double], [4 x double]* %26, i64 0, i64 %28
%30 = load double, double* %29
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 %32
%34 = load double, double* %33
%35 = call double @llvm.fmuladd.f64(double %23, double %30, double %34)
store double %35, double* %33
br label %36
36: ; preds = %18
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %15
39: ; preds = %15
br label %40
40: ; preds = %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %11
43: ; preds = %11
%44 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 3
%45 = load double, double* %44
%46 = load double, double* %3
%47 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 2
%48 = load double, double* %47
%49 = load double, double* %3
%50 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 1
%51 = load double, double* %50
%52 = load double, double* %3
%53 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 0
%54 = load double, double* %53
%55 = call double @llvm.fmuladd.f64(double %52, double %54, double %51)
%56 = call double @llvm.fmuladd.f64(double %49, double %55, double %48)
%57 = call double @llvm.fmuladd.f64(double %46, double %56, double %45)
ret double %57
}

LLVM IR (-O2):
define double @cuberp(double %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = tail call double @llvm.fmuladd.f64(double %3, double -1.000000e+00, double 0.000000e+00)
%5 = tail call double @llvm.fmuladd.f64(double %3, double 3.000000e+00, double %4)
%6 = tail call double @llvm.fmuladd.f64(double %3, double -3.000000e+00, double %5)
%7 = fadd double %3, %6
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = tail call double @llvm.fmuladd.f64(double %9, double 3.000000e+00, double 0.000000e+00)
%11 = tail call double @llvm.fmuladd.f64(double %9, double -6.000000e+00, double %10)
%12 = tail call double @llvm.fmuladd.f64(double %9, double 3.000000e+00, double %11)
%13 = tail call double @llvm.fmuladd.f64(double %9, double 0.000000e+00, double %12)
%14 = getelementptr inbounds double, double* %1, i64 2
%15 = load double, double* %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double -2.000000e+00, double 0.000000e+00)
%17 = tail call double @llvm.fmuladd.f64(double %15, double -3.000000e+00, double %16)
%18 = tail call double @llvm.fmuladd.f64(double %15, double 6.000000e+00, double %17)
%19 = tail call double @llvm.fmuladd.f64(double %15, double -1.000000e+00, double %18)
%20 = getelementptr inbounds double, double* %1, i64 3
%21 = load double, double* %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double 0.000000e+00, double 0.000000e+00)
%23 = fadd double %21, %22
%24 = tail call double @llvm.fmuladd.f64(double %21, double 0.000000e+00, double %23)
%25 = tail call double @llvm.fmuladd.f64(double %21, double 0.000000e+00, double %24)
%26 = tail call double @llvm.fmuladd.f64(double %0, double %7, double %13)
%27 = tail call double @llvm.fmuladd.f64(double %0, double %26, double %19)
%28 = tail call double @llvm.fmuladd.f64(double %0, double %27, double %25)
ret double %28
}