#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 */
double pow(double, int);
int /*<<< orphan*/ printf(char *, double);
int eval_spline(double *data, double *spline, int n_point, double x,
                double *y) {
  int i;
  int col = 2;
  double hi0;
  double xi0;
  double xi1;
  double fi0;
  double fi1;
  double d2f0;
  double d2f1;
  i = 0;
  if ((x < data[0]) || (x > data[0 + (n_point - 1) * col])) {
    printf("Out of range: %f\n", x);
    return -1;
  }
  for (i = 0; x > data[0 + i * col]; i++)
    ;
  xi0 = data[0 + (i - 1) * col];
  xi1 = data[0 + i * col];
  hi0 = xi1 - xi0;
  fi0 = data[1 + (i - 1) * col];
  fi1 = data[1 + i * col];
  d2f0 = spline[i - 1];
  d2f1 = spline[i];
  *y = -d2f0 * pow(x - xi1, 3) / (6 * hi0) +
       d2f1 * pow(x - xi0, 3) / (6 * hi0) -
       (fi0 / hi0 - hi0 * d2f0 / 6) * (x - xi1) +
       (fi1 / hi0 - hi0 * d2f1 / 6) * (x - xi0);
  return 0;
}


x86 assembly (clang, -O0):
<eval_spline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
movl   $0x2,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
ja     1188 <eval_spline+0x68>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x38(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    11a5 <eval_spline+0x85>
movsd  -0x28(%rbp),%xmm0
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13bd <eval_spline+0x29d>
movl   $0x0,-0x34(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    11e0 <eval_spline+0xc0>
jmp    11d2 <eval_spline+0xb2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ac <eval_spline+0x8c>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x38(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  0xd27(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
mov    $0x3,%edi
call   1040 <pow@plt>
movsd  -0x80(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm2,%xmm1
movsd  0xce2(%rip),%xmm2
mulsd  -0x40(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm1
divsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mulsd  -0x68(%rbp),%xmm2
movsd  0xcb9(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm2
subsd  -0x50(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  -0x70(%rbp),%xmm2
movsd  0xc6c(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm0
movsd  -0x28(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_spline>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movapd %xmm0,%xmm1
movsd  (%rdi),%xmm0
ucomisd %xmm1,%xmm0
ja     1144 <eval_spline+0x24>
lea    (%rdx,%rdx,1),%eax
add    $0xfffffffe,%eax
cltq
ucomisd (%rdi,%rax,8),%xmm1
jbe    115e <eval_spline+0x3e>
lea    0xebd(%rip),%rdi
movapd %xmm1,%xmm0
call   1030 <printf@plt>
mov    $0xffffffff,%eax
jmp    12c6 <eval_spline+0x1a6>
mov    %rcx,%r14
mov    $0xffffffffffffffff,%rax
mov    $0xfffffffc,%edx
mov    $0xfffffffffffffffe,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x10(%rdi,%rcx,8),%xmm3
add    $0x1,%rax
add    $0x2,%edx
add    $0x2,%rcx
ucomisd %xmm3,%xmm1
ja     1180 <eval_spline+0x60>
lea    -0x1(%rax),%ebx
movslq %edx,%rdx
movsd  (%rdi,%rdx,8),%xmm0
movsd  %xmm0,0x40(%rsp)
movapd %xmm3,%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
add    $0x1,%edx
movslq %edx,%rdx
movsd  (%rdi,%rdx,8),%xmm2
movsd  %xmm2,0x48(%rsp)
mov    %ecx,%ecx
shl    $0x3,%rcx
or     $0x8,%rcx
movsd  (%rdi,%rcx,1),%xmm2
movsd  %xmm2,0x50(%rsp)
movslq %ebx,%rcx
movsd  (%rsi,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %eax,%eax
movsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,0x30(%rsp)
movapd %xmm1,%xmm0
subsd  %xmm3,%xmm0
movsd  %xmm0,0x38(%rsp)
mov    $0x3,%edi
movsd  %xmm1,0x8(%rsp)
call   1040 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0xdd7(%rip),%xmm1
movsd  %xmm1,0x20(%rsp)
divsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x3,%edi
call   1040 <pow@plt>
movsd  0x30(%rsp),%xmm3
mulsd  %xmm3,%xmm0
divsd  0x20(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x48(%rsp),%xmm2
divsd  %xmm1,%xmm2
movsd  0x10(%rsp),%xmm4
mulsd  %xmm1,%xmm4
movsd  0xd73(%rip),%xmm5
divsd  %xmm5,%xmm4
subsd  %xmm4,%xmm2
mulsd  0x38(%rsp),%xmm2
subsd  %xmm2,%xmm0
movsd  0x50(%rsp),%xmm2
divsd  %xmm1,%xmm2
mulsd  %xmm3,%xmm1
divsd  %xmm5,%xmm1
subsd  %xmm1,%xmm2
mulsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%r14)
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Out of range: %f\0A\00"
define i32 @eval_spline(double* %0, double* %1, i32 %2, double %3, double* %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca double*
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store double* %0, double** %7
store double* %1, double** %8
store i32 %2, i32* %9
store double %3, double* %10
store double* %4, double** %11
store i32 2, i32* %13
store i32 0, i32* %12
%21 = load double, double* %10
%22 = load double*, double** %7
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
%25 = fcmp olt double %21, %24
br i1 %25, label %38, label %26
26: ; preds = %5
%27 = load double, double* %10
%28 = load double*, double** %7
%29 = load i32, i32* %9
%30 = sub nsw i32 %29, 1
%31 = load i32, i32* %13
%32 = mul nsw i32 %30, %31
%33 = add nsw i32 0, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %28, i64 %34
%36 = load double, double* %35
%37 = fcmp ogt double %27, %36
br i1 %37, label %38, label %41
38: ; preds = %26, %5
%39 = load double, double* %10
%40 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %39)
store i32 -1, i32* %6
br label %152
41: ; preds = %26
store i32 0, i32* %12
br label %42
42: ; preds = %54, %41
%43 = load double, double* %10
%44 = load double*, double** %7
%45 = load i32, i32* %12
%46 = load i32, i32* %13
%47 = mul nsw i32 %45, %46
%48 = add nsw i32 0, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %44, i64 %49
%51 = load double, double* %50
%52 = fcmp ogt double %43, %51
br i1 %52, label %53, label %57
53: ; preds = %42
br label %54
54: ; preds = %53
%55 = load i32, i32* %12
%56 = add nsw i32 %55, 1
store i32 %56, i32* %12
br label %42
57: ; preds = %42
%58 = load double*, double** %7
%59 = load i32, i32* %12
%60 = sub nsw i32 %59, 1
%61 = load i32, i32* %13
%62 = mul nsw i32 %60, %61
%63 = add nsw i32 0, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %58, i64 %64
%66 = load double, double* %65
store double %66, double* %15
%67 = load double*, double** %7
%68 = load i32, i32* %12
%69 = load i32, i32* %13
%70 = mul nsw i32 %68, %69
%71 = add nsw i32 0, %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %67, i64 %72
%74 = load double, double* %73
store double %74, double* %16
%75 = load double, double* %16
%76 = load double, double* %15
%77 = fsub double %75, %76
store double %77, double* %14
%78 = load double*, double** %7
%79 = load i32, i32* %12
%80 = sub nsw i32 %79, 1
%81 = load i32, i32* %13
%82 = mul nsw i32 %80, %81
%83 = add nsw i32 1, %82
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %78, i64 %84
%86 = load double, double* %85
store double %86, double* %17
%87 = load double*, double** %7
%88 = load i32, i32* %12
%89 = load i32, i32* %13
%90 = mul nsw i32 %88, %89
%91 = add nsw i32 1, %90
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double, double* %87, i64 %92
%94 = load double, double* %93
store double %94, double* %18
%95 = load double*, double** %8
%96 = load i32, i32* %12
%97 = sub nsw i32 %96, 1
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %95, i64 %98
%100 = load double, double* %99
store double %100, double* %19
%101 = load double*, double** %8
%102 = load i32, i32* %12
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %101, i64 %103
%105 = load double, double* %104
store double %105, double* %20
%106 = load double, double* %19
%107 = fneg double %106
%108 = load double, double* %10
%109 = load double, double* %16
%110 = fsub double %108, %109
%111 = call double @pow(double %110, i32 3)
%112 = fmul double %107, %111
%113 = load double, double* %14
%114 = fmul double 6.000000e+00, %113
%115 = fdiv double %112, %114
%116 = load double, double* %20
%117 = load double, double* %10
%118 = load double, double* %15
%119 = fsub double %117, %118
%120 = call double @pow(double %119, i32 3)
%121 = fmul double %116, %120
%122 = load double, double* %14
%123 = fmul double 6.000000e+00, %122
%124 = fdiv double %121, %123
%125 = fadd double %115, %124
%126 = load double, double* %17
%127 = load double, double* %14
%128 = fdiv double %126, %127
%129 = load double, double* %14
%130 = load double, double* %19
%131 = fmul double %129, %130
%132 = fdiv double %131, 6.000000e+00
%133 = fsub double %128, %132
%134 = load double, double* %10
%135 = load double, double* %16
%136 = fsub double %134, %135
%137 = fneg double %133
%138 = call double @llvm.fmuladd.f64(double %137, double %136, double %125)
%139 = load double, double* %18
%140 = load double, double* %14
%141 = fdiv double %139, %140
%142 = load double, double* %14
%143 = load double, double* %20
%144 = fmul double %142, %143
%145 = fdiv double %144, 6.000000e+00
%146 = fsub double %141, %145
%147 = load double, double* %10
%148 = load double, double* %15
%149 = fsub double %147, %148
%150 = call double @llvm.fmuladd.f64(double %146, double %149, double %138)
%151 = load double*, double** %11
store double %150, double* %151
store i32 0, i32* %6
br label %152
152: ; preds = %57, %38
%153 = load i32, i32* %6
ret i32 %153
}

LLVM IR (-O2):
@.str = [18 x i8] c"Out of range: %f\0A\00"
define i32 @eval_spline(double* nocapture %0, double* nocapture %1, i32 %2, double %3, double* nocapture writeonly %4) {
%6 = load double, double* %0
%7 = fcmp ogt double %6, %3
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = shl i32 %2, 1
%10 = add i32 %9, -2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = fcmp olt double %13, %3
br i1 %14, label %15, label %17
15: ; preds = %8, %5
%16 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %3)
br label %68
17: ; preds = %8, %17
%18 = phi i64 [ %23, %17 ], [ 0, %8 ]
%19 = shl nuw nsw i64 %18, 1
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = fcmp olt double %21, %3
%23 = add nuw i64 %18, 1
br i1 %22, label %17, label %24
24: ; preds = %17
%25 = trunc i64 %18 to i32
%26 = add nsw i32 %25, -1
%27 = shl nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %0, i64 %28
%30 = load double, double* %29
%31 = fsub double %21, %30
%32 = or i32 %27, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = load double, double* %34
%36 = and i64 %19, 4294967294
%37 = or i64 %36, 1
%38 = getelementptr inbounds double, double* %0, i64 %37
%39 = load double, double* %38
%40 = sext i32 %26 to i64
%41 = getelementptr inbounds double, double* %1, i64 %40
%42 = load double, double* %41
%43 = and i64 %18, 4294967295
%44 = getelementptr inbounds double, double* %1, i64 %43
%45 = load double, double* %44
%46 = fneg double %42
%47 = fsub double %3, %21
%48 = tail call double @pow(double %47, i32 3)
%49 = fmul double %48, %46
%50 = fmul double %31, 6.000000e+00
%51 = fdiv double %49, %50
%52 = fsub double %3, %30
%53 = tail call double @pow(double %52, i32 3)
%54 = fmul double %45, %53
%55 = fdiv double %54, %50
%56 = fadd double %51, %55
%57 = fdiv double %35, %31
%58 = fmul double %31, %42
%59 = fdiv double %58, 6.000000e+00
%60 = fsub double %57, %59
%61 = fneg double %60
%62 = tail call double @llvm.fmuladd.f64(double %61, double %47, double %56)
%63 = fdiv double %39, %31
%64 = fmul double %31, %45
%65 = fdiv double %64, 6.000000e+00
%66 = fsub double %63, %65
%67 = tail call double @llvm.fmuladd.f64(double %66, double %52, double %62)
store double %67, double* %4
br label %68
68: ; preds = %24, %15
%69 = phi i32 [ -1, %15 ], [ 0, %24 ]
ret i32 %69
}