#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free(double *);
double *malloc(int);
void spline_construct(double *x, double *y, double *d, int n) {
  int i;
  double tmp;
  double *diag_low;
  double *diag_mid;
  double *diag_up;
  double *right;
  diag_low = malloc((n - 1) * sizeof(double));
  diag_mid = malloc(n * sizeof(double));
  diag_up = malloc((n - 1) * sizeof(double));
  right = malloc(n * sizeof(double));
  diag_mid[0] = 2 * (x[1] - x[0]);
  diag_up[0] = (x[1] - x[0]);
  right[0] = 3 * (y[1] - y[0]);
  for (i = 1; i < n - 1; i++) {
    diag_low[i - 1] = (x[i] - x[i - 1]);
    diag_mid[i] = 2 * (x[i] - x[i - 1]) + 2 * (x[i + 1] - x[i]);
    diag_up[i] = (x[i + 1] - x[i]);
    right[i] = 3 * (y[i + 1] - y[i - 1]);
  }
  diag_low[n - 2] = (x[n - 1] - x[n - 2]);
  diag_mid[n - 1] = 2 * (x[n - 1] - x[n - 2]);
  right[n - 1] = 3 * (y[n - 1] - y[n - 2]);
  diag_up[0] /= diag_mid[0];
  right[0] /= diag_mid[0];
  for (i = 1; i < n; i++) {
    tmp = 1.0 / (diag_mid[i] - diag_up[i - 1] * diag_low[i - 1]);
    if (i < n - 1)
      diag_up[i] *= tmp;
    right[i] = (right[i] - right[i - 1] * diag_low[i - 1]) * tmp;
  }
  d[n - 1] = right[n - 1];
  for (i = n - 2; i >= 0; i--) {
    d[i] = right[i] - diag_up[i] * d[i + 1];
  }
  free(diag_low);
  free(diag_mid);
  free(diag_up);
  free(right);
}


x86 assembly (clang, -O0):
<spline_construct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm1
movsd  0xe64(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
movsd  0xe1e(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    130d <spline_construct+0x1ed>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
movsd  0xd8b(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm1
movsd  0xd12(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11f5 <spline_construct+0xd5>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm1
movsd  0xc99(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm1
movsd  0xc4f(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1503 <spline_construct+0x3e3>
mov    -0x38(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xbae(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1493 <spline_construct+0x373>
movsd  -0x28(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x20(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x48(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    13fe <spline_construct+0x2de>
mov    -0x48(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     15a0 <spline_construct+0x480>
mov    -0x48(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x40(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    1530 <spline_construct+0x410>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spline_construct>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebx
mov    %rdx,0x8(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r14
lea    -0x1(%rbx),%eax
mov    %eax,(%rsp)
cltq
mov    %rax,0x10(%rsp)
lea    -0x8(,%rbx,8),%r13d
ff
mov    %r13d,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
lea    0x0(,%rbx,8),%edi
mov    %edi,0x4(%rsp)
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %r13d,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    0x4(%rsp),%edi
call   1040 <malloc@plt>
mov    %rbx,%r8
mov    %rax,%rbx
movsd  (%r14),%xmm4
movsd  0x8(%r14),%xmm1
movapd %xmm1,%xmm0
subsd  %xmm4,%xmm0
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%r12)
movsd  0x0(%rbp),%xmm2
movsd  0x8(%rbp),%xmm3
subsd  %xmm2,%xmm3
mulsd  0xe41(%rip),%xmm3
movsd  %xmm3,(%rax)
cmp    $0x3,%r8d
jl     1247 <spline_construct+0x127>
mov    (%rsp),%eax
lea    -0x10(,%rax,8),%rax
ff
xor    %ecx,%ecx
movsd  0xe22(%rip),%xmm3
xchg   %ax,%ax
movapd %xmm1,%xmm5
movapd %xmm1,%xmm6
subsd  %xmm4,%xmm6
movsd  %xmm6,(%r15,%rcx,1)
movsd  0x10(%r14,%rcx,1),%xmm1
movapd %xmm1,%xmm4
subsd  %xmm5,%xmm4
movsd  %xmm4,0x8(%r13,%rcx,1)
addsd  %xmm4,%xmm4
addsd  %xmm6,%xmm6
addsd  %xmm4,%xmm6
movsd  %xmm6,0x8(%r12,%rcx,1)
movsd  0x10(%rbp,%rcx,1),%xmm4
subsd  %xmm2,%xmm4
mulsd  %xmm3,%xmm4
movsd  %xmm4,0x8(%rbx,%rcx,1)
cmp    %rcx,%rax
je     1247 <spline_construct+0x127>
movsd  0x8(%r14,%rcx,1),%xmm4
movsd  0x8(%rbp,%rcx,1),%xmm2
add    $0x8,%rcx
jmp    11e0 <spline_construct+0xc0>
mov    0x10(%rsp),%rdi
movsd  (%r14,%rdi,8),%xmm1
movslq %r8d,%rax
subsd  -0x10(%r14,%rax,8),%xmm1
movsd  %xmm1,-0x10(%r15,%rax,8)
addsd  %xmm1,%xmm1
movsd  %xmm1,(%r12,%rdi,8)
movsd  0x0(%rbp,%rdi,8),%xmm1
subsd  -0x10(%rbp,%rax,8),%xmm1
mulsd  0xd7f(%rip),%xmm1
movsd  %xmm1,(%rbx,%rdi,8)
movsd  (%rbx),%xmm1
unpcklpd %xmm0,%xmm1
movsd  (%r12),%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movhpd %xmm1,0x0(%r13)
movlpd %xmm1,(%rbx)
cmp    $0x1,%r8d
jle    133d <spline_construct+0x21d>
lea    -0x2(%r8),%eax
mov    %r8d,%edx
mov    $0x2,%ecx
sub    %rdx,%rcx
mov    $0x1,%edx
movsd  0xd3c(%rip),%xmm0
nopl   0x0(%rax)
movsd  (%r12,%rdx,8),%xmm4
movsd  -0x8(%r15,%rdx,8),%xmm3
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm4
movapd %xmm0,%xmm2
divsd  %xmm4,%xmm2
cmp    %rdi,%rdx
jge    130c <spline_construct+0x1ec>
movsd  0x0(%r13,%rdx,8),%xmm4
mulsd  %xmm2,%xmm4
movsd  %xmm4,0x0(%r13,%rdx,8)
movsd  (%rbx,%rdx,8),%xmm4
mulsd  %xmm3,%xmm1
subsd  %xmm1,%xmm4
mulsd  %xmm4,%xmm2
movsd  %xmm2,(%rbx,%rdx,8)
lea    (%rcx,%rdx,1),%rsi
cmp    $0x1,%rsi
je     134e <spline_construct+0x22e>
movhpd 0x0(%r13,%rdx,8),%xmm2
add    $0x1,%rdx
movapd %xmm2,%xmm1
jmp    12d0 <spline_construct+0x1b0>
movsd  (%rbx,%rdi,8),%xmm0
mov    0x8(%rsp),%rax
movsd  %xmm0,(%rax,%rdi,8)
jmp    13cc <spline_construct+0x2ac>
movsd  (%rbx,%rdi,8),%xmm0
mov    0x8(%rsp),%rdx
movsd  %xmm0,(%rdx,%rdi,8)
cmp    $0x2,%r8d
jl     13cc <spline_construct+0x2ac>
mov    %eax,%ecx
test   $0x1,%al
jne    1388 <spline_construct+0x268>
movsd  0x0(%r13,%rcx,8),%xmm0
mulsd  0x8(%rdx,%rcx,8),%xmm0
movsd  (%rbx,%rcx,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rcx,8)
add    $0xffffffffffffffff,%rcx
test   %eax,%eax
je     13cc <spline_construct+0x2ac>
nopl   0x0(%rax)
movsd  (%rbx,%rcx,8),%xmm0
movsd  0x0(%r13,%rcx,8),%xmm1
mulsd  0x8(%rdx,%rcx,8),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%rcx,8)
movsd  -0x8(%rbx,%rcx,8),%xmm1
mulsd  -0x8(%r13,%rcx,8),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,-0x8(%rdx,%rcx,8)
add    $0xfffffffffffffffe,%rcx
cmp    $0xffffffffffffffff,%rcx
jne    1390 <spline_construct+0x270>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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