// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_extrapolate_quadratic
int array_extrapolate_quadratic(double* x, double* y, double xnew, int x_size, double* ynew, double* dynew, ErrorMsg errmsg){

  int i;

  double * xarr = x;
  double * yarr = y;

  double av1=x_size;
  double avx=0.0, avxx=0.0, avxxx=0.0, avxxxx=0.0;
  double avy=0.0, avyx=0.0, avyxx=0.0;

  double div,a,b,c,xval,yval;

  /*
   * We pivot around the zero-th element
   * This removes natural offsets and scales
   * (i.e. transforms it to around unity for x and y)
   * This usually prevents numerical cancelation (offsets) and over/underflow (scales)
   */
  for(i=0;i<x_size;++i){
    xval = (xarr[i]-xarr[0])/xarr[0];
    yval = (yarr[i]-yarr[0])/yarr[0];
    avx += xval;
    avxx += xval*xval;
    avxxx += xval*xval*xval;
    avxxxx += xval*xval*xval*xval;
    avy += yval;
    avyx += yval*xval;
    avyxx += yval*xval*xval;
  }

  div = avxxxx*(avxx*av1-avx*avx) + avxxx*(avxx*avx-avxxx*av1) + avxx*(avxxx*avx-avxx*avxx);
  class_test(div == 0.0,
             errmsg,
             "Cannot extrapolate at x = %g for the given data set",xnew);
  a = avyxx*(avxx*av1-avx*avx) + avyx*(avxx*avx-avxxx*av1) + avy*(avxxx*avx-avxx*avxx);
  b = avyxx*(avxx*avx-avxxx*av1) + avyx*(avxxxx*av1-avxx*avxx) + avy*(avxxx*avxx-avx*avxxxx);
  c = avyxx*(avxxx*avx-avxx*avxx) + avyx*(avxxx*avxx-avxxxx*avx) + avy*(avxxxx*avxx-avxxx*avxxx);

  a/=div; b/=div; c/=div;

  xval = (xnew-xarr[0])/xarr[0];

  *ynew = yarr[0]+yarr[0]*(a*xval*xval + b*xval + c);
  *dynew = yarr[0]*(2.*a/xarr[0]*xval + b/xarr[0]);

  return _SUCCESS_;
}

