double quartic(double *x, int N, void *params) {
  double f;
  f = (x[0] + 10 * x[1]) * (x[0] + 10 * x[1]) +
      5 * (x[2] - x[3]) * (x[2] - x[3]) +
      (x[1] - 2 * x[2]) * (x[1] - 2 * x[2]) * (x[1] - 2 * x[2]) *
          (x[1] - 2 * x[2]) +
      10 * (x[0] - x[3]) * (x[0] - x[3]) * (x[0] - x[3]) * (x[0] - x[3]);
  return f;
}


x86 assembly (clang, -O0):
<quartic>:
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  0x8(%rax),%xmm0
movsd  0xed8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  0xeb7(%rip),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm3
mov    -0x8(%rbp),%rax
subsd  0x18(%rax),%xmm3
movsd  0xe9d(%rip),%xmm1
mulsd  %xmm3,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm3
mov    -0x8(%rbp),%rax
subsd  0x18(%rax),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
addsd  %xmm2,%xmm2
subsd  %xmm2,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm3
addsd  %xmm3,%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm3
addsd  %xmm3,%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm3
addsd  %xmm3,%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
subsd  0x18(%rax),%xmm2
movsd  0xde2(%rip),%xmm0
mulsd  %xmm2,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
subsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
subsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
subsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<quartic>:
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm2
movsd  0xeef(%rip),%xmm0
movapd %xmm2,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
movsd  0x10(%rdi),%xmm4
movsd  0x18(%rdi),%xmm5
movapd %xmm4,%xmm6
subsd  %xmm5,%xmm6
movsd  0xed1(%rip),%xmm7
mulsd  %xmm6,%xmm7
mulsd  %xmm6,%xmm7
mulsd  %xmm3,%xmm3
addsd  %xmm7,%xmm3
addsd  %xmm4,%xmm4
subsd  %xmm4,%xmm2
movapd %xmm2,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm3,%xmm4
subsd  %xmm5,%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm4,%xmm0
ret

LLVM IR (-O0):
define double @quartic(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 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %13, double %10)
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %20, double %17)
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 3
%27 = load double, double* %26
%28 = fsub double %24, %27
%29 = fmul double 5.000000e+00, %28
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 2
%32 = load double, double* %31
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 3
%35 = load double, double* %34
%36 = fsub double %32, %35
%37 = fmul double %29, %36
%38 = call double @llvm.fmuladd.f64(double %14, double %21, double %37)
%39 = load double*, double** %4
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = load double*, double** %4
%43 = getelementptr inbounds double, double* %42, i64 2
%44 = load double, double* %43
%45 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %44, double %41)
%46 = load double*, double** %4
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load double, double* %47
%49 = load double*, double** %4
%50 = getelementptr inbounds double, double* %49, i64 2
%51 = load double, double* %50
%52 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %51, double %48)
%53 = fmul double %45, %52
%54 = load double*, double** %4
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = load double*, double** %4
%58 = getelementptr inbounds double, double* %57, i64 2
%59 = load double, double* %58
%60 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %59, double %56)
%61 = fmul double %53, %60
%62 = load double*, double** %4
%63 = getelementptr inbounds double, double* %62, i64 1
%64 = load double, double* %63
%65 = load double*, double** %4
%66 = getelementptr inbounds double, double* %65, i64 2
%67 = load double, double* %66
%68 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %67, double %64)
%69 = call double @llvm.fmuladd.f64(double %61, double %68, double %38)
%70 = load double*, double** %4
%71 = getelementptr inbounds double, double* %70, i64 0
%72 = load double, double* %71
%73 = load double*, double** %4
%74 = getelementptr inbounds double, double* %73, i64 3
%75 = load double, double* %74
%76 = fsub double %72, %75
%77 = fmul double 1.000000e+01, %76
%78 = load double*, double** %4
%79 = getelementptr inbounds double, double* %78, i64 0
%80 = load double, double* %79
%81 = load double*, double** %4
%82 = getelementptr inbounds double, double* %81, i64 3
%83 = load double, double* %82
%84 = fsub double %80, %83
%85 = fmul double %77, %84
%86 = load double*, double** %4
%87 = getelementptr inbounds double, double* %86, i64 0
%88 = load double, double* %87
%89 = load double*, double** %4
%90 = getelementptr inbounds double, double* %89, i64 3
%91 = load double, double* %90
%92 = fsub double %88, %91
%93 = fmul double %85, %92
%94 = load double*, double** %4
%95 = getelementptr inbounds double, double* %94, i64 0
%96 = load double, double* %95
%97 = load double*, double** %4
%98 = getelementptr inbounds double, double* %97, i64 3
%99 = load double, double* %98
%100 = fsub double %96, %99
%101 = call double @llvm.fmuladd.f64(double %93, double %100, double %69)
store double %101, double* %7
%102 = load double, double* %7
ret double %102
}

LLVM IR (-O2):
define double @quartic(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 = tail call double @llvm.fmuladd.f64(double %6, double 1.000000e+01, double %4)
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %0, i64 3
%11 = load double, double* %10
%12 = fsub double %9, %11
%13 = fmul double %12, 5.000000e+00
%14 = fmul double %12, %13
%15 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %14)
%16 = tail call double @llvm.fmuladd.f64(double %9, double -2.000000e+00, double %6)
%17 = fmul double %16, %16
%18 = fmul double %16, %17
%19 = tail call double @llvm.fmuladd.f64(double %18, double %16, double %15)
%20 = fsub double %4, %11
%21 = fmul double %20, 1.000000e+01
%22 = fmul double %20, %21
%23 = fmul double %20, %22
%24 = tail call double @llvm.fmuladd.f64(double %23, double %20, double %19)
ret double %24
}