// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../external/HyRec2020/hyrectools.c
// Function: rec_interp2d
double rec_interp2d(double x10, double dx1, double x20, double dx2, double **ytab,
  unsigned int Nx1, unsigned int Nx2, double x1, double x2, int *error, char error_message[SIZE_ErrorM]) {

  int j;
  long ix1;
  double frac1;
  double temp[4];
  char sub_message[128];
  if (*error == 1) return 0.;

  /* Check if in range in x1 */
  if (x1<x10 || x1>x10+dx1*(Nx1-1)) {
    sprintf(sub_message,"x-value out of range in interpolation in rec_interp2d.\n"); 
    strcat(error_message, sub_message);
    *error = 1;
    return 0.;
  }

  /* Identify location to interpolate in x1 */
  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;  

  /* Get values interpolated over x2 at the 4 neighboring points in x1 */
  for(j=0;j<4;j++) temp[j] = rec_interp1d(x20,dx2,ytab[j],Nx2,x2, error, error_message);

  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.
  );
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movsd %xmm0, 0x108(%rsp)
movsd %xmm1, 0x100(%rsp)
movsd %xmm2, 0xf8(%rsp)
movsd %xmm3, 0xf0(%rsp)
movq %rdi, 0xe8(%rsp)
movl %esi, 0xe4(%rsp)
movl %edx, 0xe0(%rsp)
movsd %xmm4, 0xd8(%rsp)
movsd %xmm5, 0xd0(%rsp)
movq %rcx, 0xc8(%rsp)
movq %r8, 0xc0(%rsp)
movq 0xc8(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x1a5f41
xorps %xmm0, %xmm0
movsd %xmm0, 0x110(%rsp)
jmp 0x1a6273
movsd 0xd8(%rsp), %xmm1
movsd 0x108(%rsp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x1a5f90
movsd 0xd8(%rsp), %xmm0
movsd 0x108(%rsp), %xmm2
movsd 0x100(%rsp), %xmm1
movl 0xe4(%rsp), %eax
decl %eax
cvtsi2sd %rax, %xmm3
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1a5fd0
movq %rsp, %rdi
leaq 0x686d3(%rip), %rsi     # 0x20e66d
movb $0x0, %al
callq 0x8090
movq 0xc0(%rsp), %rdi
movq %rsp, %rsi
callq 0x8660
movq 0xc8(%rsp), %rax
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x110(%rsp)
jmp 0x1a6273
movsd 0xd8(%rsp), %xmm0
subsd 0x108(%rsp), %xmm0
divsd 0x100(%rsp), %xmm0
callq 0x85d0
cvttsd2si %xmm0, %rax
movq %rax, 0xb0(%rsp)
cmpq $0x1, 0xb0(%rsp)
jge 0x1a6014
movq $0x1, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
movl 0xe4(%rsp), %ecx
subl $0x3, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jle 0x1a6041
movl 0xe4(%rsp), %eax
subl $0x3, %eax
movl %eax, %eax
movq %rax, 0xb0(%rsp)
movsd 0xd8(%rsp), %xmm0
subsd 0x108(%rsp), %xmm0
divsd 0x100(%rsp), %xmm0
cvtsi2sdq 0xb0(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
subq $0x1, %rax
shlq $0x3, %rax
addq 0xe8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movl $0x0, 0xbc(%rsp)
cmpl $0x4, 0xbc(%rsp)
jge 0x1a6117
movsd 0xf8(%rsp), %xmm0
movsd 0xf0(%rsp), %xmm1
movq 0xe8(%rsp), %rax
movslq 0xbc(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movl 0xe0(%rsp), %esi
movsd 0xd0(%rsp), %xmm2
movq 0xc8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
callq 0x1a5ae0
movslq 0xbc(%rsp), %rax
movsd %xmm0, 0x80(%rsp,%rax,8)
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
jmp 0x1a609e
movsd 0x80(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd 0xa8(%rsp), %xmm0
movsd 0x2c100(%rip), %xmm1    # 0x1d2248
subsd 0xa8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x2cb23(%rip), %xmm1    # 0x1d2c80
subsd 0xa8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x2d516(%rip), %xmm1    # 0x1d3688
divsd %xmm1, %xmm0
movsd 0x88(%rsp), %xmm1
movsd 0x2c0c1(%rip), %xmm2    # 0x1d2248
addsd 0xa8(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2c0ac(%rip), %xmm2    # 0x1d2248
subsd 0xa8(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2cacf(%rip), %xmm2    # 0x1d2c80
subsd 0xa8(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2caba(%rip), %xmm2    # 0x1d2c80
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd 0x90(%rsp), %xmm1
movsd 0x2c069(%rip), %xmm2    # 0x1d2248
addsd 0xa8(%rsp), %xmm2
mulsd %xmm2, %xmm1
mulsd 0xa8(%rsp), %xmm1
movsd 0x2ca83(%rip), %xmm2    # 0x1d2c80
subsd 0xa8(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2ca6e(%rip), %xmm2    # 0x1d2c80
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd 0x98(%rsp), %xmm1
movsd 0x2c01d(%rip), %xmm2    # 0x1d2248
addsd 0xa8(%rsp), %xmm2
mulsd %xmm2, %xmm1
mulsd 0xa8(%rsp), %xmm1
movsd 0xa8(%rsp), %xmm2
movsd 0x2bff6(%rip), %xmm3    # 0x1d2248
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm1
movsd 0x2d426(%rip), %xmm2    # 0x1d3688
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x110(%rsp)
movsd 0x110(%rsp), %xmm0
addq $0x118, %rsp            # imm = 0x118
retq
nopw %cs:(%rax,%rax)