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

  char sub_message[128];
  if (*error == 1) return 0.;
  
  if (Nx < 4) {
    sprintf(sub_message, "Table needs to be of dimension 4 at least in rec_interpol_G.\n");
    strcat(error_message, sub_message);
    *error = 1;
    return 0.;
  }
  if (xtab[0] > xtab[1]) {
    sprintf(sub_message, "Array does not seem to be increasing in rec_interpol_G.\n");
    strcat(error_message, sub_message);
    *error = 1;
    return 0.;
  }
  if (x < xtab[0] || x >= xtab[Nx-1]) {
    sprintf(sub_message, "x-value out of range in rec_interpol_G.\n");
    strcat(error_message, sub_message);
    *error = 1;
    return 0.;
  }
  
  long int ix;
  long int ilo = 0;
  long int ihi = Nx-1;
  long int imid; 

  while (ihi - ilo > 1) {
    imid = (ihi + ilo)/2;
    if (x >= xtab[imid]) ilo = imid;
    if (x < xtab[imid]) ihi = imid;     
  }
  
  ix = ilo;
 
  if (ix<1) ix = 1; 
  if (ix>Nx-3) ix = Nx-3;
  xtab += ix-1;
  ytab += ix-1;

  /* Return value */
  return(
     ytab[0] *(x-xtab[1])*(x-xtab[2])*(x-xtab[3])
             /(xtab[0]-xtab[1])/(xtab[0]-xtab[2])/(xtab[0]-xtab[3])
           + ytab[1] *(x-xtab[0])*(x-xtab[2])*(x-xtab[3])
             /(xtab[1]-xtab[0])/(xtab[1]-xtab[2])/(xtab[1]-xtab[3])
           + ytab[2] *(x-xtab[0])*(x-xtab[1])*(x-xtab[3])
             /(xtab[2]-xtab[0])/(xtab[2]-xtab[1])/(xtab[2]-xtab[3])
           + ytab[3] *(x-xtab[0])*(x-xtab[1])*(x-xtab[2])
             /(xtab[3]-xtab[0])/(xtab[3]-xtab[1])/(xtab[3]-xtab[2])	 
  );
}

// Assembly:
pushq %rbx
subq $0x80, %rsp
movq %rcx, %rbx
xorpd %xmm1, %xmm1
cmpl $0x1, (%rcx)
je 0xcc528
movl %edx, %ecx
cmpl $0x3, %edx
ja 0xcc473
movups 0x54b95(%rip), %xmm0    # 0x120fde
movq %rsp, %rsi
movups %xmm0, 0x2e(%rsi)
movups 0x54b79(%rip), %xmm0    # 0x120fd0
movaps %xmm0, 0x20(%rsi)
movups 0x54b5e(%rip), %xmm0    # 0x120fc0
movaps %xmm0, 0x10(%rsi)
movupd 0x54b42(%rip), %xmm0    # 0x120fb0
jmp 0xcc512
movsd (%rdi), %xmm1
ucomisd 0x8(%rdi), %xmm1
jbe 0xcc4ac
movups 0x54b92(%rip), %xmm0    # 0x121017
movq %rsp, %rsi
movups %xmm0, 0x29(%rsi)
movups 0x54b7b(%rip), %xmm0    # 0x12100e
movaps %xmm0, 0x20(%rsi)
movups 0x54b60(%rip), %xmm0    # 0x120ffe
movaps %xmm0, 0x10(%rsi)
movupd 0x54b44(%rip), %xmm0    # 0x120fee
jmp 0xcc512
ucomisd %xmm0, %xmm1
ja 0xcc4f1
leal -0x1(%rcx), %r9d
ucomisd (%rdi,%r9,8), %xmm0
jae 0xcc4f1
xorl %r8d, %r8d
pushq $0x2
popq %r10
movq %r9, %rax
subq %r8, %rax
cmpq $0x2, %rax
jl 0xcc535
leaq (%r9,%r8), %rax
cqto
idivq %r10
movsd (%rdi,%rax,8), %xmm1
ucomisd %xmm1, %xmm0
cmovaeq %rax, %r8
ucomisd %xmm0, %xmm1
cmovaq %rax, %r9
jmp 0xcc4c5
movups 0x54b48(%rip), %xmm0    # 0x121040
movq %rsp, %rsi
movups %xmm0, 0x19(%rsi)
movups 0x54b31(%rip), %xmm0    # 0x121037
movaps %xmm0, 0x10(%rsi)
movupd 0x54b15(%rip), %xmm0    # 0x121027
movapd %xmm0, (%rsi)
movq %r8, %rdi
callq 0x8690
xorpd %xmm1, %xmm1
movl $0x1, (%rbx)
movapd %xmm1, %xmm0
addq $0x80, %rsp
popq %rbx
retq
cmpq $0x2, %r8
pushq $0x1
popq %rax
cmovgeq %r8, %rax
addl $-0x3, %ecx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
movupd -0x8(%rdi,%rax,8), %xmm3
movupd 0x8(%rdi,%rax,8), %xmm1
movapd %xmm1, %xmm2
shufpd $0x1, %xmm1, %xmm2      # xmm2 = xmm2[1],xmm1[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm0, %xmm4
subpd %xmm2, %xmm4
movapd %xmm3, %xmm5
shufpd $0x1, %xmm3, %xmm5      # xmm5 = xmm5[1],xmm3[0]
subpd %xmm5, %xmm0
movupd -0x8(%rsi,%rax,8), %xmm6
movupd 0x8(%rsi,%rax,8), %xmm8
mulpd %xmm0, %xmm6
movapd %xmm3, %xmm7
subpd %xmm5, %xmm7
movapd %xmm0, %xmm9
unpckhpd %xmm0, %xmm9            # xmm9 = xmm9[1],xmm0[1]
mulpd %xmm8, %xmm9
movapd %xmm4, %xmm5
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm9, %xmm0
mulpd %xmm4, %xmm0
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
mulpd %xmm6, %xmm4
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm4, %xmm5
divpd %xmm7, %xmm5
movapd %xmm1, %xmm4
unpcklpd %xmm1, %xmm4            # xmm4 = xmm4[0],xmm1[0]
movapd %xmm3, %xmm6
subpd %xmm4, %xmm6
divpd %xmm6, %xmm5
movapd %xmm1, %xmm4
unpckhpd %xmm1, %xmm4            # xmm4 = xmm4[1],xmm1[1]
movapd %xmm3, %xmm6
subpd %xmm4, %xmm6
divpd %xmm6, %xmm5
movapd %xmm3, %xmm4
unpcklpd %xmm3, %xmm4            # xmm4 = xmm4[0],xmm3[0]
movapd %xmm1, %xmm6
subpd %xmm4, %xmm6
divpd %xmm6, %xmm0
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
movapd %xmm1, %xmm4
subpd %xmm3, %xmm4
divpd %xmm4, %xmm0
subpd %xmm2, %xmm1
divpd %xmm1, %xmm0
movapd %xmm5, %xmm1
unpckhpd %xmm5, %xmm1            # xmm1 = xmm1[1],xmm5[1]
addsd %xmm5, %xmm1
addsd %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movapd %xmm0, %xmm1
jmp 0xcc528
nop