// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xd8, %rsp
movsd %xmm0, 0xc8(%rsp)
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movl %edx, 0xb4(%rsp)
movq %rcx, 0xa8(%rsp)
movq %r8, 0xa0(%rsp)
movq 0xa8(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x1a62e5
xorps %xmm0, %xmm0
movsd %xmm0, 0xd0(%rsp)
jmp 0x1a6802
cmpl $0x4, 0xb4(%rsp)
jae 0x1a6333
leaq 0x20(%rsp), %rdi
leaq 0x683aa(%rip), %rsi     # 0x20e6a5
movb $0x0, %al
callq 0x8090
movq 0xa0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8660
movq 0xa8(%rsp), %rax
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0xd0(%rsp)
jmp 0x1a6802
movq 0xc0(%rsp), %rax
movsd (%rax), %xmm0
movq 0xc0(%rsp), %rax
ucomisd 0x8(%rax), %xmm0
jbe 0x1a6392
leaq 0x20(%rsp), %rdi
leaq 0x68389(%rip), %rsi     # 0x20e6e3
movb $0x0, %al
callq 0x8090
movq 0xa0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8660
movq 0xa8(%rsp), %rax
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0xd0(%rsp)
jmp 0x1a6802
movsd 0xc8(%rsp), %xmm1
movq 0xc0(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
ja 0x1a63d1
movsd 0xc8(%rsp), %xmm0
movq 0xc0(%rsp), %rax
movl 0xb4(%rsp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
ucomisd (%rax,%rcx,8), %xmm0
jb 0x1a6415
leaq 0x20(%rsp), %rdi
leaq 0x6833f(%rip), %rsi     # 0x20e71c
movb $0x0, %al
callq 0x8090
movq 0xa0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8660
movq 0xa8(%rsp), %rax
movl $0x1, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0xd0(%rsp)
jmp 0x1a6802
movq $0x0, 0x10(%rsp)
movl 0xb4(%rsp), %eax
subl $0x1, %eax
movl %eax, %eax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
subq 0x10(%rsp), %rax
cmpq $0x1, %rax
jle 0x1a64a7
movq 0x8(%rsp), %rax
addq 0x10(%rsp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, (%rsp)
movsd 0xc8(%rsp), %xmm0
movq 0xc0(%rsp), %rax
movq (%rsp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jb 0x1a647c
movq (%rsp), %rax
movq %rax, 0x10(%rsp)
movsd 0xc8(%rsp), %xmm1
movq 0xc0(%rsp), %rax
movq (%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1a64a5
movq (%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x1a642f
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x1, 0x18(%rsp)
jge 0x1a64c2
movq $0x1, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl 0xb4(%rsp), %ecx
subl $0x3, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jle 0x1a64e9
movl 0xb4(%rsp), %eax
subl $0x3, %eax
movl %eax, %eax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
subq $0x1, %rax
shlq $0x3, %rax
addq 0xc0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x18(%rsp), %rax
subq $0x1, %rax
shlq $0x3, %rax
addq 0xb8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
movsd (%rax), %xmm0
movsd 0xc8(%rsp), %xmm1
movq 0xc0(%rsp), %rax
subsd 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0xc8(%rsp), %xmm1
movq 0xc0(%rsp), %rax
subsd 0x10(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0xc8(%rsp), %xmm1
movq 0xc0(%rsp), %rax
subsd 0x18(%rax), %xmm1
mulsd %xmm1, %xmm0
movq 0xc0(%rsp), %rax
movsd (%rax), %xmm1
movq 0xc0(%rsp), %rax
subsd 0x8(%rax), %xmm1
divsd %xmm1, %xmm0
movq 0xc0(%rsp), %rax
movsd (%rax), %xmm1
movq 0xc0(%rsp), %rax
subsd 0x10(%rax), %xmm1
divsd %xmm1, %xmm0
movq 0xc0(%rsp), %rax
movsd (%rax), %xmm1
movq 0xc0(%rsp), %rax
subsd 0x18(%rax), %xmm1
divsd %xmm1, %xmm0
movq 0xb8(%rsp), %rax
movsd 0x8(%rax), %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd (%rax), %xmm2
mulsd %xmm2, %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x10(%rax), %xmm2
mulsd %xmm2, %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x18(%rax), %xmm2
mulsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x8(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd (%rax), %xmm2
divsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x8(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x10(%rax), %xmm2
divsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x8(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x18(%rax), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0xb8(%rsp), %rax
movsd 0x10(%rax), %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd (%rax), %xmm2
mulsd %xmm2, %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x18(%rax), %xmm2
mulsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x10(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd (%rax), %xmm2
divsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x10(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x8(%rax), %xmm2
divsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x10(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x18(%rax), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0xb8(%rsp), %rax
movsd 0x18(%rax), %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd (%rax), %xmm2
mulsd %xmm2, %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm1
movsd 0xc8(%rsp), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x10(%rax), %xmm2
mulsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x18(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd (%rax), %xmm2
divsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x18(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x8(%rax), %xmm2
divsd %xmm2, %xmm1
movq 0xc0(%rsp), %rax
movsd 0x18(%rax), %xmm2
movq 0xc0(%rsp), %rax
subsd 0x10(%rax), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0xd0(%rsp), %xmm0
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)