double quartic(double *x, int N) {
  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    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xedc(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  0xebb(%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  0xea1(%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  0xde6(%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,-0x18(%rbp)
movsd  -0x18(%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) {
%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 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %11, double %8)
%13 = load double*, double** %3
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
%16 = load double*, double** %3
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
%19 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %18, double %15)
%20 = load double*, double** %3
%21 = getelementptr inbounds double, double* %20, i64 2
%22 = load double, double* %21
%23 = load double*, double** %3
%24 = getelementptr inbounds double, double* %23, i64 3
%25 = load double, double* %24
%26 = fsub double %22, %25
%27 = fmul double 5.000000e+00, %26
%28 = load double*, double** %3
%29 = getelementptr inbounds double, double* %28, i64 2
%30 = load double, double* %29
%31 = load double*, double** %3
%32 = getelementptr inbounds double, double* %31, i64 3
%33 = load double, double* %32
%34 = fsub double %30, %33
%35 = fmul double %27, %34
%36 = call double @llvm.fmuladd.f64(double %12, double %19, double %35)
%37 = load double*, double** %3
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = load double*, double** %3
%41 = getelementptr inbounds double, double* %40, i64 2
%42 = load double, double* %41
%43 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %42, double %39)
%44 = load double*, double** %3
%45 = getelementptr inbounds double, double* %44, i64 1
%46 = load double, double* %45
%47 = load double*, double** %3
%48 = getelementptr inbounds double, double* %47, i64 2
%49 = load double, double* %48
%50 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %49, double %46)
%51 = fmul double %43, %50
%52 = load double*, double** %3
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = load double*, double** %3
%56 = getelementptr inbounds double, double* %55, i64 2
%57 = load double, double* %56
%58 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %57, double %54)
%59 = fmul double %51, %58
%60 = load double*, double** %3
%61 = getelementptr inbounds double, double* %60, i64 1
%62 = load double, double* %61
%63 = load double*, double** %3
%64 = getelementptr inbounds double, double* %63, i64 2
%65 = load double, double* %64
%66 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %65, double %62)
%67 = call double @llvm.fmuladd.f64(double %59, double %66, double %36)
%68 = load double*, double** %3
%69 = getelementptr inbounds double, double* %68, i64 0
%70 = load double, double* %69
%71 = load double*, double** %3
%72 = getelementptr inbounds double, double* %71, i64 3
%73 = load double, double* %72
%74 = fsub double %70, %73
%75 = fmul double 1.000000e+01, %74
%76 = load double*, double** %3
%77 = getelementptr inbounds double, double* %76, i64 0
%78 = load double, double* %77
%79 = load double*, double** %3
%80 = getelementptr inbounds double, double* %79, i64 3
%81 = load double, double* %80
%82 = fsub double %78, %81
%83 = fmul double %75, %82
%84 = load double*, double** %3
%85 = getelementptr inbounds double, double* %84, i64 0
%86 = load double, double* %85
%87 = load double*, double** %3
%88 = getelementptr inbounds double, double* %87, i64 3
%89 = load double, double* %88
%90 = fsub double %86, %89
%91 = fmul double %83, %90
%92 = load double*, double** %3
%93 = getelementptr inbounds double, double* %92, i64 0
%94 = load double, double* %93
%95 = load double*, double** %3
%96 = getelementptr inbounds double, double* %95, i64 3
%97 = load double, double* %96
%98 = fsub double %94, %97
%99 = call double @llvm.fmuladd.f64(double %91, double %98, double %67)
store double %99, double* %5
%100 = load double, double* %5
ret double %100
}

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