#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 *);
double rec_interp1d(double, double, double *, unsigned int, double);
int /*<<< orphan*/ stderr;
double rec_interp2d(double x10, double dx1, double x20, double dx2,
                    double **ytab, unsigned int Nx1, unsigned int Nx2,
                    double x1, double x2) {
  int j;
  long ix1;
  double frac1;
  double temp[4];
  if (x1 < x10 || x1 > x10 + dx1 * (Nx1 - 1)) {
    fprintf(stderr, "Error: rec_interp2d: x1-value out of range in "
                    "interpolation routine.\n");
    exit(1);
  }
  ix1 = (long)floor((x1 - x10) / dx1);
  if (ix1 < 1)
    ix1 = 1;
  if (ix1 > Nx1 - 3)
    ix1 = Nx1 - 3;
  frac1 = (x1 - x10) / dx1 - ix1;
  ytab += ix1 - 1;
  for (j = 0; j < 4; j++)
    temp[j] = rec_interp1d(x20, dx2, ytab[j], Nx2, x2);
  return (-temp[0] * frac1 * (1. - frac1) * (2. - frac1) / 6. +
          temp[1] * (1. + frac1) * (1. - frac1) * (2. - frac1) / 2. +
          temp[2] * (1. + frac1) * frac1 * (2. - frac1) / 2. +
          temp[3] * (1. + frac1) * frac1 * (frac1 - 1.) / 6.);
}


x86 assembly (clang, -O0):
<rec_interp2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %edx,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
movsd  %xmm5,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     11b3 <rec_interp2d+0x73>
movsd  -0x38(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
cvtsi2sd %rax,%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11d2 <rec_interp2d+0x92>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movsd  -0x38(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1060 <floor@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x1,-0x50(%rbp)
jge    11fd <rec_interp2d+0xbd>
movq   $0x1,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x3,%ecx
mov    %ecx,%ecx
cmp    %rcx,%rax
jle    121e <rec_interp2d+0xde>
mov    -0x2c(%rbp),%eax
sub    $0x3,%eax
mov    %eax,%eax
mov    %rax,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
cvtsi2sdq -0x50(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x50(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x4,-0x44(%rbp)
jge    129c <rec_interp2d+0x15c>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%esi
movsd  -0x40(%rbp),%xmm2
call   1030 <rec_interp1d@plt>
movslq -0x44(%rbp),%rax
movsd  %xmm0,-0x80(%rbp,%rax,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1257 <rec_interp2d+0x117>
movsd  -0x80(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  0xd43(%rip),%xmm1
subsd  -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd3a(%rip),%xmm1
subsd  -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd19(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x78(%rbp),%xmm1
movsd  0xd10(%rip),%xmm2
addsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xcff(%rip),%xmm2
subsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xcf6(%rip),%xmm2
subsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xce5(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  0xcc8(%rip),%xmm2
addsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  0xcba(%rip),%xmm2
subsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xca9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  0xc8c(%rip),%xmm2
addsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  -0x58(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  0xc71(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xc59(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rec_interp2d>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
movsd  %xmm5,0x18(%rsp)
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
ucomisd %xmm4,%xmm0
ja     12fe <rec_interp2d+0x1be>
mov    %esi,%ebp
lea    -0x1(%rbp),%eax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
ucomisd %xmm2,%xmm4
ja     12fe <rec_interp2d+0x1be>
mov    %edx,%r14d
mov    %rdi,%r15
subsd  %xmm0,%xmm4
divsd  %xmm1,%xmm4
movapd %xmm4,0x40(%rsp)
movapd %xmm4,%xmm0
call   1060 <floor@plt>
test   %rax,%rax
mov    $0x1,%ebx
cmovg  %rax,%rbx
add    $0xfffffffd,%ebp
cmp    %rbp,%rbx
cmova  %rbp,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
movsd  %xmm0,0x28(%rsp)
mov    -0x8(%r15,%rbx,8),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %r14d,%esi
movsd  0x18(%rsp),%xmm2
call   1030 <rec_interp1d@plt>
movsd  %xmm0,0x20(%rsp)
mov    (%r15,%rbx,8),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %r14d,%esi
movsd  0x18(%rsp),%xmm2
call   1030 <rec_interp1d@plt>
movaps %xmm0,0x50(%rsp)
mov    0x8(%r15,%rbx,8),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %r14d,%esi
movsd  0x18(%rsp),%xmm2
call   1030 <rec_interp1d@plt>
movaps %xmm0,0x30(%rsp)
mov    0x10(%r15,%rbx,8),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %r14d,%esi
movsd  0x18(%rsp),%xmm2
call   1030 <rec_interp1d@plt>
movapd 0x40(%rsp),%xmm5
subsd  0x28(%rsp),%xmm5
movsd  0x20(%rsp),%xmm6
mulsd  %xmm5,%xmm6
movsd  0xd91(%rip),%xmm3
movapd %xmm3,%xmm2
subsd  %xmm5,%xmm2
mulsd  %xmm2,%xmm6
movsd  0xd85(%rip),%xmm1
subsd  %xmm5,%xmm1
mulsd  %xmm1,%xmm6
movsd  0xd7d(%rip),%xmm4
divsd  %xmm4,%xmm6
addsd  %xmm5,%xmm3
mulsd  %xmm3,%xmm0
unpcklpd %xmm3,%xmm3
movapd 0x50(%rsp),%xmm7
unpcklpd 0x30(%rsp),%xmm7
mulpd  %xmm3,%xmm7
unpcklpd %xmm5,%xmm2
mulpd  %xmm7,%xmm2
unpcklpd %xmm1,%xmm1
mulpd  %xmm2,%xmm1
mulpd  0xd55(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm6,%xmm2
unpckhpd %xmm1,%xmm1
mulsd  %xmm5,%xmm0
addsd  0xd35(%rip),%xmm5
addsd  %xmm2,%xmm1
mulsd  %xmm5,%xmm0
divsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xd22(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

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

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