// File: /workspace/github_c_makefile_star2_O1/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), %r15
cmpl $0x2, %esi
jg 0x13cac
leaq 0xdf1fb(%rip), %rsi     # 0xf2e50
leaq 0x820(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xdd414(%rip), %rsi     # 0xf1082
leaq 0xdf209(%rip), %rdx     # 0xf2e7e
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xdd3a6(%rip), %rsi     # 0xf1034
leaq 0xdf1f3(%rip), %rdx     # 0xf2e88
movq %r15, %rdi
movl $0x1d8, %ecx            # imm = 0x1D8
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
jmp 0x1417a
movl %r9d, %ebp
movl %r8d, %r12d
movl %ecx, %r14d
movl %esi, %ebx
movq %rdi, %r13
movq %rdx, 0x8(%rsp)
leal -0x1(%rbx), %r15d
leaq (,%r15,8), %rdi
callq 0x8460
testq %rax, %rax
je 0x13dc3
movzwl 0x1060(%rsp), %edx
movswl %dx, %r9d
movslq %ebp, %rdi
movslq %r12d, %r8
movslq %r14d, %rcx
testw %r9w, %r9w
je 0x13e0d
cmpw $0x1, %dx
jne 0x1405b
movl %r9d, (%rsp)
movl %r14d, 0x4(%rsp)
movsd 0x10(%r13), %xmm1
movsd (%r13), %xmm3
movsd 0x8(%r13), %xmm4
movapd %xmm1, %xmm2
subsd %xmm3, %xmm2
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
movq 0x8(%rsp), %r14
leaq (%r14,%r8,8), %rdx
movsd (%rdx,%rcx,8), %xmm0
movsd (%rdx), %xmm6
subsd %xmm6, %xmm0
mulsd %xmm5, %xmm0
subsd %xmm4, %xmm1
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, %xmm0
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movabsq $-0x4020000000000000, %rsi # imm = 0xBFE0000000000000
movq %rsi, (%r14,%rdi,8)
movsd 0x8(%r13), %xmm1
subsd (%r13), %xmm1
movsd (%rdx,%rcx,8), %xmm2
subsd (%rdx), %xmm2
movapd 0xde9cf(%rip), %xmm3    # 0xf2770
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
divpd %xmm1, %xmm3
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
subsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
movsd %xmm1, (%rax)
jmp 0x13e24
leaq 0xdf043(%rip), %rbx     # 0xf2e0d
leaq 0xdf0b7(%rip), %r14     # 0xf2e88
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 0x1417a
movl %r9d, (%rsp)
movl %r14d, 0x4(%rsp)
xorl %edx, %edx
movq %rdx, (%rax)
movq 0x8(%rsp), %r14
movq %rdx, (%r14,%rdi,8)
cmpl $0x3, %r15d
movl $0x2, %r9d
cmovgel %r15d, %r9d
movsd (%rax), %xmm3
leaq (,%rcx,8), %rsi
leaq (,%r8,8), %r10
leaq (%r10,%rcx,8), %r11
movq %rdi, 0x18(%rsp)
leaq (,%rdi,8), %r12
leaq (%r12,%rcx,8), %rbp
movq %rcx, %rdx
shlq $0x4, %rdx
movq %r8, 0x10(%rsp)
leaq (%rdx,%r8,8), %r8
movl $0x1, %edi
movsd 0xdde88(%rip), %xmm0    # 0xf1d00
movsd 0xdd968(%rip), %xmm1    # 0xf17e8
movsd 0xde7e8(%rip), %xmm2    # 0xf2670
movupd (%r13,%rdi,8), %xmm4
movsd -0x8(%r13,%rdi,8), %xmm5
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
subpd %xmm5, %xmm4
movapd %xmm4, %xmm5
unpckhpd %xmm4, %xmm5            # xmm5 = xmm5[1],xmm4[1]
divsd %xmm5, %xmm4
movsd (%r14,%r12), %xmm5
mulsd %xmm4, %xmm5
addsd %xmm0, %xmm5
movapd %xmm4, %xmm6
addsd %xmm1, %xmm6
divsd %xmm5, %xmm6
movsd %xmm6, (%r14,%rbp)
movsd -0x8(%r13,%rdi,8), %xmm6
movupd (%r13,%rdi,8), %xmm7
movsd (%r14,%r11), %xmm8
movsd (%r14,%r10), %xmm9
unpcklpd %xmm8, %xmm9            # xmm9 = xmm9[0],xmm8[0]
movhpd (%r14,%r8), %xmm8       # xmm8 = xmm8[0],mem[0]
subpd %xmm9, %xmm8
movapd %xmm6, %xmm9
unpcklpd %xmm7, %xmm9            # xmm9 = xmm9[0],xmm7[0]
movapd %xmm7, %xmm10
subpd %xmm9, %xmm10
divpd %xmm10, %xmm8
mulsd %xmm3, %xmm4
movapd %xmm8, %xmm3
unpckhpd %xmm8, %xmm3            # xmm3 = xmm3[1],xmm8[1]
subsd %xmm8, %xmm3
mulsd %xmm2, %xmm3
unpckhpd %xmm7, %xmm7            # xmm7 = xmm7[1,1]
subsd %xmm6, %xmm7
divsd %xmm7, %xmm3
subsd %xmm4, %xmm3
divsd %xmm5, %xmm3
movsd %xmm3, (%rax,%rdi,8)
leaq 0x1(%rdi), %rdx
addq %rsi, %r14
movq %rdx, %rdi
cmpq %rdx, %r9
jne 0x13e88
movzwl 0x1060(%rsp), %edx
testw %dx, %dx
movl 0x4(%rsp), %r10d
movq 0x1068(%rsp), %r12
je 0x140a1
cmpw $0x1, %dx
jne 0x14131
leal -0x3(%rbx), %edx
movsd (%r13,%rdx,8), %xmm2
movsd (%r13,%r15,8), %xmm0
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm7
mulsd %xmm1, %xmm7
leal -0x2(%rbx), %edi
movsd (%r13,%rdi,8), %xmm3
imull %r10d, %edi
movslq %edi, %rdi
movq 0x8(%rsp), %r8
leaq (%r8,%rdi,8), %rdi
movq 0x10(%rsp), %r9
movsd (%rdi,%r9,8), %xmm5
movl %r15d, %edi
imull %r10d, %edi
movslq %edi, %rdi
leaq (%r8,%rdi,8), %rdi
movsd (%rdi,%r9,8), %xmm4
movapd %xmm5, %xmm6
subsd %xmm4, %xmm6
mulsd %xmm7, %xmm6
movapd %xmm3, %xmm7
subsd %xmm0, %xmm7
imull %r10d, %edx
movslq %edx, %rdx
leaq (%r8,%rdx,8), %rdx
movsd (%rdx,%r9,8), %xmm8
subsd %xmm4, %xmm8
mulsd %xmm7, %xmm1
mulsd %xmm7, %xmm7
mulsd %xmm8, %xmm7
subsd %xmm7, %xmm6
subsd %xmm3, %xmm2
unpcklpd %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
unpcklpd %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0]
movapd %xmm0, %xmm1
subpd %xmm3, %xmm1
mulpd %xmm0, %xmm3
movsd %xmm1, %xmm3            # xmm3 = xmm1[0],xmm3[1]
movapd 0xde73f(%rip), %xmm2    # 0xf2770
unpcklpd %xmm6, %xmm2            # xmm2 = xmm2[0],xmm6[0]
divpd %xmm3, %xmm2
subsd %xmm5, %xmm4
divsd %xmm1, %xmm4
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
subsd %xmm4, %xmm0
mulsd %xmm2, %xmm0
movsd 0xddc77(%rip), %xmm1    # 0xf1cd0
jmp 0x140ae
leaq 0xdedc6(%rip), %rbx     # 0xf2e28
leaq 0xdee1f(%rip), %r14     # 0xf2e88
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1f2, %r8d            # imm = 0x1F2
xorl %eax, %eax
movl %r9d, %ebp
callq 0x8550
incl %eax
movslq %eax, %rsi
movq 0x1068(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1f2, %r8d            # imm = 0x1F2
jmp 0x14170
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
movq 0x8(%rsp), %r8
movslq %ebx, %rdx
leaq -0x2(%rdx), %rdi
addl $-0x2, %ebx
movsd (%rax,%rbx,8), %xmm2
mulsd %xmm1, %xmm2
imull %r10d, %ebx
movslq %ebx, %r9
movq 0x18(%rsp), %r11
leaq (%r8,%r11,8), %r8
mulsd (%r8,%r9,8), %xmm1
subsd %xmm2, %xmm0
addsd 0xdd17d(%rip), %xmm1    # 0xf1260
divsd %xmm1, %xmm0
imull %r10d, %r15d
movslq %r15d, %r9
movsd %xmm0, (%r8,%r9,8)
decq %rdx
movq %rdx, %r9
imulq %rcx, %r9
negq %rsi
imulq %rcx, %rdi
movsd (%r8,%rdi,8), %xmm0
mulsd (%r8,%r9,8), %xmm0
addsd -0x8(%rax,%rdx,8), %xmm0
movsd %xmm0, (%r8,%rdi,8)
addq %rsi, %r8
decq %rdx
jg 0x14105
movq %rax, %rdi
callq 0x8410
xorl %eax, %eax
jmp 0x1417f
leaq 0xdecf0(%rip), %rbx     # 0xf2e28
leaq 0xded49(%rip), %r14     # 0xf2e88
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x21a, %r8d            # imm = 0x21A
movl (%rsp), %ebp
movl %ebp, %r9d
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %r12, %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