// File: /workspace/github_c_makefile_star2_O2/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 0x120e1
leaq 0xd4d96(%rip), %rsi     # 0xe6e20
leaq 0x820(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0xd2fdf(%rip), %rsi     # 0xe5082
leaq 0xd4da4(%rip), %rdx     # 0xe6e4e
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd2f71(%rip), %rsi     # 0xe5034
leaq 0xd4d8e(%rip), %rdx     # 0xe6e58
movq %rbp, %rdi
movl $0x1d8, %ecx            # imm = 0x1D8
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
jmp 0x12590
movl %r9d, %r15d
movl %r8d, %r12d
movl %esi, %ebx
movq %rdi, %r13
movl %ecx, %ebp
movq %rdx, 0x10(%rsp)
leal -0x1(%rbx), %r14d
leaq (,%r14,8), %rdi
callq 0x8490
testq %rax, %rax
je 0x121f3
movzwl 0x1060(%rsp), %ecx
movswl %cx, %r9d
testw %r9w, %r9w
je 0x1223d
cmpw $0x1, %cx
movq 0x10(%rsp), %r8
jne 0x12469
movl %r9d, 0xc(%rsp)
movsd 0x10(%r13), %xmm0
movsd (%r13), %xmm3
movsd 0x8(%r13), %xmm4
movapd %xmm0, %xmm2
subsd %xmm3, %xmm2
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
movslq %ebp, %rcx
movslq %r12d, %rdi
leaq (%r8,%rdi,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
movslq %r15d, %r10
movabsq $-0x4020000000000000, %rsi # imm = 0xBFE0000000000000
movq %rsi, (%r8,%r10,8)
movsd 0x8(%r13), %xmm0
subsd (%r13), %xmm0
movsd (%rdx,%rcx,8), %xmm2
subsd (%rdx), %xmm2
movapd 0xd457f(%rip), %xmm3    # 0xe6750
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 0x1225d
leaq 0xd4be3(%rip), %rbx     # 0xe6ddd
leaq 0xd4c57(%rip), %r14     # 0xe6e58
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1dc, %r8d            # imm = 0x1DC
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
movq 0x1068(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1dc, %r8d            # imm = 0x1DC
xorl %eax, %eax
callq 0x8580
jmp 0x12590
movl %r9d, 0xc(%rsp)
andq $0x0, (%rax)
movslq %r15d, %r10
movq 0x10(%rsp), %r8
andq $0x0, (%r8,%r10,8)
movslq %r12d, %rdi
movslq %ebp, %rcx
xorpd %xmm0, %xmm0
leaq (,%rdi,8), %r9
leaq (,%rcx,8), %rsi
movq %r10, 0x18(%rsp)
leaq (,%r10,8), %r10
leaq (%r9,%rcx,8), %r11
leaq (%r10,%rcx,8), %r15
movq %rcx, %rdx
shlq $0x4, %rdx
leaq (%rdx,%rdi,8), %r12
pushq $0x1
popq %rdx
movsd 0xd3a48(%rip), %xmm1    # 0xe5ce0
movsd 0xd3548(%rip), %xmm2    # 0xe57e8
movsd 0xd43a8(%rip), %xmm3    # 0xe6650
cmpq %r14, %rdx
jae 0x12371
movupd (%r13,%rdx,8), %xmm4
movsd -0x8(%r13,%rdx,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 (%r8,%r10), %xmm5
mulsd %xmm4, %xmm5
addsd %xmm1, %xmm5
movapd %xmm4, %xmm6
addsd %xmm2, %xmm6
divsd %xmm5, %xmm6
movsd %xmm6, (%r8,%r15)
movsd -0x8(%r13,%rdx,8), %xmm6
movupd (%r13,%rdx,8), %xmm7
movsd (%r8,%r11), %xmm8
movsd (%r8,%r9), %xmm9
unpcklpd %xmm8, %xmm9            # xmm9 = xmm9[0],xmm8[0]
movhpd (%r8,%r12), %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 %xmm0, %xmm4
movapd %xmm8, %xmm0
unpckhpd %xmm8, %xmm0            # xmm0 = xmm0[1],xmm8[1]
subsd %xmm8, %xmm0
mulsd %xmm3, %xmm0
unpckhpd %xmm7, %xmm7            # xmm7 = xmm7[1,1]
subsd %xmm6, %xmm7
divsd %xmm7, %xmm0
subsd %xmm4, %xmm0
divsd %xmm5, %xmm0
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
addq %rsi, %r8
jmp 0x122a8
movzwl 0x1060(%rsp), %edx
testw %dx, %dx
je 0x124af
cmpw $0x1, %dx
jne 0x12541
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, %r8d
imull %ebp, %r8d
movslq %r8d, %r8
movq 0x10(%rsp), %r11
leaq (%r11,%r8,8), %r9
movsd (%r9,%rdi,8), %xmm2
imull %ebp, %r14d
movslq %r14d, %r9
leaq (%r11,%r9,8), %r10
movsd (%r10,%rdi,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 (%r11,%rdx,8), %rdx
movsd (%rdx,%rdi,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 0xd4311(%rip), %xmm4    # 0xe6750
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 0xd3849(%rip), %xmm1    # 0xe5cb0
jmp 0x124ce
leaq 0xd4988(%rip), %rbx     # 0xe6df8
leaq 0xd49e1(%rip), %r14     # 0xe6e58
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1f2, %r8d            # imm = 0x1F2
movl %r9d, %ebp
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
movq 0x1068(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x1f2, %r8d            # imm = 0x1F2
jmp 0x12586
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 0x10(%rsp), %r11
movsd (%rax,%rbx,8), %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
movq 0x18(%rsp), %rdx
leaq (%r11,%rdx,8), %rdx
mulsd (%rdx,%r8,8), %xmm1
addsd 0xd2d6e(%rip), %xmm1    # 0xe5260
divsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%r9,8)
movslq %ebx, %rdi
movq %rcx, %r8
imulq %rdi, %r8
negq %rsi
leaq 0x1(%rdi), %r9
imulq %rcx, %r9
testq %rdi, %rdi
js 0x12535
movsd (%rdx,%r8,8), %xmm0
mulsd (%rdx,%r9,8), %xmm0
addsd (%rax,%rdi,8), %xmm0
movsd %xmm0, (%rdx,%r8,8)
decq %rdi
addq %rsi, %rdx
jmp 0x12511
movq %rax, %rdi
callq 0x8430
xorl %eax, %eax
jmp 0x12593
leaq 0xd48b0(%rip), %rbx     # 0xe6df8
leaq 0xd4909(%rip), %r14     # 0xe6e58
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x21a, %r8d            # imm = 0x21A
movl 0xc(%rsp), %ebp
movl %ebp, %r9d
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
movq 0x1068(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
movl $0x21a, %r8d            # imm = 0x21A
movl %ebp, %r9d
xorl %eax, %eax
callq 0x8580
pushq $0x1
popq %rax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq