double L2(double x) {
  double L[2 + 1];
  L[0] = 1.;
  L[1] = x;
  {
    for (int i = 2; i < 2 + 1; i++)
      L[i] = 2. * (x)*L[i - 1] - L[i - 2] -
             ((x)*L[i - 1] - L[i - 2]) / ((double)i);
  };
  return L[2];
}


x86 assembly (clang, -O0):
<L2>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeef(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x2,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11de <L2+0xde>
movsd  0xecf(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x20(%rbp,%rax,8),%xmm2
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
cltq
movsd  -0x20(%rbp,%rax,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x20(%rbp,%rax,8),%xmm3
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
cltq
movsd  -0x20(%rbp,%rax,8),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movslq -0x24(%rbp),%rax
movsd  %xmm0,-0x20(%rbp,%rax,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1127 <L2+0x27>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<L2>:
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xeec(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
mulsd  0xee0(%rip),%xmm0
addsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @L2(double %0) {
%2 = alloca double
%3 = alloca [3 x double]
%4 = alloca i32
store double %0, double* %2
%5 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
store double 1.000000e+00, double* %5
%6 = load double, double* %2
%7 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
store double %6, double* %7
store i32 2, i32* %4
br label %8
8: ; preds = %46, %1
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %49
11: ; preds = %8
%12 = load double, double* %2
%13 = fmul double 2.000000e+00, %12
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %16
%18 = load double, double* %17
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %21
%23 = load double, double* %22
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double %13, double %18, double %24)
%26 = load double, double* %2
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %29
%31 = load double, double* %30
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %34
%36 = load double, double* %35
%37 = fneg double %36
%38 = call double @llvm.fmuladd.f64(double %26, double %31, double %37)
%39 = load i32, i32* %4
%40 = sitofp i32 %39 to double
%41 = fdiv double %38, %40
%42 = fsub double %25, %41
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 %44
store double %42, double* %45
br label %46
46: ; preds = %11
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %8
49: ; preds = %8
%50 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
%51 = load double, double* %50
ret double %51
}

LLVM IR (-O2):
define double @L2(double %0) {
%2 = fmul double %0, 2.000000e+00
%3 = tail call double @llvm.fmuladd.f64(double %2, double %0, double -1.000000e+00)
%4 = tail call double @llvm.fmuladd.f64(double %0, double %0, double -1.000000e+00)
%5 = fmul double %4, 5.000000e-01
%6 = fsub double %3, %5
ret double %6
}