double nlerp(int n, double *xin, double *f) {
  if (n == 1)
    return (1.0 - xin[0]) * f[0] + xin[0] * f[1];
  else
    return (1.0 - xin[0]) * nlerp(n - 1, xin + 1, f) +
           xin[0] * nlerp(n - 1, xin + 1, f + (1LL << (n - 1)));
}


x86 assembly (clang, -O0):
<nlerp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1168 <nlerp+0x58>
mov    -0x18(%rbp),%rax
movsd  0xec7(%rip),%xmm0
subsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f9 <nlerp+0xe9>
mov    -0x18(%rbp),%rax
movsd  0xe8c(%rip),%xmm0
subsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
mov    -0x18(%rbp),%rsi
add    $0x8,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <nlerp@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
mov    -0x18(%rbp),%rsi
add    $0x8,%rsi
mov    -0x20(%rbp),%rdx
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
shl    $0x3,%rax
add    %rax,%rdx
call   1030 <nlerp@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nlerp>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
movsd  (%rsi),%xmm2
cmp    $0x1,%edi
jne    1131 <nlerp+0x21>
movsd  (%r14),%xmm3
movsd  0x8(%r14),%xmm0
jmp    1178 <nlerp+0x68>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0xffffffff,%ebp
add    $0x8,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
movsd  %xmm2,0x8(%rsp)
call   1030 <nlerp@plt>
movsd  %xmm0,(%rsp)
mov    $0x1,%eax
mov    %ebp,%ecx
shl    %cl,%rax
lea    (%r14,%rax,8),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <nlerp@plt>
movsd  (%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movsd  0xe80(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define double @nlerp(i32 %0, double* %1, double* %2) {
%4 = icmp eq i32 %0, 1
%5 = load double, double* %1
br i1 %4, label %6, label %16
6: ; preds = %3
%7 = load double, double* %2
%8 = getelementptr inbounds double, double* %2, i64 1
%9 = load double, double* %8
br label %10
10: ; preds = %6, %16
%11 = phi double [ %9, %6 ], [ %23, %16 ]
%12 = phi double [ %7, %6 ], [ %19, %16 ]
%13 = fsub double 1.000000e+00, %5
%14 = fmul double %5, %11
%15 = tail call double @llvm.fmuladd.f64(double %13, double %12, double %14)
ret double %15
16: ; preds = %3
%17 = add nsw i32 %0, -1
%18 = getelementptr inbounds double, double* %1, i64 1
%19 = tail call double @nlerp(i32 %17, double* %18, double* %2)
%20 = zext i32 %17 to i64
%21 = shl nuw i64 1, %20
%22 = getelementptr inbounds double, double* %2, i64 %21
%23 = tail call double @nlerp(i32 %17, double* %18, double* %22)
br label %10
}