#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);
void spline_intd3(double xp, const double xs[], const double ys[],
                  const double zs[], int n, double *q, double *dq1, double *dq2,
                  double *dq3) {
  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_intd3: 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_intd3: 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];
  *q = yL * ct + yR * t - tct * dx * dx * Ax;
  *dq1 = (yR - yL) / dx - dx * (ctmt * Ax + tct * dA);
  *dq2 = 2 * (Ax - ctmt * dA);
  *dq3 = (zR - zL) / dx;
}


x86 assembly (clang, -O0):
<spline_intd3>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <spline_findix@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
jge    119b <spline_intd3+0x6b>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
ja     1209 <spline_intd3+0xd9>
movsd  -0x48(%rbp),%xmm0
movsd  0xe01(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    123c <spline_intd3+0x10c>
movsd  -0x48(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0x94(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x40(%rbp),%xmm3
lea    0xe0e(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
movsd  0xdbc(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  0xd6b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  0xd48(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x60(%rbp),%xmm1
mulsd  -0x78(%rbp),%xmm1
movsd  0xd2a(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x50(%rbp),%xmm2
movsd  -0x90(%rbp),%xmm0
ff
mulsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x90(%rbp),%xmm1
ff
subsd  -0x88(%rbp),%xmm1
ff
divsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x80(%rbp),%xmm4
movsd  -0x58(%rbp),%xmm3
mulsd  -0x78(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x80(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xbf8(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x70(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spline_intd3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,%r15
mov    %rdx,%r13
mov    %rsi,%r12
mov    %rdi,%rbx
movsd  %xmm0,(%rsp)
mov    %ecx,%esi
call   1050 <spline_findix@plt>
test   %eax,%eax
js     12d6 <spline_intd3+0x196>
mov    0x58(%rsp),%rcx
mov    0x50(%rsp),%rdx
mov    %eax,%ebp
lea    0x1(%rbp),%r14
movsd  (%rbx,%rbp,8),%xmm2
movsd  0x8(%rbx,%rbp,8),%xmm3
subsd  %xmm2,%xmm3
movsd  (%rsp),%xmm4
movapd %xmm4,%xmm0
subsd  %xmm2,%xmm0
divsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm4,%xmm1
ja     11bb <spline_intd3+0x7b>
ucomisd 0xe47(%rip),%xmm0
jbe    11ec <spline_intd3+0xac>
lea    0xe5e(%rip),%rdi
mov    %eax,%esi
mov    $0x4,%al
mov    %rdx,%rbx
movsd  %xmm3,(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm3
mov    %rbx,%rdx
mov    0x58(%rsp),%rcx
movsd  0xe0c(%rip),%xmm5
subsd  %xmm0,%xmm5
movapd %xmm0,%xmm9
movsd  0x0(%r13,%rbp,8),%xmm7
movsd  0x0(%r13,%r14,8),%xmm1
movapd %xmm1,%xmm11
subsd  %xmm7,%xmm11
movapd %xmm11,%xmm6
divsd  0xde6(%rip),%xmm6
mulsd  %xmm5,%xmm9
movapd %xmm5,%xmm2
addsd  %xmm1,%xmm7
mulsd  0xdd9(%rip),%xmm7
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm10
mulsd  %xmm6,%xmm10
movsd  0xdcb(%rip),%xmm4
mulsd  %xmm10,%xmm4
addsd  %xmm7,%xmm4
movsd  (%r12,%rbp,8),%xmm8
movsd  (%r12,%r14,8),%xmm7
mulsd  %xmm7,%xmm0
mulsd  %xmm8,%xmm5
addsd  %xmm0,%xmm5
movapd %xmm3,%xmm1
mulsd  %xmm9,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm4,%xmm1
subsd  %xmm1,%xmm5
movsd  %xmm5,(%r15)
subsd  %xmm8,%xmm7
divsd  %xmm3,%xmm7
mulsd  %xmm9,%xmm6
mulsd  %xmm4,%xmm2
addsd  %xmm6,%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm2,%xmm7
mov    0x10(%rsp),%rax
movsd  %xmm7,(%rax)
subsd  %xmm10,%xmm4
addsd  %xmm4,%xmm4
movsd  %xmm4,(%rdx)
divsd  %xmm3,%xmm11
movsd  %xmm11,(%rcx)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd8a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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

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