// File: /workspace/github_c_makefile_star2_O2/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 $0x118, %rsp            # imm = 0x118
movl %r9d, 0x10(%rsp)
movq %r8, 0xd0(%rsp)
movl %ecx, %ebp
movq %rdx, 0xc8(%rsp)
movq %rdi, 0xc0(%rsp)
movq 0x150(%rsp), %rbx
movq %rsi, 0x68(%rsp)
leal -0x1(%rsi), %eax
imull %ecx, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x8490
movq %rax, %r15
movl %ebp, 0x18(%rsp)
movslq %ebp, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x8490
movq %rax, %r12
movq %r14, %rdi
callq 0x8490
movq %rax, 0x48(%rsp)
movq %r14, %rdi
callq 0x8490
movq %rax, 0x40(%rsp)
movq %r15, 0x60(%rsp)
testq %r15, %r15
je 0x145b6
testq %r12, %r12
je 0x145f4
cmpq $0x0, 0x48(%rsp)
je 0x14663
cmpq $0x0, 0x40(%rsp)
je 0x1469e
movq %r12, 0x58(%rsp)
xorl %r15d, %r15d
cmpl $0x2, 0x68(%rsp)
movl 0x10(%rsp), %eax
cmovel %r15d, %eax
movl %eax, 0x10(%rsp)
callq 0x1a2a0
leaq 0xd8(%rsp), %rdi
movl %eax, %esi
callq 0x1a33e
leaq 0xa0(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movl 0x18(%rsp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movl %ecx, 0x54(%rsp)
leaq 0xf(%rsp), %rbx
movabsq $0x100000001, %r13      # imm = 0x100000001
leaq 0x12cf0d(%rip), %rax    # 0x141220
addq $0x10, %rax
movq %rax, 0xb8(%rsp)
leaq 0x30(%rsp), %r14
cmpl 0x54(%rsp), %r15d
je 0x14632
movl %r15d, 0x1c(%rsp)
andq $0x0, 0x70(%rsp)
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x1b0f6
movq %rax, %r12
movq %rbx, 0x90(%rsp)
movq %rax, 0x98(%rsp)
movq %r13, 0x8(%rax)
movq 0xb8(%rsp), %rax
movq %rax, (%r12)
movl $0x88, %edi
callq 0x83d0
movq %rax, %rbx
leaq 0x17(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movq %r13, %r15
movq %r13, 0x8(%rbx)
leaq 0x12cf16(%rip), %rax    # 0x1412a8
movq %rax, (%rbx)
movq %rbx, %rbp
addq $0x10, %rbp
movq %rbp, %rdi
leaq 0x16(%rsp), %rsi
callq 0x1b18a
movq %r12, %r13
addq $0x10, %r13
leaq 0x12cf41(%rip), %rax    # 0x1412f8
movq %rax, 0x10(%rbx)
movl 0x10(%rsp), %eax
movw %ax, 0x38(%rbx)
movq 0xd0(%rsp), %rax
movq %rax, 0x40(%rbx)
movl 0x1c(%rsp), %eax
movl %eax, 0x48(%rbx)
movq 0x68(%rsp), %rax
movl %eax, 0x4c(%rbx)
movq 0x60(%rsp), %rax
movq %rax, 0x50(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x58(%rbx)
movq 0xc0(%rsp), %rax
movq %rax, 0x60(%rbx)
movq 0xc8(%rsp), %rax
movq %rax, 0x68(%rbx)
movq 0x58(%rsp), %rax
movq %rax, 0x70(%rbx)
movq 0x48(%rsp), %rax
movq %rax, 0x78(%rbx)
movq 0x40(%rsp), %rax
movq %rax, 0x80(%rbx)
andq $0x0, 0x38(%rsp)
movq %r14, %rdi
callq 0x199be
movq %rbp, 0x10(%r12)
andq $0x0, 0x28(%rsp)
movq %rbx, 0x18(%r12)
andq $0x0, 0x20(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x1afb0
andq $0x0, 0x98(%rsp)
movq %r12, 0x78(%rsp)
movq %r13, 0x70(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x1b0e8
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x1b09c
leaq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x1b986
pushq $0x1
popq %rax
movl %eax, %r12d
lock
xaddl %r12d, 0xf8(%rsp)
xorl %r13d, %r13d
movl 0xd8(%rsp), %ecx
cmpl %ecx, %r13d
jae 0x144ee
leal (%r12,%r13), %eax
xorl %edx, %edx
divl %ecx
movq 0x100(%rsp), %rbx
imulq $0xb0, %rdx, %rbp
leaq (%rbx,%rbp), %rdi
addq $0x58, %rdi
movq %rdi, 0x30(%rsp)
callq 0x1add8
movb %al, 0x38(%rsp)
testb %al, %al
jne 0x14547
movq %r14, %rdi
callq 0x1adc2
incl %r13d
jmp 0x144a4
movl %r12d, %eax
xorl %edx, %edx
divl %ecx
movq 0x100(%rsp), %rbx
imulq $0xb0, %rdx, %r12
leaq (%rbx,%r12), %rsi
addq $0x58, %rsi
movq %r14, %rdi
callq 0x1ae48
movq %r15, %r13
addq %r12, %rbx
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1a0f2
movq %r14, %rdi
callq 0x1adc2
subq $-0x80, %rbx
movq %rbx, %rdi
callq 0x81e0
leaq 0x28(%rsp), %rdi
callq 0x1afb0
jmp 0x14578
addq %rbp, %rbx
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1a0f2
movq %r14, %rdi
callq 0x1adc2
subq $-0x80, %rbx
movq %rbx, %rdi
callq 0x81e0
leaq 0x28(%rsp), %rdi
callq 0x1afb0
movq %r15, %r13
leaq 0x78(%rsp), %rdi
callq 0x1afb0
leaq 0xa0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1bb4a
leaq 0xf(%rsp), %rbx
leaq 0x88(%rsp), %rdi
callq 0x1afb0
movl 0x1c(%rsp), %r15d
incl %r15d
jmp 0x14324
leaq 0xd2820(%rip), %r14     # 0xe6ddd
leaq 0xd29ff(%rip), %r15     # 0xe6fc3
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x431, %r8d            # imm = 0x431
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x431, %r8d            # imm = 0x431
jmp 0x146d7
leaq 0xd2896(%rip), %r14     # 0xe6e91
leaq 0xd29c1(%rip), %r15     # 0xe6fc3
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x435, %r8d            # imm = 0x435
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x435, %r8d            # imm = 0x435
jmp 0x146d7
movq 0xa0(%rsp), %rbx
movq 0xa8(%rsp), %r14
cmpq %r14, %rbx
je 0x146f5
movq %rbx, %rdi
callq 0x1a3be
addq $0x10, %rbx
testl %eax, %eax
je 0x14642
pushq $0x1
popq %rbx
jmp 0x1472c
leaq 0xd2842(%rip), %r14     # 0xe6eac
leaq 0xd2952(%rip), %r15     # 0xe6fc3
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x439, %r8d            # imm = 0x439
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x439, %r8d            # imm = 0x439
jmp 0x146d7
leaq 0xd2823(%rip), %r14     # 0xe6ec8
leaq 0xd2917(%rip), %r15     # 0xe6fc3
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x43d, %r8d            # imm = 0x43D
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x43d, %r8d            # imm = 0x43D
xorl %eax, %eax
callq 0x8580
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa0(%rsp), %rdi
callq 0x1a3f0
movq 0x48(%rsp), %rdi
callq 0x8430
movq 0x58(%rsp), %rdi
callq 0x8430
movq 0x60(%rsp), %rdi
callq 0x8430
movq 0x40(%rsp), %rdi
callq 0x8430
xorl %ebx, %ebx
leaq 0xa0(%rsp), %rdi
callq 0x1a3f8
leaq 0xd8(%rsp), %rdi
callq 0x1a41a
jmp 0x146e1
jmp 0x1474c
jmp 0x14793
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x1adc2
jmp 0x1475e
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x1afb0
leaq 0x88(%rsp), %rdi
callq 0x1afb0
jmp 0x1477a
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0x1478c
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x1afb0
jmp 0x147b7
movq %rax, %rbx
jmp 0x147b7
movq %rax, %rbx
jmp 0x147aa
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x199be
leaq 0x90(%rsp), %rdi
callq 0x1b0e8
leaq 0xa0(%rsp), %rdi
callq 0x1a3f8
leaq 0xd8(%rsp), %rdi
callq 0x1a41a
movq %rbx, %rdi
callq 0x8680