double beale(double *x, int N, void *params) {
  double f;
  f = (1.5 - x[0] * (1 - x[1])) * (1.5 - x[0] * (1 - x[1])) +
      (2.25 - x[0] * (1 - x[1] * x[1])) * (2.25 - x[0] * (1 - x[1] * x[1])) +
      (2.625 - x[0] * (1 - x[1] * x[1] * x[1])) *
          (2.625 - x[0] * (1 - x[1] * x[1] * x[1]));
  return f;
}


x86 assembly (clang, -O0):
<beale>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0xee5(%rip),%xmm0
subsd  0x8(%rax),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xecd(%rip),%xmm0
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0xea5(%rip),%xmm0
subsd  0x8(%rax),%xmm0
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm0,%xmm2
movsd  0xe8d(%rip),%xmm0
addsd  %xmm0,%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm4
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm3
movsd  0xe3c(%rip),%xmm4
addsd  %xmm4,%xmm3
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm3,%xmm0
movsd  0xe1d(%rip),%xmm3
addsd  %xmm3,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm3
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm4
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm5
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm4
movsd  0xdd4(%rip),%xmm5
addsd  %xmm5,%xmm4
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm3
movsd  0xdb5(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xd57(%rip),%xmm3
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
movsd  0xd28(%rip),%xmm2
addsd  %xmm2,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm3
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm4
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm3
movsd  0xce6(%rip),%xmm4
addsd  %xmm4,%xmm3
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xcb7(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<beale>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
movsd  0xeef(%rip),%xmm2
movapd %xmm2,%xmm3
subsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm3
movsd  0xee3(%rip),%xmm4
subsd  %xmm3,%xmm4
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
movapd %xmm2,%xmm5
subsd  %xmm3,%xmm5
mulsd  %xmm0,%xmm5
movsd  0xecb(%rip),%xmm6
subsd  %xmm5,%xmm6
mulsd  %xmm6,%xmm6
mulsd  %xmm4,%xmm4
addsd  %xmm6,%xmm4
mulsd  %xmm1,%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
movsd  0xeaf(%rip),%xmm0
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm4,%xmm0
ret

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

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