double beale(double *x, int N) {
  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    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0xee9(%rip),%xmm0
subsd  0x8(%rax),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xed1(%rip),%xmm0
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0xea9(%rip),%xmm0
subsd  0x8(%rax),%xmm0
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm0,%xmm2
movsd  0xe91(%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  0xe40(%rip),%xmm4
addsd  %xmm4,%xmm3
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm3,%xmm0
movsd  0xe21(%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  0xdd8(%rip),%xmm5
addsd  %xmm5,%xmm4
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm3
movsd  0xdb9(%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  0xd5b(%rip),%xmm3
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
movsd  0xd2c(%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  0xcea(%rip),%xmm4
addsd  %xmm4,%xmm3
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
movsd  0xcbb(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%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) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
%6 = load double*, double** %3
%7 = getelementptr inbounds double, double* %6, i64 0
%8 = load double, double* %7
%9 = load double*, double** %3
%10 = getelementptr inbounds double, double* %9, i64 1
%11 = load double, double* %10
%12 = fsub double 1.000000e+00, %11
%13 = fneg double %8
%14 = call double @llvm.fmuladd.f64(double %13, double %12, double 1.500000e+00)
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = load double*, double** %3
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fsub double 1.000000e+00, %20
%22 = fneg double %17
%23 = call double @llvm.fmuladd.f64(double %22, double %21, double 1.500000e+00)
%24 = load double*, double** %3
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = load double*, double** %3
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = load double*, double** %3
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = fneg double %29
%34 = call double @llvm.fmuladd.f64(double %33, double %32, double 1.000000e+00)
%35 = fneg double %26
%36 = call double @llvm.fmuladd.f64(double %35, double %34, double 2.250000e+00)
%37 = load double*, double** %3
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load double*, double** %3
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = load double*, double** %3
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = fneg double %42
%47 = call double @llvm.fmuladd.f64(double %46, double %45, double 1.000000e+00)
%48 = fneg double %39
%49 = call double @llvm.fmuladd.f64(double %48, double %47, double 2.250000e+00)
%50 = fmul double %36, %49
%51 = call double @llvm.fmuladd.f64(double %14, double %23, double %50)
%52 = load double*, double** %3
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = load double*, double** %3
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = load double*, double** %3
%59 = getelementptr inbounds double, double* %58, i64 1
%60 = load double, double* %59
%61 = fmul double %57, %60
%62 = load double*, double** %3
%63 = getelementptr inbounds double, double* %62, i64 1
%64 = load double, double* %63
%65 = fneg double %61
%66 = call double @llvm.fmuladd.f64(double %65, double %64, double 1.000000e+00)
%67 = fneg double %54
%68 = call double @llvm.fmuladd.f64(double %67, double %66, double 2.625000e+00)
%69 = load double*, double** %3
%70 = getelementptr inbounds double, double* %69, i64 0
%71 = load double, double* %70
%72 = load double*, double** %3
%73 = getelementptr inbounds double, double* %72, i64 1
%74 = load double, double* %73
%75 = load double*, double** %3
%76 = getelementptr inbounds double, double* %75, i64 1
%77 = load double, double* %76
%78 = fmul double %74, %77
%79 = load double*, double** %3
%80 = getelementptr inbounds double, double* %79, i64 1
%81 = load double, double* %80
%82 = fneg double %78
%83 = call double @llvm.fmuladd.f64(double %82, double %81, double 1.000000e+00)
%84 = fneg double %71
%85 = call double @llvm.fmuladd.f64(double %84, double %83, double 2.625000e+00)
%86 = call double @llvm.fmuladd.f64(double %68, double %85, double %51)
store double %86, double* %5
%87 = load double, double* %5
ret double %87
}

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