#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);
scalar_t__ floor(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double rec_interp1d(double x0, double dx, double *ytab, unsigned int Nx,
                    double x) {
  long ix;
  double frac;
  if (dx > 0 && (x < x0 || x > x0 + dx * (Nx - 1))) {
    fprintf(stderr, "Error: rec_interp1d: x-value out of range in "
                    "interpolation routine.\n");
    exit(1);
  }
  if (dx < 0 && (x > x0 || x < x0 + dx * (Nx - 1))) {
    fprintf(stderr, "Error: rec_interp1d: x-value out of range in "
                    "interpolation routine.\n");
    exit(1);
  }
  ix = (long)floor((x - x0) / dx);
  if (ix < 1)
    ix = 1;
  if (ix > Nx - 3)
    ix = Nx - 3;
  frac = (x - x0) / dx - ix;
  ytab += ix - 1;
  return (-ytab[0] * frac * (1. - frac) * (2. - frac) / 6. +
          ytab[1] * (1. + frac) * (1. - frac) * (2. - frac) / 2. +
          ytab[2] * (1. + frac) * frac * (2. - frac) / 2. +
          ytab[3] * (1. + frac) * frac * (frac - 1.) / 6.);
}


x86 assembly (clang, -O0):
<rec_interp1d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11bf <rec_interp1d+0x8f>
movsd  -0x28(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     11a0 <rec_interp1d+0x70>
movsd  -0x28(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
cvtsi2sd %rax,%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11bf <rec_interp1d+0x8f>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1228 <rec_interp1d+0xf8>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
ja     1209 <rec_interp1d+0xd9>
movsd  -0x28(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
cvtsi2sd %rax,%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    1228 <rec_interp1d+0xf8>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1050 <floor@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x1,-0x30(%rbp)
jge    1253 <rec_interp1d+0x123>
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x3,%ecx
mov    %ecx,%ecx
cmp    %rcx,%rax
jle    1274 <rec_interp1d+0x144>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
mov    %eax,%eax
mov    %rax,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
cvtsi2sdq -0x30(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xd36(%rip),%xmm1
subsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd2d(%rip),%xmm1
subsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd0c(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  0xcff(%rip),%xmm2
addsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xcee(%rip),%xmm2
subsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xce5(%rip),%xmm2
subsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xcd4(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm1
movsd  0xcb3(%rip),%xmm2
addsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  0xca5(%rip),%xmm2
subsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xc94(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm1
movsd  0xc73(%rip),%xmm2
addsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  0xc58(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xc40(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rec_interp1d>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm1
jbe    116a <rec_interp1d+0x3a>
ucomisd %xmm2,%xmm0
ja     127b <rec_interp1d+0x14b>
lea    -0x1(%rbx),%eax
cvtsi2sd %rax,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
ucomisd %xmm3,%xmm2
ja     127b <rec_interp1d+0x14b>
ucomisd %xmm1,%xmm4
jbe    1197 <rec_interp1d+0x67>
ucomisd %xmm0,%xmm2
ja     127b <rec_interp1d+0x14b>
lea    -0x1(%rbx),%eax
xorps  %xmm3,%xmm3
cvtsi2sd %rax,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
ucomisd %xmm2,%xmm3
ja     127b <rec_interp1d+0x14b>
subsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
movapd %xmm2,(%rsp)
movapd %xmm2,%xmm0
call   1050 <floor@plt>
test   %rax,%rax
mov    $0x1,%ecx
cmovg  %rax,%rcx
add    $0xfffffffd,%ebx
cmp    %rbx,%rcx
cmova  %rbx,%rcx
xorps  %xmm0,%xmm0
cvtsi2sd %rcx,%xmm0
movapd (%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  -0x8(%r14,%rcx,8),%xmm3
mulsd  %xmm2,%xmm3
movsd  0xe19(%rip),%xmm7
movapd %xmm7,%xmm4
subsd  %xmm2,%xmm4
mulsd  %xmm4,%xmm3
movsd  0xe0d(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm3
movsd  0xe04(%rip),%xmm8
addsd  %xmm2,%xmm7
movupd (%r14,%rcx,8),%xmm5
movapd %xmm7,%xmm6
unpcklpd %xmm7,%xmm6
mulpd  %xmm5,%xmm6
unpcklpd %xmm2,%xmm4
movapd %xmm2,%xmm0
mulpd  %xmm6,%xmm4
unpcklpd %xmm1,%xmm1
mulpd  %xmm4,%xmm1
mulpd  0xde2(%rip),%xmm1
divsd  %xmm8,%xmm3
movapd %xmm1,%xmm4
subsd  %xmm3,%xmm4
mulsd  0x10(%r14,%rcx,8),%xmm7
unpckhpd %xmm1,%xmm1
mulsd  %xmm2,%xmm7
addsd  0xdb6(%rip),%xmm0
addsd  %xmm4,%xmm1
mulsd  %xmm7,%xmm0
divsd  %xmm8,%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
lea    0xda5(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [69 x i8] c"Error: rec_interp1d: x-value out of range in interpolation routine.\0A\00"
define double @rec_interp1d(double %0, double %1, double* nocapture %2, i32 %3, double %4) {
%6 = fcmp ogt double %1, 0.000000e+00
br i1 %6, label %7, label %18
7: ; preds = %5
%8 = fcmp olt double %4, %0
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = add i32 %3, -1
%11 = uitofp i32 %10 to double
%12 = tail call double @llvm.fmuladd.f64(double %1, double %11, double %0)
%13 = fcmp olt double %12, %4
br i1 %13, label %14, label %18
14: ; preds = %9, %7
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %9, %5
%19 = fcmp olt double %1, 0.000000e+00
br i1 %19, label %20, label %31
20: ; preds = %18
%21 = fcmp ogt double %4, %0
br i1 %21, label %27, label %22
22: ; preds = %20
%23 = add i32 %3, -1
%24 = uitofp i32 %23 to double
%25 = tail call double @llvm.fmuladd.f64(double %1, double %24, double %0)
%26 = fcmp ogt double %25, %4
br i1 %26, label %27, label %31
27: ; preds = %22, %20
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %22, %18
%32 = fsub double %4, %0
%33 = fdiv double %32, %1
%34 = tail call i64 @floor(double %33)
%35 = icmp sgt i64 %34, 1
%36 = select i1 %35, i64 %34, i64 1
%37 = add i32 %3, -3
%38 = zext i32 %37 to i64
%39 = icmp ugt i64 %36, %38
%40 = select i1 %39, i64 %38, i64 %36
%41 = sitofp i64 %40 to double
%42 = fsub double %33, %41
%43 = add nsw i64 %40, -1
%44 = getelementptr inbounds double, double* %2, i64 %43
%45 = load double, double* %44
%46 = fneg double %45
%47 = fmul double %42, %46
%48 = fsub double 1.000000e+00, %42
%49 = fmul double %47, %48
%50 = fsub double 2.000000e+00, %42
%51 = fmul double %50, %49
%52 = fdiv double %51, 6.000000e+00
%53 = getelementptr inbounds double, double* %2, i64 %40
%54 = fadd double %42, 1.000000e+00
%55 = bitcast double* %53 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = insertelement <2 x double> poison, double %54, i64 0
%58 = shufflevector <2 x double> %57, <2 x double> poison, <2 x i32> zeroinitializer
%59 = fmul <2 x double> %56, %58
%60 = insertelement <2 x double> poison, double %48, i64 0
%61 = insertelement <2 x double> %60, double %42, i64 1
%62 = fmul <2 x double> %61, %59
%63 = insertelement <2 x double> poison, double %50, i64 0
%64 = shufflevector <2 x double> %63, <2 x double> poison, <2 x i32> zeroinitializer
%65 = fmul <2 x double> %64, %62
%66 = fmul <2 x double> %65, <double 5.000000e-01, double 5.000000e-01>
%67 = extractelement <2 x double> %66, i64 0
%68 = fadd double %52, %67
%69 = extractelement <2 x double> %66, i64 1
%70 = fadd double %69, %68
%71 = getelementptr inbounds double, double* %44, i64 3
%72 = load double, double* %71
%73 = fmul double %72, %54
%74 = fmul double %42, %73
%75 = fadd double %42, -1.000000e+00
%76 = fmul double %75, %74
%77 = fdiv double %76, 6.000000e+00
%78 = fadd double %77, %70
ret double %78
}