// Assembly:
subq $0x10c8, %rsp           # imm = 0x10C8
movq %rdi, 0x10b8(%rsp)
movq %rsi, 0x10b0(%rsp)
movsd %xmm0, 0x10a8(%rsp)
movl %edx, 0x10a4(%rsp)
movq %rcx, 0x1098(%rsp)
movq %r8, 0x1090(%rsp)
movq %r9, 0x1088(%rsp)
movq 0x10b8(%rsp), %rax
movq %rax, 0x1078(%rsp)
movq 0x10b0(%rsp), %rax
movq %rax, 0x1070(%rsp)
cvtsi2sdl 0x10a4(%rsp), %xmm0
movsd %xmm0, 0x1068(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1060(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1058(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1050(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1048(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1040(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1038(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1030(%rsp)
movl $0x0, 0x1084(%rsp)
movl 0x1084(%rsp), %eax
cmpl 0x10a4(%rsp), %eax
jge 0x2aedc
movq 0x1078(%rsp), %rax
movslq 0x1084(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1078(%rsp), %rax
subsd (%rax), %xmm0
movq 0x1078(%rsp), %rax
divsd (%rax), %xmm0
movsd %xmm0, 0x1008(%rsp)
movq 0x1070(%rsp), %rax
movslq 0x1084(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1070(%rsp), %rax
subsd (%rax), %xmm0
movq 0x1070(%rsp), %rax
divsd (%rax), %xmm0
movsd %xmm0, 0x1000(%rsp)
movsd 0x1008(%rsp), %xmm0
addsd 0x1060(%rsp), %xmm0
movsd %xmm0, 0x1060(%rsp)
movsd 0x1008(%rsp), %xmm0
movsd 0x1008(%rsp), %xmm2
movsd 0x1058(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1058(%rsp)
movsd 0x1008(%rsp), %xmm0
mulsd 0x1008(%rsp), %xmm0
movsd 0x1008(%rsp), %xmm2
movsd 0x1050(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1050(%rsp)
movsd 0x1008(%rsp), %xmm0
mulsd 0x1008(%rsp), %xmm0
mulsd 0x1008(%rsp), %xmm0
movsd 0x1008(%rsp), %xmm2
movsd 0x1048(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1048(%rsp)
movsd 0x1000(%rsp), %xmm0
addsd 0x1040(%rsp), %xmm0
movsd %xmm0, 0x1040(%rsp)
movsd 0x1000(%rsp), %xmm0
movsd 0x1008(%rsp), %xmm2
movsd 0x1038(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1038(%rsp)
movsd 0x1000(%rsp), %xmm0
mulsd 0x1008(%rsp), %xmm0
movsd 0x1008(%rsp), %xmm2
movsd 0x1030(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1030(%rsp)
movl 0x1084(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1084(%rsp)
jmp 0x2ad10
movsd 0x1048(%rsp), %xmm1
movsd 0x1058(%rsp), %xmm2
movsd 0x1068(%rsp), %xmm3
movsd 0x1060(%rsp), %xmm0
mulsd 0x1060(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm3, %xmm2
addsd %xmm0, %xmm2
movsd 0x1050(%rsp), %xmm0
movsd 0x1058(%rsp), %xmm3
movsd 0x1060(%rsp), %xmm5
movsd 0x1050(%rsp), %xmm4
mulsd 0x1068(%rsp), %xmm4
movq %xmm4, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm4
mulsd %xmm5, %xmm3
addsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x1058(%rsp), %xmm0
movsd 0x1050(%rsp), %xmm2
movsd 0x1060(%rsp), %xmm4
movsd 0x1058(%rsp), %xmm3
mulsd 0x1058(%rsp), %xmm3
movq %xmm3, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1028(%rsp)
movsd 0x1028(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x2b065
jp 0x2b065
leaq 0x800(%rsp), %rdi
movsd 0x10a8(%rsp), %xmm0
leaq 0x1a95bc(%rip), %rsi    # 0x1d45c5
movb $0x1, %al
callq 0x5b9c0
movq %rsp, %rdi
leaq 0x800(%rsp), %rcx
leaq 0x1a7060(%rip), %rsi    # 0x1d2082
leaq 0x1a95d0(%rip), %rdx    # 0x1d45f9
movb $0x0, %al
callq 0x5b9c0
movq 0x1088(%rsp), %rdi
movq %rsp, %r8
leaq 0x1a6ff2(%rip), %rsi    # 0x1d2034
leaq 0x1a95bb(%rip), %rdx    # 0x1d4604
movl $0xd86, %ecx            # imm = 0xD86
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x10c4(%rsp)
jmp 0x2b4c3
movsd 0x1030(%rsp), %xmm1
movsd 0x1058(%rsp), %xmm2
movsd 0x1068(%rsp), %xmm3
movsd 0x1060(%rsp), %xmm0
mulsd 0x1060(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm3, %xmm2
addsd %xmm0, %xmm2
movsd 0x1038(%rsp), %xmm0
movsd 0x1058(%rsp), %xmm3
movsd 0x1060(%rsp), %xmm5
movsd 0x1050(%rsp), %xmm4
mulsd 0x1068(%rsp), %xmm4
movq %xmm4, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm4
mulsd %xmm5, %xmm3
addsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x1040(%rsp), %xmm0
movsd 0x1050(%rsp), %xmm2
movsd 0x1060(%rsp), %xmm4
movsd 0x1058(%rsp), %xmm3
mulsd 0x1058(%rsp), %xmm3
movq %xmm3, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1020(%rsp)
movsd 0x1030(%rsp), %xmm1
movsd 0x1058(%rsp), %xmm2
movsd 0x1060(%rsp), %xmm3
movsd 0x1050(%rsp), %xmm0
mulsd 0x1068(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm3, %xmm2
addsd %xmm0, %xmm2
movsd 0x1038(%rsp), %xmm0
movsd 0x1048(%rsp), %xmm3
movsd 0x1068(%rsp), %xmm5
movsd 0x1058(%rsp), %xmm4
mulsd 0x1058(%rsp), %xmm4
movq %xmm4, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm4
mulsd %xmm5, %xmm3
addsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x1040(%rsp), %xmm0
movsd 0x1050(%rsp), %xmm2
movsd 0x1058(%rsp), %xmm4
movsd 0x1060(%rsp), %xmm3
mulsd 0x1048(%rsp), %xmm3
movq %xmm3, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1018(%rsp)
movsd 0x1030(%rsp), %xmm1
movsd 0x1050(%rsp), %xmm2
movsd 0x1060(%rsp), %xmm3
movsd 0x1058(%rsp), %xmm0
mulsd 0x1058(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm3, %xmm2
addsd %xmm0, %xmm2
movsd 0x1038(%rsp), %xmm0
movsd 0x1050(%rsp), %xmm3
movsd 0x1058(%rsp), %xmm5
movsd 0x1048(%rsp), %xmm4
mulsd 0x1060(%rsp), %xmm4
movq %xmm4, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm4
mulsd %xmm5, %xmm3
addsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x1040(%rsp), %xmm0
movsd 0x1048(%rsp), %xmm2
movsd 0x1058(%rsp), %xmm4
movsd 0x1050(%rsp), %xmm3
mulsd 0x1050(%rsp), %xmm3
movq %xmm3, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1010(%rsp)
movsd 0x1028(%rsp), %xmm1
movsd 0x1020(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x1020(%rsp)
movsd 0x1028(%rsp), %xmm1
movsd 0x1018(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x1018(%rsp)
movsd 0x1028(%rsp), %xmm1
movsd 0x1010(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x1010(%rsp)
movsd 0x10a8(%rsp), %xmm0
movq 0x1078(%rsp), %rax
subsd (%rax), %xmm0
movq 0x1078(%rsp), %rax
divsd (%rax), %xmm0
movsd %xmm0, 0x1008(%rsp)
movq 0x1070(%rsp), %rax
movsd (%rax), %xmm1
movq 0x1070(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x1020(%rsp), %xmm2
mulsd 0x1008(%rsp), %xmm2
movsd 0x1008(%rsp), %xmm4
movsd 0x1018(%rsp), %xmm3
mulsd 0x1008(%rsp), %xmm3
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
addsd 0x1010(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x1098(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x1070(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x1a7813(%rip), %xmm1   # 0x1d2c80
mulsd 0x1020(%rsp), %xmm1
movq 0x1078(%rsp), %rax
divsd (%rax), %xmm1
movsd 0x1008(%rsp), %xmm3
movsd 0x1018(%rsp), %xmm2
movq 0x1078(%rsp), %rax
divsd (%rax), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq 0x1090(%rsp), %rax
movsd %xmm0, (%rax)
movl $0x0, 0x10c4(%rsp)
movl 0x10c4(%rsp), %eax
addq $0x10c8, %rsp           # imm = 0x10C8
retq
nopw %cs:(%rax,%rax)