// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/evolver_ndf15.c
// Function: interp_from_difold
int interp_from_difold(double tinterp,double tnew,double *ynew,double h,double **dif,int k, double *yinterp,
            double *ypinterp, double *yppinterp, int* index, int neq, int output){
  /* Output=1: only y_vector. Output=2: y and y prime. Output=3: y, yp and ypp*/
  int i,j,m,l,p,factor;
  double sumj,suml,sump,prodm,s;
  s = (tinterp - tnew)/h;
  if (k==1){
    for(i=1;i<=neq;i++){
      if(index[i]==_TRUE_){
        yinterp[i] = ynew[i] + dif[i][1] * s;
        if (output>1) ypinterp[i] = dif[i][1]/h;
        if (output>2) yppinterp[i] = 0; /* No good estimate can be made of the second derivative */
      }
    }
  }
  else{
    /*This gets tricky */
    for(i=1;i<=neq;i++){
      if(index[i]==_TRUE_){
        /*First the value of the function:    */
        sumj=0.0;
        factor=1;
        for(j=1;j<=k;j++){
          prodm=1.0;
          factor*=j;
          for(m=0;m<j;m++) prodm*=(m+s);
          sumj+=dif[i][j]/factor*prodm;
        }
        yinterp[i] = ynew[i]+sumj;
        /* Now the first derivative: */
        if (output>1){
          factor = 1;
          sumj=0.0;
          for(j=1;j<=k;j++){
            suml = 0.0;
            factor *=j;
            for(l=0;l<j;l++){
              prodm=1.0;
              for(m=0;m<j;m++){
            if(m!=l) prodm*=(m+s);
              }
              suml+=prodm;
            }
            sumj+=dif[i][j]/factor*suml;
          }
          ypinterp[i] = sumj/h;
        }
        /* The second derivative: */
        if (output>2){
          factor=1;
          sumj=0.0;
          for(j=1;j<=k;j++){
            suml=0.0;
            factor*=j;
            for(l=0;l<j;l++){
              sump=0.0;
              for(p=0;p<j;p++){
                if(p!=l){
                  prodm=1.0;
                  for(m=0;m<j;m++){
                    if((m!=l)&&(m!=p)){
                      prodm*=(m+s);
                    }
                  }
                  sump+=prodm;
                }
              }
              suml+=sump;
            }
            sumj+=dif[i][j]/factor*suml;
          }
          yppinterp[i] = sumj/(h*h);
        }
      }
    }
  }
  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, -0x10(%rsp)
movl 0x48(%rsp), %r8d
movl 0x40(%rsp), %r11d
movq 0x38(%rsp), %r10
subsd %xmm1, %xmm0
divsd %xmm2, %xmm0
cmpl $0x1, %edx
jne 0x11ca8
testl %r11d, %r11d
jle 0x11ee2
movl %r11d, %eax
shlq $0x2, %rax
xorl %edx, %edx
cmpl $0x1, 0x4(%r10,%rdx)
jne 0x11c9a
movq 0x8(%rsi,%rdx,2), %r11
movsd 0x8(%r11), %xmm1
mulsd %xmm0, %xmm1
addsd 0x8(%rdi,%rdx,2), %xmm1
movsd %xmm1, 0x8(%rcx,%rdx,2)
cmpl $0x2, %r8d
jl 0x11c9a
movsd 0x8(%r11), %xmm1
divsd %xmm2, %xmm1
movq -0x10(%rsp), %r11
movsd %xmm1, 0x8(%r11,%rdx,2)
je 0x11c9a
movq $0x0, 0x8(%r9,%rdx,2)
addq $0x4, %rdx
cmpq %rdx, %rax
jne 0x11c50
jmp 0x11ee2
testl %r11d, %r11d
jle 0x11ee2
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
leal 0x1(%rdx), %ebx
incl %r11d
movl $0x1, %r14d
movsd 0xdc593(%rip), %xmm3    # 0xee260
movq %r9, -0x8(%rsp)
cmpl $0x1, (%r10,%r14,4)
jne 0x11ed6
testl %edx, %edx
jle 0x11dd5
movq (%rsi,%r14,8), %rax
movl $0x1, %ebp
xorpd %xmm4, %xmm4
movl $0x1, %r15d
movq %r15, %r12
movapd %xmm3, %xmm5
xorpd %xmm6, %xmm6
movapd %xmm0, %xmm7
addsd %xmm6, %xmm7
mulsd %xmm7, %xmm5
addsd %xmm3, %xmm6
decq %r12
jne 0x11d03
imull %r15d, %ebp
movsd (%rax,%r15,8), %xmm6
xorps %xmm7, %xmm7
cvtsi2sd %ebp, %xmm7
divsd %xmm7, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm4
incq %r15
cmpq %rbx, %r15
jne 0x11cf8
addsd (%rdi,%r14,8), %xmm4
movsd %xmm4, (%rcx,%r14,8)
cmpl $0x1, %r8d
jle 0x11ed6
testl %edx, %edx
jle 0x11df4
movq (%rsi,%r14,8), %r15
movl $0x1, %ebp
xorpd %xmm4, %xmm4
movl $0x1, %r12d
xorl %eax, %eax
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
xorl %r13d, %r13d
movapd %xmm3, %xmm7
cmpl %r13d, %eax
je 0x11d93
movapd %xmm0, %xmm8
addsd %xmm6, %xmm8
mulsd %xmm8, %xmm7
addsd %xmm3, %xmm6
incq %r13
cmpq %r13, %r12
jne 0x11d7f
addsd %xmm7, %xmm5
incq %rax
movl %eax, %r13d
cmpq %r13, %r12
jne 0x11d74
imull %r12d, %ebp
movsd (%r15,%r12,8), %xmm6
xorps %xmm7, %xmm7
cvtsi2sd %ebp, %xmm7
divsd %xmm7, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm4
incq %r12
cmpq %rbx, %r12
jne 0x11d6e
jmp 0x11df8
xorpd %xmm4, %xmm4
movsd (%rdi,%r14,8), %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%rcx,%r14,8)
cmpl $0x1, %r8d
jg 0x11df8
jmp 0x11ed6
xorpd %xmm4, %xmm4
divsd %xmm2, %xmm4
movq -0x10(%rsp), %rax
movsd %xmm4, (%rax,%r14,8)
cmpl $0x2, %r8d
je 0x11ed6
testl %edx, %edx
jle 0x11ec3
movq (%rsi,%r14,8), %r15
movl $0x1, %ebp
xorpd %xmm4, %xmm4
movl $0x1, %r12d
xorl %r13d, %r13d
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
xorl %eax, %eax
cmpl %r13d, %eax
je 0x11e7e
xorpd %xmm7, %xmm7
xorl %r9d, %r9d
movapd %xmm3, %xmm8
movapd %xmm8, %xmm9
cmpl %r9d, %eax
je 0x11e63
movapd %xmm0, %xmm9
addsd %xmm7, %xmm9
mulsd %xmm8, %xmm9
cmpl %r9d, %r13d
je 0x11e6d
movapd %xmm9, %xmm8
addsd %xmm3, %xmm7
incq %r9
cmpq %r9, %r12
jne 0x11e4a
addsd %xmm8, %xmm6
incq %rax
movl %eax, %r9d
cmpq %r9, %r12
jne 0x11e39
addsd %xmm6, %xmm5
incq %r13
movl %r13d, %eax
cmpq %rax, %r12
jne 0x11e33
imull %r12d, %ebp
movsd (%r15,%r12,8), %xmm6
xorps %xmm7, %xmm7
cvtsi2sd %ebp, %xmm7
divsd %xmm7, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm4
incq %r12
cmpq %rbx, %r12
jne 0x11e2c
jmp 0x11ec7
xorpd %xmm4, %xmm4
divsd %xmm1, %xmm4
movq -0x8(%rsp), %r9
movsd %xmm4, (%r9,%r14,8)
incq %r14
cmpq %r11, %r14
jne 0x11cd2
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq