double ciag(double n) {
  if (n == 0)
    return 2;
  else if (n == 1)
    return 5;
  else
    return 5 * ciag(n - 1) - 6 * ciag(n - 2);
}


x86 assembly (clang, -O0):
<ciag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1147 <ciag+0x37>
jp     1147 <ciag+0x37>
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e7 <ciag+0xd7>
movsd  -0x10(%rbp),%xmm0
movsd  0xeac(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1176 <ciag+0x66>
jp     1176 <ciag+0x66>
movsd  0xe9c(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e7 <ciag+0xd7>
movsd  -0x10(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <ciag@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe7a(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <ciag@plt>
movaps %xmm0,%xmm2
movsd  -0x18(%rbp),%xmm0
movsd  0xe59(%rip),%xmm1
mulsd  %xmm2,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe2e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ciag>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1131 <ciag+0x21>
jp     1131 <ciag+0x21>
movsd  0xed4(%rip),%xmm0
add    $0x18,%rsp
ret
ucomisd 0xed7(%rip),%xmm1
jne    114a <ciag+0x3a>
jp     114a <ciag+0x3a>
movsd  0xec3(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0xec6(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <ciag@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0xeab(%rip),%xmm0
call   1030 <ciag@plt>
mulsd  0xea6(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe78(%rip),%xmm1
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @ciag(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp oeq double %4, 0.000000e+00
br i1 %5, label %6, label %7
6: ; preds = %1
store double 2.000000e+00, double* %2
br label %21
7: ; preds = %1
%8 = load double, double* %3
%9 = fcmp oeq double %8, 1.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %7
store double 5.000000e+00, double* %2
br label %21
11: ; preds = %7
%12 = load double, double* %3
%13 = fsub double %12, 1.000000e+00
%14 = call double @ciag(double %13)
%15 = load double, double* %3
%16 = fsub double %15, 2.000000e+00
%17 = call double @ciag(double %16)
%18 = fmul double 6.000000e+00, %17
%19 = fneg double %18
%20 = call double @llvm.fmuladd.f64(double 5.000000e+00, double %14, double %19)
store double %20, double* %2
br label %21
21: ; preds = %11, %10, %6
%22 = load double, double* %2
ret double %22
}

LLVM IR (-O2):
define double @ciag(double %0) {
%2 = fcmp oeq double %0, 0.000000e+00
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = fcmp oeq double %0, 1.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %1, %3, %7
%6 = phi double [ %13, %7 ], [ 2.000000e+00, %1 ], [ 5.000000e+00, %3 ]
ret double %6
7: ; preds = %3
%8 = fadd double %0, -1.000000e+00
%9 = tail call double @ciag(double %8)
%10 = fadd double %0, -2.000000e+00
%11 = tail call double @ciag(double %10)
%12 = fmul double %11, -6.000000e+00
%13 = tail call double @llvm.fmuladd.f64(double %9, double 5.000000e+00, double %12)
br label %5
}