double bez_dist(double t, double *cx, double *cy) {
  double x = ((cx[3] * t + cx[2]) * t + cx[1]) * t;
  double y = ((cy[3] * t + cy[2]) * t + cy[1]) * t;
  return (x * x + y * y);
}


x86 assembly (clang, -O0):
<bez_dist>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  -0x8(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  -0x8(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<bez_dist>:
movsd  0x18(%rdi),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x10(%rdi),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rdi),%xmm1
movsd  0x18(%rsi),%xmm2
mulsd  %xmm0,%xmm2
addsd  0x10(%rsi),%xmm2
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm2
addsd  0x8(%rsi),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @bez_dist(double %0, double* %1, double* %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double* %1, double** %5
store double* %2, double** %6
%9 = load double*, double** %5
%10 = getelementptr inbounds double, double* %9, i64 3
%11 = load double, double* %10
%12 = load double, double* %4
%13 = load double*, double** %5
%14 = getelementptr inbounds double, double* %13, i64 2
%15 = load double, double* %14
%16 = call double @llvm.fmuladd.f64(double %11, double %12, double %15)
%17 = load double, double* %4
%18 = load double*, double** %5
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = call double @llvm.fmuladd.f64(double %16, double %17, double %20)
%22 = load double, double* %4
%23 = fmul double %21, %22
store double %23, double* %7
%24 = load double*, double** %6
%25 = getelementptr inbounds double, double* %24, i64 3
%26 = load double, double* %25
%27 = load double, double* %4
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 2
%30 = load double, double* %29
%31 = call double @llvm.fmuladd.f64(double %26, double %27, double %30)
%32 = load double, double* %4
%33 = load double*, double** %6
%34 = getelementptr inbounds double, double* %33, i64 1
%35 = load double, double* %34
%36 = call double @llvm.fmuladd.f64(double %31, double %32, double %35)
%37 = load double, double* %4
%38 = fmul double %36, %37
store double %38, double* %8
%39 = load double, double* %7
%40 = load double, double* %7
%41 = load double, double* %8
%42 = load double, double* %8
%43 = fmul double %41, %42
%44 = call double @llvm.fmuladd.f64(double %39, double %40, double %43)
ret double %44
}

LLVM IR (-O2):
define double @bez_dist(double %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds double, double* %1, i64 3
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %1, i64 2
%7 = load double, double* %6
%8 = tail call double @llvm.fmuladd.f64(double %5, double %0, double %7)
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = tail call double @llvm.fmuladd.f64(double %8, double %0, double %10)
%12 = fmul double %11, %0
%13 = getelementptr inbounds double, double* %2, i64 3
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %2, i64 2
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %14, double %0, double %16)
%18 = getelementptr inbounds double, double* %2, i64 1
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %17, double %0, double %19)
%21 = fmul double %20, %0
%22 = fmul double %21, %21
%23 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %22)
ret double %23
}