#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int spline_findix(double, double const *, int);
double spline_int(double xp, const double xs[], const double ys[],
                  const double zs[], int n) {
  double dx, t, ct, tct, ctmt, zL, zR, dA, Ax, yL, yR;
  int i;
  i = spline_findix(xp, xs, n);
  if (i < 0) {
    printf("spline_int: xp is out of range.\n");
    exit(1);
  }
  dx = xs[i + 1] - xs[i];
  t = (xp - xs[i]) / dx;
  if (t < 0 || t > 1) {
    printf(
        "spline_int: Extrapolating? t=%7.4f, xp=%7.4f, xs[%i]=%7.4f,dx=%7.4f\n",
        t, xp, i, xs[i], dx);
  }
  ct = 1 - t;
  tct = t * ct;
  ctmt = ct - t;
  zL = zs[i];
  zR = zs[i + 1];
  dA = (zR - zL) / 6.0;
  Ax = (zR + zL) / 4.0 - ctmt * dA / 2.0;
  yL = ys[i];
  yR = ys[i + 1];
  double q = yL * ct + yR * t - tct * dx * dx * Ax;
  return q;
}


x86 assembly (clang, -O0):
<spline_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <spline_findix@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    118b <spline_int+0x5b>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x84(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
ja     11f9 <spline_int+0xc9>
movsd  -0x38(%rbp),%xmm0
movsd  0xe11(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    122c <spline_int+0xfc>
movsd  -0x38(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0x84(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    0xe1c(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
movsd  0xdcc(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x84(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  0xd7b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  0xd58(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x50(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
movsd  0xd3a(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x84(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x78(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x80(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spline_int>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm0,(%rsp)
mov    %ecx,%esi
call   1050 <spline_findix@plt>
test   %eax,%eax
js     1258 <spline_int+0x118>
mov    %eax,%r12d
lea    0x1(%r12),%r13
movsd  (%rbx,%r12,8),%xmm2
movsd  0x8(%rbx,%r12,8),%xmm3
subsd  %xmm2,%xmm3
movsd  (%rsp),%xmm1
movapd %xmm1,%xmm6
subsd  %xmm2,%xmm6
divsd  %xmm3,%xmm6
xorpd  %xmm0,%xmm0
ucomisd %xmm6,%xmm0
ja     11a8 <spline_int+0x68>
ucomisd 0xe5a(%rip),%xmm6
jbe    11d2 <spline_int+0x92>
lea    0xe71(%rip),%rdi
movapd %xmm6,%xmm0
mov    %eax,%esi
mov    $0x4,%al
movsd  %xmm3,(%rsp)
movsd  %xmm6,0x8(%rsp)
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm6
movsd  (%rsp),%xmm3
movsd  0xe26(%rip),%xmm1
subsd  %xmm6,%xmm1
movapd %xmm1,%xmm0
subsd  %xmm6,%xmm0
movsd  (%r15,%r12,8),%xmm2
movsd  (%r15,%r13,8),%xmm5
movapd %xmm5,%xmm4
subsd  %xmm2,%xmm4
divsd  0xe06(%rip),%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm5,%xmm2
mulsd  0xdfe(%rip),%xmm2
mulsd  0xdfe(%rip),%xmm4
addsd  %xmm2,%xmm4
movsd  (%r14,%r13,8),%xmm2
mulsd  %xmm6,%xmm2
movsd  (%r14,%r12,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm6,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm4,%xmm1
subsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe06(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"spline_int: xp is out of range.\0A\00"
@.str.1 = [69 x i8] c"spline_int: Extrapolating? t=%7.4f, xp=%7.4f, xs[%i]=%7.4f,dx=%7.4f\0A\00"
define double @spline_int(double %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%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 i32
%23 = alloca double
store double %0, double* %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
%24 = load double, double* %6
%25 = load double*, double** %7
%26 = load i32, i32* %10
%27 = call i32 @spline_findix(double %24, double* %25, i32 %26)
store i32 %27, i32* %22
%28 = load i32, i32* %22
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %5
%34 = load double*, double** %7
%35 = load i32, i32* %22
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %34, i64 %37
%39 = load double, double* %38
%40 = load double*, double** %7
%41 = load i32, i32* %22
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = fsub double %39, %44
store double %45, double* %11
%46 = load double, double* %6
%47 = load double*, double** %7
%48 = load i32, i32* %22
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = fsub double %46, %51
%53 = load double, double* %11
%54 = fdiv double %52, %53
store double %54, double* %12
%55 = load double, double* %12
%56 = fcmp olt double %55, 0.000000e+00
br i1 %56, label %60, label %57
57: ; preds = %33
%58 = load double, double* %12
%59 = fcmp ogt double %58, 1.000000e+00
br i1 %59, label %60, label %71
60: ; preds = %57, %33
%61 = load double, double* %12
%62 = load double, double* %6
%63 = load i32, i32* %22
%64 = load double*, double** %7
%65 = load i32, i32* %22
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = load double, double* %11
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), double %61, double %62, i32 %63, double %68, double %69)
br label %71
71: ; preds = %60, %57
%72 = load double, double* %12
%73 = fsub double 1.000000e+00, %72
store double %73, double* %13
%74 = load double, double* %12
%75 = load double, double* %13
%76 = fmul double %74, %75
store double %76, double* %14
%77 = load double, double* %13
%78 = load double, double* %12
%79 = fsub double %77, %78
store double %79, double* %15
%80 = load double*, double** %9
%81 = load i32, i32* %22
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
store double %84, double* %16
%85 = load double*, double** %9
%86 = load i32, i32* %22
%87 = add nsw i32 %86, 1
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %85, i64 %88
%90 = load double, double* %89
store double %90, double* %17
%91 = load double, double* %17
%92 = load double, double* %16
%93 = fsub double %91, %92
%94 = fdiv double %93, 6.000000e+00
store double %94, double* %18
%95 = load double, double* %17
%96 = load double, double* %16
%97 = fadd double %95, %96
%98 = fdiv double %97, 4.000000e+00
%99 = load double, double* %15
%100 = load double, double* %18
%101 = fmul double %99, %100
%102 = fdiv double %101, 2.000000e+00
%103 = fsub double %98, %102
store double %103, double* %19
%104 = load double*, double** %8
%105 = load i32, i32* %22
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %104, i64 %106
%108 = load double, double* %107
store double %108, double* %20
%109 = load double*, double** %8
%110 = load i32, i32* %22
%111 = add nsw i32 %110, 1
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds double, double* %109, i64 %112
%114 = load double, double* %113
store double %114, double* %21
%115 = load double, double* %20
%116 = load double, double* %13
%117 = load double, double* %21
%118 = load double, double* %12
%119 = fmul double %117, %118
%120 = call double @llvm.fmuladd.f64(double %115, double %116, double %119)
%121 = load double, double* %14
%122 = load double, double* %11
%123 = fmul double %121, %122
%124 = load double, double* %11
%125 = fmul double %123, %124
%126 = load double, double* %19
%127 = fneg double %125
%128 = call double @llvm.fmuladd.f64(double %127, double %126, double %120)
store double %128, double* %23
%129 = load double, double* %23
ret double %129
}

LLVM IR (-O2):
@.str.1 = [69 x i8] c"spline_int: Extrapolating? t=%7.4f, xp=%7.4f, xs[%i]=%7.4f,dx=%7.4f\0A\00"
@str = [32 x i8] c"spline_int: xp is out of range.\00"
define double @spline_int(double %0, double* %1, double* nocapture %2, double* nocapture %3, i32 %4) {
%6 = tail call i32 @spline_findix(double %0, double* %1, i32 %4)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %5
%12 = add nuw nsw i32 %6, 1
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds double, double* %1, i64 %13
%15 = load double, double* %14
%16 = zext i32 %6 to i64
%17 = getelementptr inbounds double, double* %1, i64 %16
%18 = load double, double* %17
%19 = fsub double %15, %18
%20 = fsub double %0, %18
%21 = fdiv double %20, %19
%22 = fcmp olt double %21, 0.000000e+00
%23 = fcmp ogt double %21, 1.000000e+00
%24 = or i1 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %11
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), double %21, double %0, i32 %6, double %18, double %19)
br label %27
27: ; preds = %11, %25
%28 = fsub double 1.000000e+00, %21
%29 = fsub double %28, %21
%30 = getelementptr inbounds double, double* %3, i64 %16
%31 = load double, double* %30
%32 = getelementptr inbounds double, double* %3, i64 %13
%33 = load double, double* %32
%34 = fsub double %33, %31
%35 = fdiv double %34, 6.000000e+00
%36 = fadd double %31, %33
%37 = fmul double %36, 2.500000e-01
%38 = fmul double %29, %35
%39 = fmul double %38, 5.000000e-01
%40 = fsub double %37, %39
%41 = getelementptr inbounds double, double* %2, i64 %16
%42 = load double, double* %41
%43 = getelementptr inbounds double, double* %2, i64 %13
%44 = load double, double* %43
%45 = fmul double %21, %44
%46 = tail call double @llvm.fmuladd.f64(double %42, double %28, double %45)
%47 = fneg double %21
%48 = fmul double %28, %47
%49 = fmul double %19, %48
%50 = fmul double %19, %49
%51 = tail call double @llvm.fmuladd.f64(double %50, double %40, double %46)
ret double %51
}