double cox_deboor(unsigned int n, unsigned int p, const double t[n + 1],
                  const double v[n + 1 - p], double x) {
  assert(x >= t[0]);
  unsigned int i = 0;
  while (x >= t[i])
    i++;
  i--;
  return cox_deboor_i(x, p, p, t + i - p, v + i - p);
}


x86 assembly (clang, -O0):
<cox_deboor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
ucomisd (%rax),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1040 <assert@plt>
movl   $0x0,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
ucomisd (%rax,%rcx,8),%xmm0
jb     1183 <cox_deboor+0x63>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115e <cox_deboor+0x3e>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x24(%rbp),%eax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rcx
mov    -0x24(%rbp),%eax
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x8(%rbp),%eax
mov    %eax,%r8d
xor    %eax,%eax
sub    %r8,%rax
shl    $0x3,%rax
add    %rax,%rcx
mov    $0x1,%al
call   1030 <cox_deboor_i@plt>
cvtsi2sd %eax,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cox_deboor>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%ebp
xor    %edi,%edi
ucomisd (%rdx),%xmm0
setae  %dil
xor    %eax,%eax
call   1040 <assert@plt>
movsd  0x8(%rsp),%xmm0
mov    $0xfffffffe,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x2(%rax),%ecx
add    $0x1,%eax
ucomisd (%rbx,%rcx,8),%xmm0
jae    1160 <cox_deboor+0x40>
mov    %eax,%eax
lea    (%rbx,%rax,8),%rdx
mov    %ebp,%esi
shl    $0x3,%rsi
sub    %rsi,%rdx
lea    (%r14,%rax,8),%rcx
sub    %rsi,%rcx
mov    %ebp,%edi
mov    %ebp,%esi
mov    $0x1,%al
call   1030 <cox_deboor_i@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @cox_deboor(i32 %0, i32 %1, double* %2, double* %3, double %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store double* %2, double** %8
store double* %3, double** %9
store double %4, double* %10
%12 = load i32, i32* %6
%13 = add i32 %12, 1
%14 = zext i32 %13 to i64
%15 = load i32, i32* %6
%16 = add i32 %15, 1
%17 = load i32, i32* %7
%18 = sub i32 %16, %17
%19 = zext i32 %18 to i64
%20 = load double, double* %10
%21 = load double*, double** %8
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = fcmp oge double %20, %23
%25 = zext i1 %24 to i32
%26 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %25)
store i32 0, i32* %11
br label %27
27: ; preds = %35, %5
%28 = load double, double* %10
%29 = load double*, double** %8
%30 = load i32, i32* %11
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = fcmp oge double %28, %33
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = load i32, i32* %11
%37 = add i32 %36, 1
store i32 %37, i32* %11
br label %27
38: ; preds = %27
%39 = load i32, i32* %11
%40 = add i32 %39, -1
store i32 %40, i32* %11
%41 = load double, double* %10
%42 = load i32, i32* %7
%43 = load i32, i32* %7
%44 = load double*, double** %8
%45 = load i32, i32* %11
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load i32, i32* %7
%49 = zext i32 %48 to i64
%50 = sub i64 0, %49
%51 = getelementptr inbounds double, double* %47, i64 %50
%52 = load double*, double** %9
%53 = load i32, i32* %11
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load i32, i32* %7
%57 = zext i32 %56 to i64
%58 = sub i64 0, %57
%59 = getelementptr inbounds double, double* %55, i64 %58
%60 = call i32 (double, i32, i32, double*, double*, ...) bitcast (i32 (...)* @cox_deboor_i to i32 (double, i32, i32, double*, double*, ...)*)(double %41, i32 %42, i32 %43, double* %51, double* %59)
%61 = sitofp i32 %60 to double
ret double %61
}

LLVM IR (-O2):
define double @cox_deboor(i32 %0, i32 %1, double* %2, double* %3, double %4) {
%6 = load double, double* %2
%7 = fcmp ole double %6, %4
%8 = zext i1 %7 to i32
%9 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %8)
br label %10
10: ; preds = %10, %5
%11 = phi i32 [ 0, %5 ], [ %16, %10 ]
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds double, double* %2, i64 %12
%14 = load double, double* %13
%15 = fcmp ugt double %14, %4
%16 = add i32 %11, 1
br i1 %15, label %17, label %10
17: ; preds = %10
%18 = add i32 %11, -1
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds double, double* %2, i64 %19
%21 = zext i32 %1 to i64
%22 = sub nsw i64 0, %21
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = getelementptr inbounds double, double* %3, i64 %19
%25 = getelementptr inbounds double, double* %24, i64 %22
%26 = tail call i32 (double, i32, i32, double*, double*, ...) bitcast (i32 (...)* @cox_deboor_i to i32 (double, i32, i32, double*, double*, ...)*)(double %4, i32 %1, i32 %1, double* %23, double* %25)
%27 = sitofp i32 %26 to double
ret double %27
}