void de_casteljau_step(unsigned int N, double out[N], double t,
                       const double coeff[N + 1]) {
  for (unsigned int i = 0; i < N; i++)
    out[i] = lerp(t, coeff[i], coeff[i + 1]);
}


x86 assembly (clang, -O0):
<de_casteljau_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1182 <de_casteljau_step+0x72>
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm2
mov    $0x3,%al
call   1030 <lerp@plt>
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112f <de_casteljau_step+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<de_casteljau_step>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
je     1173 <de_casteljau_step+0x63>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %edi,%r15d
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x1(%rbx),%r13
movsd  (%r12,%rbx,8),%xmm1
movsd  0x8(%r12,%rbx,8),%xmm2
movsd  0x8(%rsp),%xmm0
mov    $0x3,%al
call   1030 <lerp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
mov    %r13,%rbx
cmp    %r13,%r15
jne    1140 <de_casteljau_step+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @de_casteljau_step(i32 %0, double* nocapture writeonly %1, double %2, double* nocapture %3) {
%5 = icmp eq i32 %0, 0
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %9
8: ; preds = %9, %4
ret void
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %13, %9 ]
%11 = getelementptr inbounds double, double* %3, i64 %10
%12 = load double, double* %11
%13 = add nuw nsw i64 %10, 1
%14 = getelementptr inbounds double, double* %3, i64 %13
%15 = load double, double* %14
%16 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @lerp to i32 (double, double, double, ...)*)(double %2, double %12, double %15)
%17 = sitofp i32 %16 to double
%18 = getelementptr inbounds double, double* %1, i64 %10
store double %17, double* %18
%19 = icmp eq i64 %13, %7
br i1 %19, label %8, label %9
}