// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_spline_table_columns2
int array_spline_table_columns2(
		       double * x, /* vector of size x_size */
		       int x_size,
		       double * y_array, /* array of size x_size*y_size with elements
					  y_array[index_y*x_size+index_x] */
		       int y_size,
		       double * ddy_array, /* array of size x_size*y_size */
		       short spline_mode,
		       ErrorMsg errmsg
		       ) {

  double * p;
  double * qn;
  double * un;
  double * u;

  int index_y;

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

  if (x_size==2) spline_mode = _SPLINE_NATURAL_; // in the case of only 2 x-values, only the natural spline method is appropriate, for _SPLINE_EST_DERIV_ 3 x-values are needed.

  class_setup_parallel();

  for (index_y=0; index_y < y_size; index_y++) {

    class_run_parallel(=,

      double dy_first;
      double dy_last;
      int index_x;
      double sig;
      if (spline_mode == _SPLINE_NATURAL_) {
        ddy_array[index_y*x_size+0] = 0.0;
        u[0*y_size+index_y] = 0.0;
      }
      else {
        dy_first =
          ((x[2]-x[0])*(x[2]-x[0])*
           (y_array[index_y*x_size+1]-y_array[index_y*x_size+0])-
           (x[1]-x[0])*(x[1]-x[0])*
           (y_array[index_y*x_size+2]-y_array[index_y*x_size+0]))/
          ((x[2]-x[0])*(x[1]-x[0])*(x[2]-x[1]));

        ddy_array[index_y*x_size+0] = -0.5;

        u[0*y_size+index_y] =
          (3./(x[1] -  x[0]))*
          ((y_array[index_y*x_size+1]-y_array[index_y*x_size+0])/
           (x[1] - x[0])-dy_first);

      }

      for (index_x=1; index_x < x_size-1; index_x++) {

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

        p[index_y] = sig * ddy_array[index_y*x_size+(index_x-1)] + 2.0;

        ddy_array[index_y*x_size+index_x] = (sig-1.0)/p[index_y];

        u[index_x*y_size+index_y] =
          (y_array[index_y*x_size+(index_x+1)] - y_array[index_y*x_size+index_x])
          / (x[index_x+1] - x[index_x])
          - (y_array[index_y*x_size+index_x] - y_array[index_y*x_size+(index_x-1)])
          / (x[index_x] - x[index_x-1]);

        u[index_x*y_size+index_y] = (6.0 * u[index_x*y_size+index_y] /
                                     (x[index_x+1] - x[index_x-1])
                                     - sig * u[(index_x-1)*y_size+index_y]) / p[index_y];

      }

      if (spline_mode == _SPLINE_NATURAL_) {

        qn[index_y]=un[index_y]=0.0;

      }
      else {

        dy_last =
          ((x[x_size-3]-x[x_size-1])*(x[x_size-3]-x[x_size-1])*
           (y_array[index_y*x_size+(x_size-2)]-y_array[index_y*x_size+(x_size-1)])-
           (x[x_size-2]-x[x_size-1])*(x[x_size-2]-x[x_size-1])*
           (y_array[index_y*x_size+(x_size-3)]-y_array[index_y*x_size+(x_size-1)]))/
          ((x[x_size-3]-x[x_size-1])*(x[x_size-2]-x[x_size-1])*(x[x_size-3]-x[x_size-2]));

        qn[index_y]=0.5;

        un[index_y]=
          (3./(x[x_size-1] - x[x_size-2]))*
          (dy_last-(y_array[index_y*x_size+(x_size-1)] - y_array[index_y*x_size+(x_size-2)])/
           (x[x_size-1] - x[x_size-2]));

      }

      index_x=x_size-1;

      ddy_array[index_y*x_size+index_x] =
        (un[index_y] - qn[index_y] * u[(index_x-1)*y_size+index_y]) /
        (qn[index_y] * ddy_array[index_y*x_size+(index_x-1)] + 1.0);

      for (index_x=x_size-2; index_x >= 0; index_x--) {

        ddy_array[index_y*x_size+index_x] = ddy_array[index_y*x_size+index_x] *
          ddy_array[index_y*x_size+(index_x+1)] + u[index_x*y_size+index_y];

      }
      return _SUCCESS_;
    );
  }

  class_finish_parallel();

  free(qn);
  free(p);
  free(u);
  free(un);

  return _SUCCESS_;
 }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %r9d, 0x8(%rsp)
