// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_spline_table_line_to_line
int array_spline_table_line_to_line(
				    double * x, /* vector of size x_size */
				    int n_lines,
				    double * array,
				    int n_columns,
				    int index_y,
				    int index_ddydx2,
				    short spline_mode,
				    ErrorMsg errmsg) {

  int i,k;
  double p,qn,sig,un;
  double * u;
  double dy_first;
  double dy_last;

  class_test(n_lines<3,
             errmsg,
             "no possible spline with less than three lines");

  u = (double*)malloc((n_lines-1) * sizeof(double));
  if (u == NULL) {
    class_sprintf(errmsg,"%s(L:%d) Cannot allocate u",__func__,__LINE__);
    return _FAILURE_;
  }

  if (spline_mode == _SPLINE_NATURAL_) {
    *(array+0*n_columns+index_ddydx2) = u[0] = 0.0;
  }
  else {
    if (spline_mode == _SPLINE_EST_DERIV_) {
      dy_first =
	((x[2]-x[0])*(x[2]-x[0])*
	 (*(array+1*n_columns+index_y)-*(array+0*n_columns+index_y))-
	 (x[1]-x[0])*(x[1]-x[0])*
	 (*(array+2*n_columns+index_y)-*(array+0*n_columns+index_y)))/
	((x[2]-x[0])*(x[1]-x[0])*(x[2]-x[1]));
      *(array+0*n_columns+index_ddydx2) = -0.5;
      u[0] =
	(3./(x[1] -  x[0]))*
	((*(array+1*n_columns+index_y) -  *(array+0*n_columns+index_y))/
	 (x[1] - x[0])-dy_first);
    }
    else {
      class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode);
      return _FAILURE_;
    }
  }

  for (i=1; i < n_lines-1; i++) {

      sig = (x[i] - x[i-1]) / (x[i+1] - x[i-1]);

      p = sig * *(array+(i-1)*n_columns+index_ddydx2) + 2.0;
      *(array+i*n_columns+index_ddydx2) = (sig-1.0)/p;
      u[i] = (*(array+(i+1)*n_columns+index_y) - *(array+i*n_columns+index_y))
	/ (x[i+1] - x[i])
	- (*(array+i*n_columns+index_y) - *(array+(i-1)*n_columns+index_y))
	/ (x[i] - x[i-1]);
      u[i]= (6.0 * u[i] /
	     (x[i+1] - x[i-1])
	     - sig * u[i-1]) / p;

  }

  if (spline_mode == _SPLINE_NATURAL_) {
    qn=0.;
    un=0.;
  }
  else {
    if (spline_mode == _SPLINE_EST_DERIV_) {
      dy_last =
	((x[n_lines-3]-x[n_lines-1])*(x[n_lines-3]-x[n_lines-1])*
	 (*(array+(n_lines-2)*n_columns+index_y)-*(array+(n_lines-1)*n_columns+index_y))-
	 (x[n_lines-2]-x[n_lines-1])*(x[n_lines-2]-x[n_lines-1])*
	 (*(array+(n_lines-3)*n_columns+index_y)-*(array+(n_lines-1)*n_columns+index_y)))/
	((x[n_lines-3]-x[n_lines-1])*(x[n_lines-2]-x[n_lines-1])*(x[n_lines-3]-x[n_lines-2]));
      qn=0.5;
      un =
	(3./(x[n_lines-1] - x[n_lines-2]))*
	(dy_last-(*(array+(n_lines-1)*n_columns+index_y) -  *(array+(n_lines-2)*n_columns+index_y))/
	 (x[n_lines-1] - x[n_lines-2]));
    }
    else {
      class_sprintf(errmsg,"%s(L:%d) Spline mode not identified: %d",__func__,__LINE__,spline_mode);
      return _FAILURE_;
    }
  }

  *(array+(n_lines-1)*n_columns+index_ddydx2) =
    (un-qn*u[n_lines-2])/(qn* *(array+(n_lines-2)*n_columns+index_ddydx2)+1.0);

  for (k=n_lines-2; k>=0; k--)
    *(array+k*n_columns+index_ddydx2) = *(array+k*n_columns+index_ddydx2) *
      *(array+(k+1)*n_columns+index_ddydx2) + u[k];

  free(u);

  return _SUCCESS_;
 }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1028, %rsp           # imm = 0x1028
