#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);
int /*<<< orphan*/ spline_coef(int, double *, double *, double *, double *,
                               double *);
int /*<<< orphan*/ spline_eval(int, double *, double *, int, double *, double *,
                               double *, double *, double *);
void spline(int n, double *x, double *y, int nu, double *xi, double *yi) {
  double *b = malloc(sizeof(double) * (n));
  double *c = malloc(sizeof(double) * (n));
  double *d = malloc(sizeof(double) * (n));
  spline_coef(n, x, y, b, c, d);
  spline_eval(nu, xi, yi, n, x, y, b, c, d);
  free(b);
  free(c);
  free(d);
  return;
}


x86 assembly (clang, -O0):
<spline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
call   1050 <spline_coef@plt>
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    -0x38(%rbp),%r11
mov    -0x40(%rbp),%r10
mov    -0x48(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <spline_eval@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    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,0x18(%rsp)
mov    %ecx,0xc(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,%r13
mov    %edi,%ebp
lea    0x0(,%rbp,8),%ebx
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    %r13,%rsi
mov    0x10(%rsp),%rbx
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r14,%r8
mov    %rax,%r9
call   1050 <spline_coef@plt>
sub    $0x8,%rsp
mov    0x14(%rsp),%edi
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    %ebp,%ecx
mov    %r13,%r8
mov    %rbx,%r9
push   %r15
push   %r14
push   %r12
call   1040 <spline_eval@plt>
add    $0x20,%rsp
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @spline(i32 %0, double* %1, double* %2, i32 %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
store i32 %0, i32* %7
store double* %1, double** %8
store double* %2, double** %9
store i32 %3, i32* %10
store double* %4, double** %11
store double* %5, double** %12
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = mul i64 8, %17
%19 = trunc i64 %18 to i32
%20 = call double* @malloc(i32 %19)
store double* %20, double** %13
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = mul i64 8, %22
%24 = trunc i64 %23 to i32
%25 = call double* @malloc(i32 %24)
store double* %25, double** %14
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = mul i64 8, %27
%29 = trunc i64 %28 to i32
%30 = call double* @malloc(i32 %29)
store double* %30, double** %15
%31 = load i32, i32* %7
%32 = load double*, double** %8
%33 = load double*, double** %9
%34 = load double*, double** %13
%35 = load double*, double** %14
%36 = load double*, double** %15
%37 = call i32 @spline_coef(i32 %31, double* %32, double* %33, double* %34, double* %35, double* %36)
%38 = load i32, i32* %10
%39 = load double*, double** %11
%40 = load double*, double** %12
%41 = load i32, i32* %7
%42 = load double*, double** %8
%43 = load double*, double** %9
%44 = load double*, double** %13
%45 = load double*, double** %14
%46 = load double*, double** %15
%47 = call i32 @spline_eval(i32 %38, double* %39, double* %40, i32 %41, double* %42, double* %43, double* %44, double* %45, double* %46)
%48 = load double*, double** %13
%49 = call i32 @free(double* %48)
%50 = load double*, double** %14
%51 = call i32 @free(double* %50)
%52 = load double*, double** %15
%53 = call i32 @free(double* %52)
ret void
}

LLVM IR (-O2):
define void @spline(i32 %0, double* %1, double* %2, i32 %3, double* %4, double* %5) {
%7 = shl i32 %0, 3
%8 = tail call double* @malloc(i32 %7)
%9 = tail call double* @malloc(i32 %7)
%10 = tail call double* @malloc(i32 %7)
%11 = tail call i32 @spline_coef(i32 %0, double* %1, double* %2, double* %8, double* %9, double* %10)
%12 = tail call i32 @spline_eval(i32 %3, double* %4, double* %5, i32 %0, double* %1, double* %2, double* %8, double* %9, double* %10)
%13 = tail call i32 @free(double* %8)
%14 = tail call i32 @free(double* %9)
%15 = tail call i32 @free(double* %10)
ret void
}