float xnn(int n) {
  if (n == 1)
    return 1;
  if (n == 2)
    return 2;
  return (n - 1) * xnn(n - 1) / n + xnn(n - 2) / n;
}


x86 assembly (clang, -O0):
<xnn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1137 <xnn+0x27>
movss  0xed7(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11ac <xnn+0x9c>
cmpl   $0x2,-0x8(%rbp)
jne    1153 <xnn+0x43>
movss  0xeb7(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11ac <xnn+0x9c>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1030 <xnn@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
call   1030 <xnn@plt>
movaps %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm2
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xnn>:
push   %rbx
sub    $0x20,%rsp
cmp    $0x1,%edi
je     112b <xnn+0x1b>
mov    %edi,%ebx
cmp    $0x2,%edi
jne    1135 <xnn+0x25>
movss  0xedb(%rip),%xmm0
jmp    1183 <xnn+0x73>
movss  0xecd(%rip),%xmm0
jmp    1183 <xnn+0x73>
lea    -0x1(%rbx),%edi
cvtsi2ss %edi,%xmm0
movss  %xmm0,(%rsp)
call   1030 <xnn@plt>
mulss  (%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movaps %xmm0,(%rsp)
add    $0xfffffffe,%ebx
mov    %ebx,%edi
call   1030 <xnn@plt>
movaps 0x10(%rsp),%xmm1
unpcklps %xmm0,%xmm1
movaps (%rsp),%xmm0
shufps $0x0,%xmm0,%xmm0
divps  %xmm0,%xmm1
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
addss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @xnn(i32 %0) {
%2 = alloca float
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %7
6: ; preds = %1
store float 1.000000e+00, float* %2
br label %29
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %7
store float 2.000000e+00, float* %2
br label %29
11: ; preds = %7
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = sitofp i32 %13 to float
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = call float @xnn(i32 %16)
%18 = fmul float %14, %17
%19 = load i32, i32* %3
%20 = sitofp i32 %19 to float
%21 = fdiv float %18, %20
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 2
%24 = call float @xnn(i32 %23)
%25 = load i32, i32* %3
%26 = sitofp i32 %25 to float
%27 = fdiv float %24, %26
%28 = fadd float %21, %27
store float %28, float* %2
br label %29
29: ; preds = %11, %10, %6
%30 = load float, float* %2
ret float %30
}

LLVM IR (-O2):
define float @xnn(i32 %0) {
switch i32 %0, label %5 [
i32 1, label %3
i32 2, label %2
]
2: ; preds = %1
br label %3
3: ; preds = %2, %1, %5
%4 = phi float [ %20, %5 ], [ 2.000000e+00, %2 ], [ 1.000000e+00, %1 ]
ret float %4
5: ; preds = %1
%6 = add nsw i32 %0, -1
%7 = sitofp i32 %6 to float
%8 = tail call float @xnn(i32 %6)
%9 = fmul float %8, %7
%10 = sitofp i32 %0 to float
%11 = add nsw i32 %0, -2
%12 = tail call float @xnn(i32 %11)
%13 = insertelement <2 x float> poison, float %9, i64 0
%14 = insertelement <2 x float> %13, float %12, i64 1
%15 = insertelement <2 x float> poison, float %10, i64 0
%16 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> zeroinitializer
%17 = fdiv <2 x float> %14, %16
%18 = shufflevector <2 x float> %17, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%19 = fadd <2 x float> %17, %18
%20 = extractelement <2 x float> %19, i64 0
br label %3
}