double beales(double *xs) {
  double x = xs[0];
  double y = xs[1];
  return (((1.5 - x + (x * y)) * (1.5 - x + (x * y))) +
          ((2.25 - x + (x * y * y)) * (2.25 - x + (x * y * y))) +
          ((2.625 - x + (x * y * y * y)) * (2.625 - x + (x * y * y * y))));
}


x86 assembly (clang, -O0):
<beales>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xee5(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xec6(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm0,%xmm2
movsd  0xe9f(%rip),%xmm3
subsd  -0x10(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm4
mulsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
movsd  0xe7b(%rip),%xmm4
subsd  -0x10(%rbp),%xmm4
movsd  -0x10(%rbp),%xmm3
mulsd  -0x18(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm5
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe43(%rip),%xmm2
subsd  -0x10(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  0xe1a(%rip),%xmm3
subsd  -0x10(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<beales>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
movsd  0xeef(%rip),%xmm2
subsd  %xmm0,%xmm2
movsd  0xeeb(%rip),%xmm3
subsd  %xmm0,%xmm3
movsd  0xee7(%rip),%xmm4
subsd  %xmm0,%xmm4
mulsd  %xmm1,%xmm0
addsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm0
addsd  %xmm0,%xmm3
mulsd  %xmm3,%xmm3
mulsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm1,%xmm0
addsd  %xmm4,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
ret

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

LLVM IR (-O2):
define double @beales(double* nocapture %0) {
%2 = load double, double* %0
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = load double, double* %3
%5 = fsub double 1.500000e+00, %2
%6 = tail call double @llvm.fmuladd.f64(double %2, double %4, double %5)
%7 = fsub double 2.250000e+00, %2
%8 = fmul double %2, %4
%9 = tail call double @llvm.fmuladd.f64(double %8, double %4, double %7)
%10 = fmul double %9, %9
%11 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %10)
%12 = fsub double 2.625000e+00, %2
%13 = fmul double %4, %8
%14 = tail call double @llvm.fmuladd.f64(double %13, double %4, double %12)
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %11)
ret double %15
}