double de_casteljau(double t, unsigned int N, const double coeff[N + 1]) {
  if (0 == N)
    return coeff[0];
  double coeff2[N];
  de_casteljau_step(N, coeff2, t, coeff);
  return de_casteljau(t, N - 1, coeff2);
}


x86 assembly (clang, -O0):
<de_casteljau>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    1151 <de_casteljau+0x31>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ab <de_casteljau+0x8b>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    -0x20(%rbp),%rdx
mov    $0x1,%al
call   1040 <de_casteljau_step@plt>
mov    -0x38(%rbp),%rsi
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
call   1030 <de_casteljau@plt>
movsd  %xmm0,-0x8(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
movsd  -0x8(%rbp),%xmm0
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<de_casteljau>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rdx
test   %edi,%edi
je     1173 <de_casteljau+0x53>
mov    %edi,%ebx
mov    %rsp,%r15
mov    %edi,%eax
mov    %rsp,%r14
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rsi
movsd  %xmm0,-0x20(%rbp)
mov    $0x1,%al
call   1040 <de_casteljau_step@plt>
add    $0xffffffff,%ebx
movsd  -0x20(%rbp),%xmm0
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <de_casteljau@plt>
mov    %r15,%rsp
jmp    1177 <de_casteljau+0x57>
movsd  (%rdx),%xmm0
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @de_casteljau(double %0, i32 %1, double* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double*
%8 = alloca i8*
%9 = alloca i64
store double %0, double* %5
store i32 %1, i32* %6
store double* %2, double** %7
%10 = load i32, i32* %6
%11 = add i32 %10, 1
%12 = zext i32 %11 to i64
%13 = load i32, i32* %6
%14 = icmp eq i32 0, %13
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load double*, double** %7
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
store double %18, double* %4
br label %33
19: ; preds = %3
%20 = load i32, i32* %6
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %8
%23 = alloca double, i64 %21
store i64 %21, i64* %9
%24 = load i32, i32* %6
%25 = load double, double* %5
%26 = load double*, double** %7
%27 = call i32 (i32, double*, double, double*, ...) bitcast (i32 (...)* @de_casteljau_step to i32 (i32, double*, double, double*, ...)*)(i32 %24, double* %23, double %25, double* %26)
%28 = load double, double* %5
%29 = load i32, i32* %6
%30 = sub i32 %29, 1
%31 = call double @de_casteljau(double %28, i32 %30, double* %23)
store double %31, double* %4
%32 = load i8*, i8** %8
br label %33
33: ; preds = %19, %15
%34 = load double, double* %4
ret double %34
}

LLVM IR (-O2):
define double @de_casteljau(double %0, i32 %1, double* %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = load double, double* %2
br label %14
7: ; preds = %3
%8 = zext i32 %1 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca double, i64 %8
%11 = call i32 (i32, double*, double, double*, ...) bitcast (i32 (...)* @de_casteljau_step to i32 (i32, double*, double, double*, ...)*)(i32 %1, double* %10, double %0, double* %2)
%12 = add i32 %1, -1
%13 = call double @de_casteljau(double %0, i32 %12, double* %10)
br label %14
14: ; preds = %7, %5
%15 = phi double [ %6, %5 ], [ %13, %7 ]
ret double %15
}