double interp1d(double x, double wl[], double f[], int n, int *starti) {
  double p0, p1, p2, p3;
  double f0, f1, f2, f3;
  double wl0, wl1, wl2, wl3;
  double temp1, temp2, temp3;
  double temp12, temp13;
  double y;
  int i;
  if (n == 1 || x <= wl[0]) {
    y = f[0];
  } else if (x >= wl[n - 1]) {
    y = f[n - 1];
  } else if (n == 2) {
    p0 = (wl[1] - x) / (wl[1] - wl[0]);
    p1 = 1. - x;
    y = f[0] * p0 + f[1] * p1;
  } else if (n == 3) {
    p0 = wl[0] - x;
    p1 = wl[1] - x;
    p2 = wl[2] - x;
    y = ((f[0] * p1 - f[1] * p0) * p2 / (wl[1] - wl[0]) -
         (f[0] * p2 - f[2] * p0) * p1 / (wl[2] - wl[0])) /
        (wl[2] - wl[1]);
  } else {
    i = *starti;
    if (i < 1 || i > n - 3 || x < wl[i - 1] || x > wl[i + 2]) {
      i = BinarySearch(x, wl, n);
    } else {
      if (wl[i - 1] <= x && x < wl[i]) {
        if (i > 1) {
          i--;
        }
      } else if (wl[i + 1] <= x && x <= wl[i + 2]) {
        if (i < n - 3) {
          i++;
        }
      }
    }
    *starti = i;
    wl0 = wl[i - 1];
    wl1 = wl[i];
    wl2 = wl[i + 1];
    wl3 = wl[i + 2];
    f0 = f[i - 1];
    f1 = f[i];
    f2 = f[i + 1];
    f3 = f[i + 2];
    p0 = wl0 - x;
    p1 = wl1 - x;
    p2 = wl2 - x;
    p3 = wl3 - x;
    temp1 = ((f0) * (p1) - (p0) * (f1)) / (wl1 - wl0);
    temp2 = ((f0) * (p2) - (p0) * (f2)) / (wl2 - wl0);
    temp3 = ((f0) * (p3) - (p0) * (f3)) / (wl3 - wl0);
    temp12 = ((temp1) * (p2) - (p1) * (temp2)) / (wl2 - wl1);
    temp13 = ((temp1) * (p3) - (p1) * (temp3)) / (wl3 - wl1);
    y = ((temp12) * (p3) - (p2) * (temp13)) / (wl3 - wl2);
  }
  return (y);
}