movq 0x1068(%rsp), %rbp
cmpl $0x2, %esi
jg 0x13de1
leaq 0xdc0d6(%rip), %rsi     # 0xefe60
leaq 0x820(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0xda2df(%rip), %rsi     # 0xee082
leaq 0xdc0e4(%rip), %rdx     # 0xefe8e
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xda271(%rip), %rsi     # 0xee034
leaq 0xdc0ce(%rip), %rdx     # 0xefe98
movq %rbp, %rdi
movl $0x1d8, %ecx            # imm = 0x1D8
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
jmp 0x14291
movl %r9d, %r12d
movl %r8d, %r15d
movl %esi, %ebx
movq %rdi, %r13
movl %ecx, %ebp
movq %rdx, 0x8(%rsp)
leal -0x1(%rbx), %r14d
leaq (,%r14,8), %rdi
callq 0x8460
testq %rax, %rax
je 0x13ef0
movzwl 0x1060(%rsp), %esi
movswl %si, %edx
movslq %r12d, %rdi
movslq %r15d, %r12
movslq %ebp, %rcx
movl %edx, 0x4(%rsp)
testw %dx, %dx
je 0x13f3a
cmpw $0x1, %si
movq 0x8(%rsp), %r8
jne 0x14170
movsd 0x10(%r13), %xmm0
movsd (%r13), %xmm3
movsd 0x8(%r13), %xmm4
movapd %xmm0, %xmm2
subsd %xmm3, %xmm2
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
leaq (%r8,%r12,8), %rdx
movsd (%rdx,%rcx,8), %xmm1
movsd (%rdx), %xmm6
subsd %xmm6, %xmm1
mulsd %xmm5, %xmm1
subsd %xmm4, %xmm0
subsd %xmm3, %xmm4
leal (%rcx,%rcx), %esi
movslq %esi, %rsi
movsd (%rdx,%rsi,8), %xmm3
subsd %xmm6, %xmm3
mulsd %xmm4, %xmm2
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm4
subsd %xmm4, %xmm1
mulsd %xmm0, %xmm2
divsd %xmm2, %xmm1
movabsq $-0x4020000000000000, %rsi # imm = 0xBFE0000000000000
movq %rsi, (%r8,%rdi,8)
movsd 0x8(%r13), %xmm0
subsd (%r13), %xmm0
movsd (%rdx,%rcx,8), %xmm2
subsd (%rdx), %xmm2
movapd 0xdb8b2(%rip), %xmm3    # 0xef780
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm3
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
subsd %xmm1, %xmm0
mulsd %xmm3, %xmm0
movsd %xmm0, (%rax)
jmp 0x13f4c
leaq 0xdbf26(%rip), %rbx     # 0xefe1d
leaq 0xdbf9a(%rip), %r14     # 0xefe98
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1dc, %r8d            # imm = 0x1DC
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq 0x1068(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1dc, %r8d            # imm = 0x1DC
xorl %eax, %eax
callq 0x8550
jmp 0x14291
xorl %edx, %edx
movq %rdx, (%rax)
movq 0x8(%rsp), %r8
movq %rdx, (%r8,%rdi,8)
xorpd %xmm0, %xmm0
movsd (%r13), %xmm4
movsd 0x8(%r13), %xmm5
leaq (,%rcx,8), %rsi
leaq (,%r12,8), %r9
leaq (%r9,%rcx,8), %r10
movq %rdi, 0x18(%rsp)
leaq (,%rdi,8), %r11
leaq (%r11,%rcx,8), %r15
movq %rcx, %rdx
shlq $0x4, %rdx
movq %r12, 0x10(%rsp)
leaq (%rdx,%r12,8), %r12
movl $0x1, %edi
movsd 0xdad66(%rip), %xmm1    # 0xeed00
movsd 0xda846(%rip), %xmm2    # 0xee7e8
movsd 0xdb6c6(%rip), %xmm3    # 0xef670
subsd %xmm4, %xmm5
movsd 0x8(%r13,%rdi,8), %xmm6
subsd %xmm4, %xmm6
divsd %xmm6, %xmm5
movsd (%r8,%r11), %xmm6
mulsd %xmm5, %xmm6
addsd %xmm1, %xmm6
movapd %xmm5, %xmm4
addsd %xmm2, %xmm4
divsd %xmm6, %xmm4
movsd %xmm4, (%r8,%r15)
movsd -0x8(%r13,%rdi,8), %xmm9
movupd (%r13,%rdi,8), %xmm4
movsd (%r8,%r10), %xmm8
movsd (%r8,%r9), %xmm7
unpcklpd %xmm8, %xmm7            # xmm7 = xmm7[0],xmm8[0]
movhpd (%r8,%r12), %xmm8       # xmm8 = xmm8[0],mem[0]
subpd %xmm7, %xmm8
movapd %xmm4, %xmm7
unpckhpd %xmm4, %xmm7            # xmm7 = xmm7[1],xmm4[1]
movapd %xmm7, %xmm10
subsd %xmm9, %xmm10
unpcklpd %xmm4, %xmm9            # xmm9 = xmm9[0],xmm4[0]
movapd %xmm4, %xmm11
subpd %xmm9, %xmm11
divpd %xmm11, %xmm8
mulsd %xmm0, %xmm5
movapd %xmm8, %xmm0
unpckhpd %xmm8, %xmm0            # xmm0 = xmm0[1],xmm8[1]
subsd %xmm8, %xmm0
mulsd %xmm3, %xmm0
divsd %xmm10, %xmm0
subsd %xmm5, %xmm0
divsd %xmm6, %xmm0
movsd %xmm0, (%rax,%rdi,8)
leaq 0x1(%rdi), %rdx
addq %rsi, %r8
movapd %xmm7, %xmm5
movq %rdx, %rdi
cmpq %rdx, %r14
jne 0x13faa
movzwl 0x1060(%rsp), %edx
testw %dx, %dx
movq 0x1068(%rsp), %r15
je 0x141ba
cmpw $0x1, %dx
jne 0x14247
leal -0x3(%rbx), %edx
movsd (%r13,%rdx,8), %xmm4
movsd (%r13,%r14,8), %xmm0
movapd %xmm4, %xmm3
subsd %xmm0, %xmm3
movapd %xmm3, %xmm6
mulsd %xmm3, %xmm6
addl $-0x2, %ebx
movl %ebx, %edi
imull %ebp, %edi
movslq %edi, %r8
movq 0x8(%rsp), %r10
leaq (%r10,%r8,8), %rdi
movq 0x10(%rsp), %r11
movsd (%rdi,%r11,8), %xmm2
imull %ebp, %r14d
movslq %r14d, %r9
leaq (%r10,%r9,8), %rdi
movsd (%rdi,%r11,8), %xmm1
movapd %xmm2, %xmm5
subsd %xmm1, %xmm5
mulsd %xmm6, %xmm5
movsd (%r13,%rbx,8), %xmm6
movapd %xmm6, %xmm7
subsd %xmm0, %xmm7
imull %ebp, %edx
movslq %edx, %rdx
leaq (%r10,%rdx,8), %rdx
movsd (%rdx,%r11,8), %xmm8
subsd %xmm1, %xmm8
mulsd %xmm7, %xmm3
mulsd %xmm7, %xmm7
mulsd %xmm8, %xmm7
subsd %xmm7, %xmm5
subsd %xmm6, %xmm4
unpcklpd %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0]
unpcklpd %xmm3, %xmm6            # xmm6 = xmm6[0],xmm3[0]
movapd %xmm0, %xmm3
subpd %xmm6, %xmm3
mulpd %xmm0, %xmm6
movsd %xmm3, %xmm6            # xmm6 = xmm3[0],xmm6[1]
movapd 0xdb63a(%rip), %xmm4    # 0xef780
unpcklpd %xmm5, %xmm4            # xmm4 = xmm4[0],xmm5[0]
divpd %xmm6, %xmm4
subsd %xmm2, %xmm1
divsd %xmm3, %xmm1
movapd %xmm4, %xmm0
unpckhpd %xmm4, %xmm0            # xmm0 = xmm0[1],xmm4[1]
subsd %xmm1, %xmm0
mulsd %xmm4, %xmm0
movsd 0xdab62(%rip), %xmm1    # 0xeecd0
jmp 0x141d9
leaq 0xdbcc1(%rip), %rbx     # 0xefe38
leaq 0xdbd1a(%rip), %r14     # 0xefe98
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1f2, %r8d            # imm = 0x1F2
movl 0x4(%rsp), %ebp
movl %ebp, %r9d
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq 0x1068(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1f2, %r8d            # imm = 0x1F2
jmp 0x14287
addl $-0x2, %ebx
movl %ebx, %edx
imull %ebp, %edx
movslq %edx, %r8
imull %ebp, %r14d
movslq %r14d, %r9
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movq 0x8(%rsp), %r10
movsd (%rax,%rbx,8), %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
movq 0x18(%rsp), %rdx
leaq (%r10,%rdx,8), %rdx
mulsd (%rdx,%r8,8), %xmm1
addsd 0xda063(%rip), %xmm1    # 0xee260
divsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%r9,8)
movslq %ebx, %rdi
leaq 0x1(%rdi), %r8
movq %r8, %r9
imulq %rcx, %r9
negq %rsi
imulq %rcx, %rdi
movsd (%rdx,%rdi,8), %xmm0
mulsd (%rdx,%r9,8), %xmm0
addsd -0x8(%rax,%r8,8), %xmm0
movsd %xmm0, (%rdx,%rdi,8)
addq %rsi, %rdx
decq %r8
jg 0x1421c
movq %rax, %rdi
callq 0x8410
xorl %eax, %eax
jmp 0x14296
leaq 0xdbbea(%rip), %rbx     # 0xefe38
leaq 0xdbc43(%rip), %r14     # 0xefe98
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x21a, %r8d            # imm = 0x21A
movl 0x4(%rsp), %ebp
movl %ebp, %r9d
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %r15, %rdi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x21a, %r8d            # imm = 0x21A
movl %ebp, %r9d
xorl %eax, %eax
callq 0x8550
movl $0x1, %eax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq