double bspline_curve_derivative(unsigned int k, unsigned int n, unsigned int p,
                                const double t[n + 1], const double v[n - p],
                                double x) {
  double t2[n + 1 - 2 * k];
  double v2[n - p - k];
  bspline_coeff_derivative_n(k, n, p, t2, v2, t, v);
  return cox_deboor(n - 2 * k, p - k, t2, v2, x);
}


x86 assembly (clang, -O0):
<bspline_curve_derivative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%edx
add    %edx,%edx
mov    %ecx,%eax
neg    %edx
mov    %edx,%ecx
lea    0x1(%rax,%rcx,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%edx
sub    %edx,%eax
mov    -0x4(%rbp),%edx
sub    %edx,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%r8
sub    %rdx,%r8
mov    %r8,-0x48(%rbp)
mov    %r8,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%r9
mov    -0x20(%rbp),%rax
sub    $0x10,%rsp
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <bspline_coeff_derivative_n@plt>
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
add    $0x10,%rsp
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
sub    %eax,%edi
mov    -0xc(%rbp),%esi
sub    -0x4(%rbp),%esi
movsd  -0x28(%rbp),%xmm0
mov    $0x1,%al
call   1040 <cox_deboor@plt>
cvtsi2sd %eax,%xmm0
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bspline_curve_derivative>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,-0x38(%rbp)
mov    %r8,%r10
mov    %rcx,%r9
mov    %edx,%r14d
mov    %esi,%r12d
mov    %edi,%r15d
lea    (%r15,%r15,1),%eax
mov    %eax,-0x2c(%rbp)
neg    %eax
add    %r12d,%eax
add    $0x1,%eax
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    %esi,%ecx
sub    %r15d,%ecx
sub    %r14d,%ecx
lea    0xf(,%rcx,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
sub    $0x8,%rsp
mov    %r13,%rcx
mov    %rbx,%r8
xor    %eax,%eax
push   %r10
call   1030 <bspline_coeff_derivative_n@plt>
add    $0x10,%rsp
sub    -0x2c(%rbp),%r12d
sub    %r15d,%r14d
mov    %r12d,%edi
mov    %r14d,%esi
mov    %r13,%rdx
mov    %rbx,%rcx
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1040 <cox_deboor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @bspline_curve_derivative(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double* %3, double** %10
store double* %4, double** %11
store double %5, double* %12
%16 = load i32, i32* %8
%17 = add i32 %16, 1
%18 = zext i32 %17 to i64
%19 = load i32, i32* %8
%20 = load i32, i32* %9
%21 = sub i32 %19, %20
%22 = zext i32 %21 to i64
%23 = load i32, i32* %8
%24 = add i32 %23, 1
%25 = load i32, i32* %7
%26 = mul i32 2, %25
%27 = sub i32 %24, %26
%28 = zext i32 %27 to i64
%29 = call i8* @llvm.stacksave()
store i8* %29, i8** %13
%30 = alloca double, i64 %28
store i64 %28, i64* %14
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = sub i32 %31, %32
%34 = load i32, i32* %7
%35 = sub i32 %33, %34
%36 = zext i32 %35 to i64
%37 = alloca double, i64 %36
store i64 %36, i64* %15
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = load double*, double** %10
%42 = load double*, double** %11
%43 = call i32 (i32, i32, i32, double*, double*, double*, double*, ...) bitcast (i32 (...)* @bspline_coeff_derivative_n to i32 (i32, i32, i32, double*, double*, double*, double*, ...)*)(i32 %38, i32 %39, i32 %40, double* %30, double* %37, double* %41, double* %42)
%44 = load i32, i32* %8
%45 = load i32, i32* %7
%46 = mul i32 2, %45
%47 = sub i32 %44, %46
%48 = load i32, i32* %9
%49 = load i32, i32* %7
%50 = sub i32 %48, %49
%51 = load double, double* %12
%52 = call i32 (i32, i32, double*, double*, double, ...) bitcast (i32 (...)* @cox_deboor to i32 (i32, i32, double*, double*, double, ...)*)(i32 %47, i32 %50, double* %30, double* %37, double %51)
%53 = sitofp i32 %52 to double
%54 = load i8*, i8** %13
ret double %53
}

LLVM IR (-O2):
define double @bspline_curve_derivative(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double %5) {
%7 = add i32 %1, 1
%8 = shl i32 %0, 1
%9 = sub i32 %7, %8
%10 = zext i32 %9 to i64
%11 = alloca double, i64 %10
%12 = add i32 %0, %2
%13 = sub i32 %1, %12
%14 = zext i32 %13 to i64
%15 = alloca double, i64 %14
%16 = call i32 (i32, i32, i32, double*, double*, double*, double*, ...) bitcast (i32 (...)* @bspline_coeff_derivative_n to i32 (i32, i32, i32, double*, double*, double*, double*, ...)*)(i32 %0, i32 %1, i32 %2, double* %11, double* %15, double* %3, double* %4)
%17 = sub i32 %1, %8
%18 = sub i32 %2, %0
%19 = call i32 (i32, i32, double*, double*, double, ...) bitcast (i32 (...)* @cox_deboor to i32 (i32, i32, double*, double*, double, ...)*)(i32 %17, i32 %18, double* %11, double* %15, double %5)
%20 = sitofp i32 %19 to double
ret double %20
}