movq %r8, 0xa0(%rsp)
movl %ecx, %ebx
movq %rdx, 0x98(%rsp)
movq %rdi, 0x90(%rsp)
movq 0x120(%rsp), %r14
movq %rsi, 0x70(%rsp)
leal -0x1(%rsi), %eax
imull %ecx, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, %r15
movl %ebx, 0xc(%rsp)
movslq %ebx, %rbx
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x8460
movq %rax, %r12
movq %rbx, %rdi
callq 0x8460
movq %rax, 0x28(%rsp)
movq %rbx, %rdi
callq 0x8460
movq %rax, 0x20(%rsp)
movq %r15, 0x68(%rsp)
testq %r15, %r15
je 0x16439
testq %r12, %r12
je 0x16477
cmpq $0x0, 0x28(%rsp)
je 0x164b5
cmpq $0x0, 0x20(%rsp)
je 0x1658c
movq %r12, 0x60(%rsp)
xorl %ebp, %ebp
cmpl $0x2, 0x70(%rsp)
movl 0x8(%rsp), %eax
cmovel %ebp, %eax
movl %eax, 0x8(%rsp)
callq 0x1c686
leaq 0xa8(%rsp), %rdi
movl %eax, %esi
callq 0x1c736
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x1654b
xorl %ebp, %ebp
movabsq $0x100000001, %r14      # imm = 0x100000001
leaq 0x13107d(%rip), %rax    # 0x147240
addq $0x10, %rax
movq %rax, 0x88(%rsp)
leaq 0x78(%rsp), %r15
movl $0x20, %edi
callq 0x83b0
movq %rax, %r12
movq %r14, 0x8(%rax)
movq 0x88(%rsp), %rax
movq %rax, (%r12)
movl $0x88, %edi
callq 0x83b0
movq %rax, %r13
movq %r14, 0x8(%rax)
leaq 0x1310bf(%rip), %rax    # 0x1472c8
movq %rax, (%r13)
movq %r13, %rbx
addq $0x10, %rbx
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x1d4aa
movq %rbx, 0x10(%r12)
leaq 0x1310eb(%rip), %rax    # 0x147318
movq %rax, 0x10(%r13)
movl 0x8(%rsp), %eax
movw %ax, 0x38(%r13)
movq 0xa0(%rsp), %rax
movq %rax, 0x40(%r13)
movl %ebp, 0x48(%r13)
movq 0x70(%rsp), %rax
movl %eax, 0x4c(%r13)
movq 0x68(%rsp), %rax
movq %rax, 0x50(%r13)
movl 0xc(%rsp), %eax
movl %eax, 0x58(%r13)
movq 0x90(%rsp), %rax
movq %rax, 0x60(%r13)
movq 0x98(%rsp), %rax
movq %rax, 0x68(%r13)
movq 0x60(%rsp), %rax
movq %rax, 0x70(%r13)
movq 0x28(%rsp), %rax
movq %rax, 0x78(%r13)
movq 0x20(%rsp), %rax
movq %rax, 0x80(%r13)
movq %r13, 0x18(%r12)
movq %r12, %rbx
addq $0x10, %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1d3e8
movq %rbx, 0x30(%rsp)
movq %r12, 0x38(%rsp)
movq 0x132cee(%rip), %rax    # 0x148fb0
cmpb $0x0, (%rax)
je 0x162ce
incl 0x8(%r12)
jmp 0x162d4
lock
incl 0x8(%r12)
movl $0x1, %r13d
lock
xaddl %r13d, 0xc8(%rsp)
movl 0xa8(%rsp), %ecx
testl %ecx, %ecx
je 0x16343
xorl %r15d, %r15d
leal (%r15,%r13), %eax
xorl %edx, %edx
divl %ecx
movq 0xd0(%rsp), %rbx
imulq $0xb0, %rdx, %r14
leaq (%rbx,%r14), %rdi
addq $0x58, %rdi
movq %rdi, 0x10(%rsp)
callq 0x8080
testl %eax, %eax
sete 0x18(%rsp)
je 0x163f8
leaq 0x10(%rsp), %rdi
callq 0x1d204
incl %r15d
movl 0xa8(%rsp), %ecx
cmpl %ecx, %r15d
jb 0x162f2
jmp 0x16345
xorl %ecx, %ecx
movl %r13d, %eax
xorl %edx, %edx
divl %ecx
movq 0xd0(%rsp), %rbx
imulq $0xb0, %rdx, %r14
leaq (%rbx,%r14), %rax
addq $0x58, %rax
movq %rax, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x1d294
leaq 0x78(%rsp), %r15
addq %r14, %rbx
movb $0x1, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0x1c44e
movabsq $0x100000001, %r14      # imm = 0x100000001
leaq 0x10(%rsp), %rdi
callq 0x1d204
subq $-0x80, %rbx
movq %rbx, %rdi
callq 0x81c0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x163c0
callq 0x1d330
movq %r12, %rdi
callq 0x1d330
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x1dd2e
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x163e7
callq 0x1d330
incl %ebp
cmpl 0xc(%rsp), %ebp
jne 0x161d4
jmp 0x164f3
addq %r14, %rbx
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0x1c44e
leaq 0x10(%rsp), %rdi
callq 0x1d204
subq $-0x80, %rbx
movq %rbx, %rdi
callq 0x81c0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
movabsq $0x100000001, %r14      # imm = 0x100000001
leaq 0x78(%rsp), %r15
jne 0x163bb
jmp 0x163c0
leaq 0xd99dd(%rip), %rbx     # 0xefe1d
leaq 0xd9bbc(%rip), %r15     # 0xf0003
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0x431, %r8d            # imm = 0x431
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0x431, %r8d            # imm = 0x431
jmp 0x165c5
leaq 0xd9a53(%rip), %rbx     # 0xefed1
leaq 0xd9b7e(%rip), %r15     # 0xf0003
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0x435, %r8d            # imm = 0x435
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0x435, %r8d            # imm = 0x435
jmp 0x165c5
leaq 0xd9a30(%rip), %rbx     # 0xefeec
leaq 0xd9b40(%rip), %r15     # 0xf0003
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0x439, %r8d            # imm = 0x439
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0x439, %r8d            # imm = 0x439
jmp 0x165c5
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %rbx
xorl %ebp, %ebp
cmpq %rbx, %r14
je 0x16527
movq %r14, %rdi
callq 0x1c7ba
testl %eax, %eax
jne 0x165e5
addq $0x10, %r14
cmpq %rbx, %r14
jne 0x16504
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %rbx
cmpq %r14, %rbx
je 0x1654b
movq %r14, %r15
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x1653d
callq 0x1d330
addq $0x10, %r15
cmpq %rbx, %r15
jne 0x1652f
movq %r14, 0x48(%rsp)
movq 0x28(%rsp), %rdi
callq 0x8410
movq 0x60(%rsp), %rdi
callq 0x8410
movq 0x68(%rsp), %rdi
callq 0x8410
movq 0x20(%rsp), %rdi
callq 0x8410
leaq 0x40(%rsp), %rdi
callq 0x1c806
leaq 0xa8(%rsp), %rdi
callq 0x1c84c
jmp 0x165d1
leaq 0xd9975(%rip), %rbx     # 0xeff08
leaq 0xd9a69(%rip), %r15     # 0xf0003
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0x43d, %r8d            # imm = 0x43D
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0x43d, %r8d            # imm = 0x43D
xorl %eax, %eax
callq 0x8550
movl $0x1, %ebp
movl %ebp, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %ebp
jmp 0x16573
jmp 0x165f5
jmp 0x16637
movq %rax, %rbx
jmp 0x16602
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1d204
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x16611
callq 0x1d330
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x16659
callq 0x1d330
jmp 0x16659
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
jne 0x1665c
jmp 0x16661
movq %rax, %rbx
jmp 0x16661
movq %rax, %rbx
jmp 0x1664c
movq %rax, %rbx
movq %r13, %rdi
callq 0x8380
movq %r12, %rdi
callq 0x8380
jmp 0x16661
movq %rax, %rbx
movq %r12, %rdi
callq 0x1d330
leaq 0x40(%rsp), %rdi
callq 0x1c806
leaq 0xa8(%rsp), %rdi
callq 0x1c84c
movq %rbx, %rdi
callq 0x8650