// File: /workspace/github_c_makefile_star2_O1/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
movl 0x48(%rsp), %r13d
movl 0x40(%rsp), %eax
movq 0x38(%rsp), %r15
subsd %xmm1, %xmm0
divsd %xmm2, %xmm0
movq %rdx, -0x10(%rsp)
cmpl $0x1, %edx
jne 0x11b69
testl %eax, %eax
jle 0x11dad
movl %eax, %eax
shlq $0x2, %rax
xorl %edx, %edx
cmpl $0x1, 0x4(%r15,%rdx)
jne 0x11b5b
movq 0x8(%rsi,%rdx,2), %r10
movsd 0x8(%r10), %xmm1
mulsd %xmm0, %xmm1
addsd 0x8(%rdi,%rdx,2), %xmm1
movsd %xmm1, 0x8(%rcx,%rdx,2)
cmpl $0x2, %r13d
jl 0x11b4c
movsd 0x8(%r10), %xmm1
divsd %xmm2, %xmm1
movsd %xmm1, 0x8(%r8,%rdx,2)
cmpl $0x3, %r13d
jl 0x11b5b
movq $0x0, 0x8(%r9,%rdx,2)
addq $0x4, %rdx
cmpq %rdx, %rax
jne 0x11b12
jmp 0x11dad
testl %eax, %eax
jle 0x11dad
movq %rax, %rdx
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
movq -0x10(%rsp), %rax
leal 0x1(%rax), %ebx
incl %edx
movl $0x1, %r14d
movsd 0xdf6cc(%rip), %xmm3    # 0xf1260
movq %rdi, -0x8(%rsp)
cmpl $0x1, (%r15,%r14,4)
jne 0x11da1
movq %r15, %r11
cmpl $0x0, -0x10(%rsp)
jle 0x11c08
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 0x11bcc
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 0x11bc1
jmp 0x11c0c
xorpd %xmm4, %xmm4
addsd (%rdi,%r14,8), %xmm4
movsd %xmm4, (%rcx,%r14,8)
cmpl $0x2, %r13d
jl 0x11cb1
cmpl $0x0, -0x10(%rsp)
jle 0x11ca3
movq (%rsi,%r14,8), %r15
movl $0x1, %ebp
xorpd %xmm4, %xmm4
movl $0x1, %r12d
xorl %eax, %eax
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
xorl %r10d, %r10d
movapd %xmm3, %xmm7
cmpl %r10d, %eax
je 0x11c61
movapd %xmm0, %xmm8
addsd %xmm6, %xmm8
mulsd %xmm8, %xmm7
addsd %xmm3, %xmm6
incq %r10
cmpq %r10, %r12
jne 0x11c4d
addsd %xmm7, %xmm5
incq %rax
movl %eax, %r10d
cmpq %r10, %r12
jne 0x11c42
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 0x11c3c
jmp 0x11ca7
xorpd %xmm4, %xmm4
divsd %xmm2, %xmm4
movsd %xmm4, (%r8,%r14,8)
cmpl $0x3, %r13d
movq %r11, %r15
jl 0x11da1
movq %rcx, %rdi
movl %r13d, %ecx
movq %r8, %r10
movq %r9, %r8
cmpl $0x0, -0x10(%rsp)
jle 0x11d7f
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 0x11d3a
xorpd %xmm7, %xmm7
xorl %r9d, %r9d
movapd %xmm3, %xmm8
movapd %xmm8, %xmm9
cmpl %r9d, %eax
je 0x11d1f
movapd %xmm0, %xmm9
addsd %xmm7, %xmm9
mulsd %xmm8, %xmm9
cmpl %r9d, %r13d
je 0x11d29
movapd %xmm9, %xmm8
addsd %xmm3, %xmm7
incq %r9
cmpq %r9, %r12
jne 0x11d06
addsd %xmm8, %xmm6
incq %rax
movl %eax, %r9d
cmpq %r9, %r12
jne 0x11cf5
addsd %xmm6, %xmm5
incq %r13
movl %r13d, %eax
cmpq %rax, %r12
jne 0x11cef
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 0x11ce8
jmp 0x11d83
xorpd %xmm4, %xmm4
divsd %xmm1, %xmm4
movq %r8, %r9
movsd %xmm4, (%r8,%r14,8)
movq %r10, %r8
movl %ecx, %r13d
movq %rdi, %rcx
movq -0x8(%rsp), %rdi
movq %r11, %r15
incq %r14
cmpq %rdx, %r14
jne 0x11b99
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq