// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../external/HyRec2020/hyrectools.c
// Function: rec_interp1d
double rec_interp1d(double x0, double dx, double *ytab, unsigned int Nx, double x, int *error, char error_message[SIZE_ErrorM]) {

  long ix;
  double frac;
  char sub_message[128];
  if (*error == 1) return 0.;

  /* Check if in range */
  if (dx > 0 && (x<x0 || x>x0+dx*(Nx-1))) {
    sprintf(sub_message,"x-value out of range in interpolation in rec_interp1d.\n");
    strcat(error_message, sub_message);
    *error = 1;
    return 0.;
  }
  if (dx < 0 && (x>x0 || x<x0+dx*(Nx-1))) {
    sprintf(sub_message,"x-value out of range in interpolation in rec_interp1d.\n"); 
    strcat(error_message, sub_message);
    *error = 1;
    return 0.;
  }

  /* Identify location to interpolate */
  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 value */
  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*(1.-frac)/6.
  );
}

// Assembly:
subq $0xd8, %rsp
movsd %xmm0, 0xc8(%rsp)
movsd %xmm1, 0xc0(%rsp)
movq %rdi, 0xb8(%rsp)
movl %esi, 0xb4(%rsp)
movsd %xmm2, 0xa8(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rcx, 0x98(%rsp)
movq 0xa0(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x1a5b3f
xorps %xmm0, %xmm0
movsd %xmm0, 0xd0(%rsp)
jmp 0x1a5eab
movsd 0xc0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1a5be4
movsd 0xa8(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x1a5ba4
movsd 0xa8(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm2
movsd 0xc0(%rsp), %xmm1
movl 0xb4(%rsp), %eax
decl %eax
cvtsi2sd %rax, %xmm3
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1a5be4
movq %rsp, %rdi
leaq 0x68a87(%rip), %rsi     # 0x20e635
movb $0x0, %al
callq 0x8090
movq 0x98(%rsp), %rdi
movq %rsp, %rsi
callq 0x8660
movq 0xa0(%rsp), %rax
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0xd0(%rsp)
jmp 0x1a5eab
xorps %xmm0, %xmm0
ucomisd 0xc0(%rsp), %xmm0
jbe 0x1a5c81
movsd 0xa8(%rsp), %xmm0
ucomisd 0xc8(%rsp), %xmm0
ja 0x1a5c41
movsd 0xa8(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm2
movsd 0xc0(%rsp), %xmm0
movl 0xb4(%rsp), %eax
decl %eax
cvtsi2sd %rax, %xmm3
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1a5c81
movq %rsp, %rdi
leaq 0x689ea(%rip), %rsi     # 0x20e635
movb $0x0, %al
callq 0x8090
movq 0x98(%rsp), %rdi
movq %rsp, %rsi
callq 0x8660
movq 0xa0(%rsp), %rax
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0xd0(%rsp)
jmp 0x1a5eab
movsd 0xa8(%rsp), %xmm0
subsd 0xc8(%rsp), %xmm0
divsd 0xc0(%rsp), %xmm0
callq 0x85d0
cvttsd2si %xmm0, %rax
movq %rax, 0x90(%rsp)
cmpq $0x1, 0x90(%rsp)
jge 0x1a5cc5
movq $0x1, 0x90(%rsp)
movq 0x90(%rsp), %rax
movl 0xb4(%rsp), %ecx
subl $0x3, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jle 0x1a5cf2
movl 0xb4(%rsp), %eax
subl $0x3, %eax
movl %eax, %eax
movq %rax, 0x90(%rsp)
movsd 0xa8(%rsp), %xmm0
subsd 0xc8(%rsp), %xmm0
divsd 0xc0(%rsp), %xmm0
cvtsi2sdq 0x90(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movq 0x90(%rsp), %rax
subq $0x1, %rax
shlq $0x3, %rax
addq 0xb8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd 0x88(%rsp), %xmm0
movsd 0x2c4d0(%rip), %xmm1    # 0x1d2248
subsd 0x88(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x2cef3(%rip), %xmm1    # 0x1d2c80
subsd 0x88(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x2d8e6(%rip), %xmm1    # 0x1d3688
divsd %xmm1, %xmm0
movq 0xb8(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x2c48d(%rip), %xmm2    # 0x1d2248
addsd 0x88(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2c478(%rip), %xmm2    # 0x1d2248
subsd 0x88(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2ce9b(%rip), %xmm2    # 0x1d2c80
subsd 0x88(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2ce86(%rip), %xmm2    # 0x1d2c80
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0xb8(%rsp), %rax
movsd 0x10(%rax), %xmm1
movsd 0x2c431(%rip), %xmm2    # 0x1d2248
addsd 0x88(%rsp), %xmm2
mulsd %xmm2, %xmm1
mulsd 0x88(%rsp), %xmm1
movsd 0x2ce4b(%rip), %xmm2    # 0x1d2c80
subsd 0x88(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2ce36(%rip), %xmm2    # 0x1d2c80
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0xb8(%rsp), %rax
movsd 0x18(%rax), %xmm1
movsd 0x2c3e1(%rip), %xmm2    # 0x1d2248
addsd 0x88(%rsp), %xmm2
mulsd %xmm2, %xmm1
mulsd 0x88(%rsp), %xmm1
movsd 0x2c3c3(%rip), %xmm2    # 0x1d2248
subsd 0x88(%rsp), %xmm2
mulsd %xmm2, %xmm1
movsd 0x2d7ee(%rip), %xmm2    # 0x1d3688
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0xd0(%rsp), %xmm0
addq $0xd8, %rsp
retq
nopl (%rax)