x86 assembly (clang, -O0):
<interp1d>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
cmpl   $0x1,-0x1c(%rbp)
je     1150 <interp1d+0x40>
movsd  -0x8(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     1165 <interp1d+0x55>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    1787 <interp1d+0x677>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jb     11a1 <interp1d+0x91>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    1782 <interp1d+0x672>
cmpl   $0x2,-0x1c(%rbp)
jne    1215 <interp1d+0x105>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
subsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe25(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x30(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    177d <interp1d+0x66d>
cmpl   $0x3,-0x1c(%rbp)
jne    1326 <interp1d+0x216>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x38(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mulsd  -0x30(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x40(%rbp),%xmm3
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  -0x30(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  -0x38(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    1778 <interp1d+0x668>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xbc(%rbp)
cmpl   $0x1,-0xbc(%rbp)
jl     1397 <interp1d+0x287>
mov    -0xbc(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jg     1397 <interp1d+0x287>
movsd  -0x8(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0xbc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
ja     1397 <interp1d+0x287>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0xbc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    13b5 <interp1d+0x2a5>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x1,%al
call   1030 <BinarySearch@plt>
mov    %eax,-0xbc(%rbp)
jmp    1493 <interp1d+0x383>
mov    -0x10(%rbp),%rax
mov    -0xbc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1419 <interp1d+0x309>
movsd  -0x8(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movslq -0xbc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1419 <interp1d+0x309>
cmpl   $0x1,-0xbc(%rbp)
jle    1414 <interp1d+0x304>
mov    -0xbc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xbc(%rbp)
jmp    148e <interp1d+0x37e>
mov    -0x10(%rbp),%rax
mov    -0xbc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1489 <interp1d+0x379>
movsd  -0x8(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0xbc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1489 <interp1d+0x379>
mov    -0xbc(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    1484 <interp1d+0x374>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    1489 <interp1d+0x379>
jmp    148e <interp1d+0x37e>
jmp    1493 <interp1d+0x383>
mov    -0xbc(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    -0xbc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movslq -0xbc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    -0xbc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    -0xbc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0xbc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xbc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    -0xbc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%rax
mov    -0xbc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x70(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x78(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x80(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x78(%rbp),%xmm1
subsd  -0x70(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x80(%rbp),%xmm1
subsd  -0x70(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
subsd  -0x70(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x98(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x80(%rbp),%xmm1
subsd  -0x78(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0xa0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
subsd  -0x78(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0x48(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0xb0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
subsd  -0x80(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    177d <interp1d+0x66d>
jmp    1782 <interp1d+0x672>
jmp    1787 <interp1d+0x677>
movsd  -0xb8(%rbp),%xmm0
ff
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interp1d>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
cmp    $0x1,%edx
je     117d <interp1d+0x6d>
mov    %rdi,%rbx
movapd %xmm0,%xmm7
movsd  (%rdi),%xmm1
ucomisd %xmm0,%xmm1
jae    117d <interp1d+0x6d>
movslq %edx,%rax
ucomisd -0x8(%rbx,%rax,8),%xmm7
jae    118c <interp1d+0x7c>
cmp    $0x3,%edx
je     1198 <interp1d+0x88>
cmp    $0x2,%edx
jne    120a <interp1d+0xfa>
movsd  0x8(%rbx),%xmm2
movapd %xmm2,%xmm0
subsd  %xmm7,%xmm0
subsd  %xmm1,%xmm2
movsd  0xe9c(%rip),%xmm1
subsd  %xmm7,%xmm1
mulsd  0x8(%r14),%xmm1
divsd  %xmm2,%xmm0
mulsd  (%r14),%xmm0
addsd  %xmm1,%xmm0
jmp    1182 <interp1d+0x72>
movsd  (%r14),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
add    $0xffffffffffffffff,%rax
movsd  (%r14,%rax,8),%xmm0
jmp    1182 <interp1d+0x72>
movapd %xmm1,%xmm2
subsd  %xmm7,%xmm2
movupd 0x8(%rbx),%xmm0
unpcklpd %xmm7,%xmm7
movapd %xmm0,%xmm3
movapd %xmm0,%xmm4
unpckhpd %xmm0,%xmm4
subsd  %xmm0,%xmm4
movapd %xmm0,%xmm5
subpd  %xmm7,%xmm5
movupd 0x8(%r14),%xmm0
unpcklpd %xmm2,%xmm2
mulpd  %xmm0,%xmm2
movsd  (%r14),%xmm0
unpcklpd %xmm0,%xmm0
mulpd  %xmm5,%xmm0
subpd  %xmm2,%xmm0
shufpd $0x1,%xmm5,%xmm5
mulpd  %xmm5,%xmm0
unpcklpd %xmm1,%xmm1
subpd  %xmm1,%xmm3
divpd  %xmm3,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
divsd  %xmm4,%xmm0
jmp    1182 <interp1d+0x72>
mov    %rcx,%r15
mov    (%rcx),%eax
test   %eax,%eax
jle    1238 <interp1d+0x128>
lea    -0x3(%rdx),%ecx
cmp    %ecx,%eax
jg     1238 <interp1d+0x128>
lea    -0x1(%rax),%esi
movsd  (%rbx,%rsi,8),%xmm1
ucomisd %xmm7,%xmm1
ja     1238 <interp1d+0x128>
movsd  0x10(%rbx,%rax,8),%xmm0
ucomisd %xmm0,%xmm7
jbe    134e <interp1d+0x23e>
movapd %xmm7,%xmm0
mov    %rbx,%rdi
mov    %edx,%esi
mov    $0x1,%al
movapd %xmm7,(%rsp)
call   1030 <BinarySearch@plt>
movapd (%rsp),%xmm7
mov    %eax,(%r15)
cltq
movsd  -0x8(%rbx,%rax,8),%xmm6
movsd  (%rbx,%rax,8),%xmm3
movsd  0x8(%rbx,%rax,8),%xmm9
movsd  0x10(%rbx,%rax,8),%xmm12
movsd  -0x8(%r14,%rax,8),%xmm4
movapd %xmm3,%xmm8
subsd  %xmm6,%xmm8
movapd %xmm9,%xmm10
subsd  %xmm6,%xmm10
movapd %xmm12,%xmm11
subsd  %xmm6,%xmm11
subsd  %xmm7,%xmm6
movapd %xmm9,%xmm13
subsd  %xmm3,%xmm13
movapd %xmm12,%xmm14
subsd  %xmm3,%xmm14
subsd  %xmm7,%xmm3
movapd %xmm12,%xmm1
subsd  %xmm9,%xmm12
subsd  %xmm7,%xmm9
subsd  %xmm7,%xmm1
movsd  (%r14,%rax,8),%xmm0
mulsd  %xmm6,%xmm0
movapd %xmm4,%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm0,%xmm2
divsd  %xmm8,%xmm2
movsd  0x8(%r14,%rax,8),%xmm0
mulsd  %xmm6,%xmm0
movapd %xmm4,%xmm5
mulsd  %xmm9,%xmm5
subsd  %xmm0,%xmm5
mulsd  0x10(%r14,%rax,8),%xmm6
divsd  %xmm10,%xmm5
mulsd  %xmm1,%xmm4
subsd  %xmm6,%xmm4
divsd  %xmm11,%xmm4
mulsd  %xmm3,%xmm5
movapd %xmm2,%xmm0
mulsd  %xmm9,%xmm0
subsd  %xmm5,%xmm0
divsd  %xmm13,%xmm0
mulsd  %xmm3,%xmm4
mulsd  %xmm1,%xmm2
subsd  %xmm4,%xmm2
divsd  %xmm14,%xmm2
mulsd  %xmm9,%xmm2
mulsd  %xmm1,%xmm0
subsd  %xmm2,%xmm0
divsd  %xmm12,%xmm0
jmp    1182 <interp1d+0x72>
ucomisd %xmm1,%xmm7
jb     136f <interp1d+0x25f>
movsd  (%rbx,%rax,8),%xmm1
ucomisd %xmm7,%xmm1
jbe    136f <interp1d+0x25f>
cmp    $0x2,%eax
mov    $0x1,%eax
cmovae %esi,%eax
jmp    1252 <interp1d+0x142>
ucomisd 0x8(%rbx,%rax,8),%xmm7
jb     1252 <interp1d+0x142>
lea    0x1(%rax),%rdx
cmp    %ecx,%eax
cmovge %eax,%edx
ucomisd %xmm7,%xmm0
cmovb  %eax,%edx
mov    %edx,%eax
jmp    1252 <interp1d+0x142>

LLVM IR (-O0):
define double @interp1d(double %0, double* %1, double* %2, i32 %3, i32* %4) {
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca i32
store double %0, double* %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%30 = load i32, i32* %9
%31 = icmp eq i32 %30, 1
br i1 %31, label %38, label %32
32: ; preds = %5
%33 = load double, double* %6
%34 = load double*, double** %7
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = fcmp ole double %33, %36
br i1 %37, label %38, label %42
38: ; preds = %32, %5
%39 = load double*, double** %8
%40 = getelementptr inbounds double, double* %39, i64 0
%41 = load double, double* %40
store double %41, double* %28
br label %373
42: ; preds = %32
%43 = load double, double* %6
%44 = load double*, double** %7
%45 = load i32, i32* %9
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %44, i64 %47
%49 = load double, double* %48
%50 = fcmp oge double %43, %49
br i1 %50, label %51, label %58
51: ; preds = %42
%52 = load double*, double** %8
%53 = load i32, i32* %9
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %52, i64 %55
%57 = load double, double* %56
store double %57, double* %28
br label %372
58: ; preds = %42
%59 = load i32, i32* %9
%60 = icmp eq i32 %59, 2
br i1 %60, label %61, label %87
61: ; preds = %58
%62 = load double*, double** %7
%63 = getelementptr inbounds double, double* %62, i64 1
%64 = load double, double* %63
%65 = load double, double* %6
%66 = fsub double %64, %65
%67 = load double*, double** %7
%68 = getelementptr inbounds double, double* %67, i64 1
%69 = load double, double* %68
%70 = load double*, double** %7
%71 = getelementptr inbounds double, double* %70, i64 0
%72 = load double, double* %71
%73 = fsub double %69, %72
%74 = fdiv double %66, %73
store double %74, double* %11
%75 = load double, double* %6
%76 = fsub double 1.000000e+00, %75
store double %76, double* %12
%77 = load double*, double** %8
%78 = getelementptr inbounds double, double* %77, i64 0
%79 = load double, double* %78
%80 = load double, double* %11
%81 = load double*, double** %8
%82 = getelementptr inbounds double, double* %81, i64 1
%83 = load double, double* %82
%84 = load double, double* %12
%85 = fmul double %83, %84
%86 = call double @llvm.fmuladd.f64(double %79, double %80, double %85)
store double %86, double* %28
br label %371
87: ; preds = %58
%88 = load i32, i32* %9
%89 = icmp eq i32 %88, 3
br i1 %89, label %90, label %157
90: ; preds = %87
%91 = load double*, double** %7
%92 = getelementptr inbounds double, double* %91, i64 0
%93 = load double, double* %92
%94 = load double, double* %6
%95 = fsub double %93, %94
store double %95, double* %11
%96 = load double*, double** %7
%97 = getelementptr inbounds double, double* %96, i64 1
%98 = load double, double* %97
%99 = load double, double* %6
%100 = fsub double %98, %99
store double %100, double* %12
%101 = load double*, double** %7
%102 = getelementptr inbounds double, double* %101, i64 2
%103 = load double, double* %102
%104 = load double, double* %6
%105 = fsub double %103, %104
store double %105, double* %13
%106 = load double*, double** %8
%107 = getelementptr inbounds double, double* %106, i64 0
%108 = load double, double* %107
%109 = load double, double* %12
%110 = load double*, double** %8
%111 = getelementptr inbounds double, double* %110, i64 1
%112 = load double, double* %111
%113 = load double, double* %11
%114 = fmul double %112, %113
%115 = fneg double %114
%116 = call double @llvm.fmuladd.f64(double %108, double %109, double %115)
%117 = load double, double* %13
%118 = fmul double %116, %117
%119 = load double*, double** %7
%120 = getelementptr inbounds double, double* %119, i64 1
%121 = load double, double* %120
%122 = load double*, double** %7
%123 = getelementptr inbounds double, double* %122, i64 0
%124 = load double, double* %123
%125 = fsub double %121, %124
%126 = fdiv double %118, %125
%127 = load double*, double** %8
%128 = getelementptr inbounds double, double* %127, i64 0
%129 = load double, double* %128
%130 = load double, double* %13
%131 = load double*, double** %8
%132 = getelementptr inbounds double, double* %131, i64 2
%133 = load double, double* %132
%134 = load double, double* %11
%135 = fmul double %133, %134
%136 = fneg double %135
%137 = call double @llvm.fmuladd.f64(double %129, double %130, double %136)
%138 = load double, double* %12
%139 = fmul double %137, %138
%140 = load double*, double** %7
%141 = getelementptr inbounds double, double* %140, i64 2
%142 = load double, double* %141
%143 = load double*, double** %7
%144 = getelementptr inbounds double, double* %143, i64 0
%145 = load double, double* %144
%146 = fsub double %142, %145
%147 = fdiv double %139, %146
%148 = fsub double %126, %147
%149 = load double*, double** %7
%150 = getelementptr inbounds double, double* %149, i64 2
%151 = load double, double* %150
%152 = load double*, double** %7
%153 = getelementptr inbounds double, double* %152, i64 1
%154 = load double, double* %153
%155 = fsub double %151, %154
%156 = fdiv double %148, %155
store double %156, double* %28
br label %370
157: ; preds = %87
%158 = load i32*, i32** %10
%159 = load i32, i32* %158
store i32 %159, i32* %29
%160 = load i32, i32* %29
%161 = icmp slt i32 %160, 1
br i1 %161, label %185, label %162
162: ; preds = %157
%163 = load i32, i32* %29
%164 = load i32, i32* %9
%165 = sub nsw i32 %164, 3
%166 = icmp sgt i32 %163, %165
br i1 %166, label %185, label %167
167: ; preds = %162
%168 = load double, double* %6
%169 = load double*, double** %7
%170 = load i32, i32* %29
%171 = sub nsw i32 %170, 1
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds double, double* %169, i64 %172
%174 = load double, double* %173
%175 = fcmp olt double %168, %174
br i1 %175, label %185, label %176
176: ; preds = %167
%177 = load double, double* %6
%178 = load double*, double** %7
%179 = load i32, i32* %29
%180 = add nsw i32 %179, 2
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds double, double* %178, i64 %181
%183 = load double, double* %182
%184 = fcmp ogt double %177, %183
br i1 %184, label %185, label %190
185: ; preds = %176, %167, %162, %157
%186 = load double, double* %6
%187 = load double*, double** %7
%188 = load i32, i32* %9
%189 = call i32 (double, double*, i32, ...) bitcast (i32 (...)* @BinarySearch to i32 (double, double*, i32, ...)*)(double %186, double* %187, i32 %188)
store i32 %189, i32* %29
br label %243
190: ; preds = %176
%191 = load double*, double** %7
%192 = load i32, i32* %29
%193 = sub nsw i32 %192, 1
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds double, double* %191, i64 %194
%196 = load double, double* %195
%197 = load double, double* %6
%198 = fcmp ole double %196, %197
br i1 %198, label %199, label %214
199: ; preds = %190
%200 = load double, double* %6
%201 = load double*, double** %7
%202 = load i32, i32* %29
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds double, double* %201, i64 %203
%205 = load double, double* %204
%206 = fcmp olt double %200, %205
br i1 %206, label %207, label %214
207: ; preds = %199
%208 = load i32, i32* %29
%209 = icmp sgt i32 %208, 1
br i1 %209, label %210, label %213
210: ; preds = %207
%211 = load i32, i32* %29
%212 = add nsw i32 %211, -1
store i32 %212, i32* %29
br label %213
213: ; preds = %210, %207
br label %242
214: ; preds = %199, %190
%215 = load double*, double** %7
%216 = load i32, i32* %29
%217 = add nsw i32 %216, 1
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds double, double* %215, i64 %218
%220 = load double, double* %219
%221 = load double, double* %6
%222 = fcmp ole double %220, %221
br i1 %222, label %223, label %241
223: ; preds = %214
%224 = load double, double* %6
%225 = load double*, double** %7
%226 = load i32, i32* %29
%227 = add nsw i32 %226, 2
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds double, double* %225, i64 %228
%230 = load double, double* %229
%231 = fcmp ole double %224, %230
br i1 %231, label %232, label %241
232: ; preds = %223
%233 = load i32, i32* %29
%234 = load i32, i32* %9
%235 = sub nsw i32 %234, 3
%236 = icmp slt i32 %233, %235
br i1 %236, label %237, label %240
237: ; preds = %232
%238 = load i32, i32* %29
%239 = add nsw i32 %238, 1
store i32 %239, i32* %29
br label %240
240: ; preds = %237, %232
br label %241
241: ; preds = %240, %223, %214
br label %242
242: ; preds = %241, %213
br label %243
243: ; preds = %242, %185
%244 = load i32, i32* %29
%245 = load i32*, i32** %10
store i32 %244, i32* %245
%246 = load double*, double** %7
%247 = load i32, i32* %29
%248 = sub nsw i32 %247, 1
%249 = sext i32 %248 to i64
%250 = getelementptr inbounds double, double* %246, i64 %249
%251 = load double, double* %250
store double %251, double* %19
%252 = load double*, double** %7
%253 = load i32, i32* %29
%254 = sext i32 %253 to i64
%255 = getelementptr inbounds double, double* %252, i64 %254
%256 = load double, double* %255
store double %256, double* %20
%257 = load double*, double** %7
%258 = load i32, i32* %29
%259 = add nsw i32 %258, 1
%260 = sext i32 %259 to i64
%261 = getelementptr inbounds double, double* %257, i64 %260
%262 = load double, double* %261
store double %262, double* %21
%263 = load double*, double** %7
%264 = load i32, i32* %29
%265 = add nsw i32 %264, 2
%266 = sext i32 %265 to i64
%267 = getelementptr inbounds double, double* %263, i64 %266
%268 = load double, double* %267
store double %268, double* %22
%269 = load double*, double** %8
%270 = load i32, i32* %29
%271 = sub nsw i32 %270, 1
%272 = sext i32 %271 to i64
%273 = getelementptr inbounds double, double* %269, i64 %272
%274 = load double, double* %273
store double %274, double* %15
%275 = load double*, double** %8
%276 = load i32, i32* %29
%277 = sext i32 %276 to i64
%278 = getelementptr inbounds double, double* %275, i64 %277
%279 = load double, double* %278
store double %279, double* %16
%280 = load double*, double** %8
%281 = load i32, i32* %29
%282 = add nsw i32 %281, 1
%283 = sext i32 %282 to i64
%284 = getelementptr inbounds double, double* %280, i64 %283
%285 = load double, double* %284
store double %285, double* %17
%286 = load double*, double** %8
%287 = load i32, i32* %29
%288 = add nsw i32 %287, 2
%289 = sext i32 %288 to i64
%290 = getelementptr inbounds double, double* %286, i64 %289
%291 = load double, double* %290
store double %291, double* %18
%292 = load double, double* %19
%293 = load double, double* %6
%294 = fsub double %292, %293
store double %294, double* %11
%295 = load double, double* %20
%296 = load double, double* %6
%297 = fsub double %295, %296
store double %297, double* %12
%298 = load double, double* %21
%299 = load double, double* %6
%300 = fsub double %298, %299
store double %300, double* %13
%301 = load double, double* %22
%302 = load double, double* %6
%303 = fsub double %301, %302
store double %303, double* %14
%304 = load double, double* %15
%305 = load double, double* %12
%306 = load double, double* %11
%307 = load double, double* %16
%308 = fmul double %306, %307
%309 = fneg double %308
%310 = call double @llvm.fmuladd.f64(double %304, double %305, double %309)
%311 = load double, double* %20
%312 = load double, double* %19
%313 = fsub double %311, %312
%314 = fdiv double %310, %313
store double %314, double* %23
%315 = load double, double* %15
%316 = load double, double* %13
%317 = load double, double* %11
%318 = load double, double* %17
%319 = fmul double %317, %318
%320 = fneg double %319
%321 = call double @llvm.fmuladd.f64(double %315, double %316, double %320)
%322 = load double, double* %21
%323 = load double, double* %19
%324 = fsub double %322, %323
%325 = fdiv double %321, %324
store double %325, double* %24
%326 = load double, double* %15
%327 = load double, double* %14
%328 = load double, double* %11
%329 = load double, double* %18
%330 = fmul double %328, %329
%331 = fneg double %330
%332 = call double @llvm.fmuladd.f64(double %326, double %327, double %331)
%333 = load double, double* %22
%334 = load double, double* %19
%335 = fsub double %333, %334
%336 = fdiv double %332, %335
store double %336, double* %25
%337 = load double, double* %23
%338 = load double, double* %13
%339 = load double, double* %12
%340 = load double, double* %24
%341 = fmul double %339, %340
%342 = fneg double %341
%343 = call double @llvm.fmuladd.f64(double %337, double %338, double %342)
%344 = load double, double* %21
%345 = load double, double* %20
%346 = fsub double %344, %345
%347 = fdiv double %343, %346
store double %347, double* %26
%348 = load double, double* %23
%349 = load double, double* %14
%350 = load double, double* %12
%351 = load double, double* %25
%352 = fmul double %350, %351
%353 = fneg double %352
%354 = call double @llvm.fmuladd.f64(double %348, double %349, double %353)
%355 = load double, double* %22
%356 = load double, double* %20
%357 = fsub double %355, %356
%358 = fdiv double %354, %357
store double %358, double* %27
%359 = load double, double* %26
%360 = load double, double* %14
%361 = load double, double* %13
%362 = load double, double* %27
%363 = fmul double %361, %362
%364 = fneg double %363
%365 = call double @llvm.fmuladd.f64(double %359, double %360, double %364)
%366 = load double, double* %22
%367 = load double, double* %21
%368 = fsub double %366, %367
%369 = fdiv double %365, %368
store double %369, double* %28
br label %370
370: ; preds = %243, %90
br label %371
371: ; preds = %370, %61
br label %372
372: ; preds = %371, %51
br label %373
373: ; preds = %372, %38
%374 = load double, double* %28
ret double %374
}

LLVM IR (-O2):
define double @interp1d(double %0, double* %1, double* nocapture %2, i32 %3, i32* nocapture %4) {
%6 = icmp eq i32 %3, 1
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = load double, double* %1
%9 = fcmp ult double %8, %0
br i1 %9, label %12, label %10
10: ; preds = %7, %5
%11 = load double, double* %2
br label %163
12: ; preds = %7
%13 = add nsw i32 %3, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %1, i64 %14
%16 = load double, double* %15
%17 = fcmp ugt double %16, %0
br i1 %17, label %21, label %18
18: ; preds = %12
%19 = getelementptr inbounds double, double* %2, i64 %14
%20 = load double, double* %19
br label %163
21: ; preds = %12
switch i32 %3, label %66 [
i32 2, label %22
i32 3, label %34
]
22: ; preds = %21
%23 = getelementptr inbounds double, double* %1, i64 1
%24 = load double, double* %23
%25 = fsub double %24, %0
%26 = fsub double %24, %8
%27 = fdiv double %25, %26
%28 = fsub double 1.000000e+00, %0
%29 = load double, double* %2
%30 = getelementptr inbounds double, double* %2, i64 1
%31 = load double, double* %30
%32 = fmul double %28, %31
%33 = tail call double @llvm.fmuladd.f64(double %29, double %27, double %32)
br label %163
34: ; preds = %21
%35 = fsub double %8, %0
%36 = getelementptr inbounds double, double* %1, i64 1
%37 = bitcast double* %36 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = insertelement <2 x double> poison, double %0, i64 0
%40 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> zeroinitializer
%41 = fsub <2 x double> %38, %40
%42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%43 = load double, double* %2
%44 = getelementptr inbounds double, double* %2, i64 1
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = fneg <2 x double> %46
%48 = insertelement <2 x double> poison, double %35, i64 0
%49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> zeroinitializer
%50 = fmul <2 x double> %49, %47
%51 = insertelement <2 x double> poison, double %43, i64 0
%52 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> zeroinitializer
%53 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %41, <2 x double> %50)
%54 = fmul <2 x double> %42, %53
%55 = insertelement <2 x double> poison, double %8, i64 0
%56 = shufflevector <2 x double> %55, <2 x double> poison, <2 x i32> zeroinitializer
%57 = fsub <2 x double> %38, %56
%58 = fdiv <2 x double> %54, %57
%59 = shufflevector <2 x double> %58, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%60 = fsub <2 x double> %58, %59
%61 = extractelement <2 x double> %60, i64 0
%62 = shufflevector <2 x double> %38, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%63 = fsub <2 x double> %62, %38
%64 = extractelement <2 x double> %63, i64 0
%65 = fdiv double %61, %64
br label %163
66: ; preds = %21
%67 = load i32, i32* %4
%68 = icmp slt i32 %67, 1
br i1 %68, label %84, label %69
69: ; preds = %66
%70 = add nsw i32 %3, -3
%71 = icmp sgt i32 %67, %70
br i1 %71, label %84, label %72
72: ; preds = %69
%73 = add nsw i32 %67, -1
%74 = zext i32 %73 to i64
%75 = getelementptr inbounds double, double* %1, i64 %74
%76 = load double, double* %75
%77 = fcmp ogt double %76, %0
br i1 %77, label %84, label %78
78: ; preds = %72
%79 = add nuw nsw i32 %67, 2
%80 = zext i32 %79 to i64
%81 = getelementptr inbounds double, double* %1, i64 %80
%82 = load double, double* %81
%83 = fcmp olt double %82, %0
br i1 %83, label %84, label %86
84: ; preds = %78, %72, %69, %66
%85 = tail call i32 (double, double*, i32, ...) bitcast (i32 (...)* @BinarySearch to i32 (double, double*, i32, ...)*)(double %0, double* %1, i32 %3)
br label %107
86: ; preds = %78
%87 = fcmp ugt double %76, %0
br i1 %87, label %96, label %88
88: ; preds = %86
%89 = zext i32 %67 to i64
%90 = getelementptr inbounds double, double* %1, i64 %89
%91 = load double, double* %90
%92 = fcmp ogt double %91, %0
br i1 %92, label %93, label %96
93: ; preds = %88
%94 = icmp ugt i32 %67, 1
%95 = select i1 %94, i32 %73, i32 1
br label %107
96: ; preds = %88, %86
%97 = add nuw nsw i32 %67, 1
%98 = zext i32 %97 to i64
%99 = getelementptr inbounds double, double* %1, i64 %98
%100 = load double, double* %99
%101 = fcmp ugt double %100, %0
br i1 %101, label %107, label %102
102: ; preds = %96
%103 = fcmp oge double %82, %0
%104 = icmp slt i32 %67, %70
%105 = select i1 %103, i1 %104, i1 false
%106 = select i1 %105, i32 %97, i32 %67
br label %107
107: ; preds = %102, %93, %96, %84
%108 = phi i32 [ %85, %84 ], [ %67, %96 ], [ %95, %93 ], [ %106, %102 ]
store i32 %108, i32* %4
%109 = add nsw i32 %108, -1
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds double, double* %1, i64 %110
%112 = load double, double* %111
%113 = sext i32 %108 to i64
%114 = getelementptr inbounds double, double* %1, i64 %113
%115 = load double, double* %114
%116 = add nsw i32 %108, 1
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %1, i64 %117
%119 = load double, double* %118
%120 = add nsw i32 %108, 2
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %1, i64 %121
%123 = load double, double* %122
%124 = getelementptr inbounds double, double* %2, i64 %110
%125 = load double, double* %124
%126 = getelementptr inbounds double, double* %2, i64 %113
%127 = load double, double* %126
%128 = getelementptr inbounds double, double* %2, i64 %117
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %2, i64 %121
%131 = load double, double* %130
%132 = fsub double %112, %0
%133 = fsub double %115, %0
%134 = fsub double %119, %0
%135 = fsub double %123, %0
%136 = fneg double %132
%137 = fmul double %127, %136
%138 = tail call double @llvm.fmuladd.f64(double %125, double %133, double %137)
%139 = fsub double %115, %112
%140 = fdiv double %138, %139
%141 = fmul double %129, %136
%142 = tail call double @llvm.fmuladd.f64(double %125, double %134, double %141)
%143 = fsub double %119, %112
%144 = fdiv double %142, %143
%145 = fmul double %131, %136
%146 = tail call double @llvm.fmuladd.f64(double %125, double %135, double %145)
%147 = fsub double %123, %112
%148 = fdiv double %146, %147
%149 = fneg double %133
%150 = fmul double %144, %149
%151 = tail call double @llvm.fmuladd.f64(double %140, double %134, double %150)
%152 = fsub double %119, %115
%153 = fdiv double %151, %152
%154 = fmul double %148, %149
%155 = tail call double @llvm.fmuladd.f64(double %140, double %135, double %154)
%156 = fsub double %123, %115
%157 = fdiv double %155, %156
%158 = fneg double %134
%159 = fmul double %157, %158
%160 = tail call double @llvm.fmuladd.f64(double %153, double %135, double %159)
%161 = fsub double %123, %119
%162 = fdiv double %160, %161
br label %163
163: ; preds = %18, %34, %107, %22, %10
%164 = phi double [ %11, %10 ], [ %20, %18 ], [ %33, %22 ], [ %65, %34 ], [ %162, %107 ]
ret double %164
}