// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_interpolate_spline_one_column
int array_interpolate_spline_one_column(
					double * x_array,
					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,
					int index_y,
					double * ddy_array, /* array of size x_size*y_size */
					double x,   /* input */
					double * y, /* output */
					ErrorMsg errmsg
					) {


  int inf,sup,mid;
  double h,a,b;

  inf=0;
  sup=x_size-1;

  if (x_array[inf] < x_array[sup]){

    if (x < x_array[inf]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[inf]);
      return _FAILURE_;
    }

    if (x > x_array[sup]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[sup]);
      return _FAILURE_;
    }

    while (sup-inf > 1) {

      mid=(int)(0.5*(inf+sup));
      if (x < x_array[mid]) {sup=mid;}
      else {inf=mid;}

    }

  }

  else {

    if (x < x_array[sup]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,x_array[sup]);
      return _FAILURE_;
    }

    if (x > x_array[inf]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,x_array[inf]);
      return _FAILURE_;
    }

    while (sup-inf > 1) {

      mid=(int)(0.5*(inf+sup));
      if (x > x_array[mid]) {sup=mid;}
      else {inf=mid;}

    }

  }

  h = x_array[sup] - x_array[inf];
  b = (x-x_array[inf])/h;
  a = 1-b;

  *y =
    a * y_array[index_y * x_size + inf] +
    b * y_array[index_y * x_size + sup] +
    ((a*a*a-a)* ddy_array[index_y * x_size + inf] +
     (b*b*b-b)* ddy_array[index_y * x_size + sup])*h*h/6.;

  return _SUCCESS_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x48(%rsp), %r14
leal -0x1(%rsi), %eax
movslq %esi, %r13
movsd (%rdi), %xmm1
movsd -0x8(%rdi,%r13,8), %xmm2
decq %r13
ucomisd %xmm1, %xmm2
jbe 0x16bb3
ucomisd %xmm0, %xmm1
jbe 0x16c0b
leaq 0xd056d(%rip), %r15     # 0xe70df
leaq 0xd066a(%rip), %r12     # 0xe71e3
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x85b, %r8d            # imm = 0x85B
movb $0x2, %al
movsd %xmm0, 0x8(%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%rbx), %xmm1
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x85b, %r8d            # imm = 0x85B
jmp 0x16cad
ucomisd %xmm0, %xmm2
jbe 0x16c60
leaq 0xd051b(%rip), %r15     # 0xe70df
leaq 0xd0618(%rip), %r12     # 0xe71e3
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x871, %r8d            # imm = 0x871
movapd %xmm2, %xmm1
movb $0x2, %al
movsd %xmm0, 0x8(%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%rbx,%r13,8), %xmm1
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x871, %r8d            # imm = 0x871
jmp 0x16cad
ucomisd %xmm2, %xmm0
jbe 0x16cc2
leaq 0xd04f0(%rip), %r15     # 0xe710c
leaq 0xd05c0(%rip), %r12     # 0xe71e3
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x860, %r8d            # imm = 0x860
movapd %xmm2, %xmm1
movb $0x2, %al
movsd %xmm0, 0x8(%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%rbx,%r13,8), %xmm1
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x860, %r8d            # imm = 0x860
jmp 0x16cad
ucomisd %xmm1, %xmm0
jbe 0x16cfa
leaq 0xd049b(%rip), %r15     # 0xe710c
leaq 0xd056b(%rip), %r12     # 0xe71e3
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x876, %r8d            # imm = 0x876
movb $0x2, %al
movsd %xmm0, 0x8(%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%rbx), %xmm1
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x876, %r8d            # imm = 0x876
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x8580
pushq $0x1
popq %rax
jmp 0x16dc9
xorl %ecx, %ecx
movsd 0xcefe4(%rip), %xmm2    # 0xe5cb0
movl %eax, %edi
subl %ecx, %edi
cmpl $0x2, %edi
jl 0x16d2e
leal (%rcx,%rax), %edi
cvtsi2sd %edi, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %edi
movslq %edi, %rdi
movsd (%rbx,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %edi, %eax
cmoval %ecx, %edi
movl %edi, %ecx
jmp 0x16ccc
xorl %ecx, %ecx
movsd 0xcefac(%rip), %xmm2    # 0xe5cb0
movl %eax, %edi
subl %ecx, %edi
cmpl $0x2, %edi
jl 0x16d2e
leal (%rcx,%rax), %edi
cvtsi2sd %edi, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %edi
movslq %edi, %rdi
ucomisd (%rbx,%rdi,8), %xmm0
cmoval %edi, %eax
cmoval %ecx, %edi
movl %edi, %ecx
jmp 0x16d04
cltq
movsd (%rbx,%rax,8), %xmm5
movslq %ecx, %rcx
movsd (%rbx,%rcx,8), %xmm1
subsd %xmm1, %xmm5
subsd %xmm1, %xmm0
divsd %xmm5, %xmm0
movsd 0xce50f(%rip), %xmm2    # 0xe5260
subsd %xmm0, %xmm2
imull %esi, %r8d
addl %r8d, %ecx
movslq %ecx, %rcx
addl %r8d, %eax
cltq
movsd (%rdx,%rax,8), %xmm1
mulsd %xmm0, %xmm1
movsd (%rdx,%rcx,8), %xmm3
mulsd %xmm2, %xmm3
movapd %xmm2, %xmm4
mulsd %xmm2, %xmm4
mulsd %xmm2, %xmm4
subsd %xmm2, %xmm4
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
subsd %xmm0, %xmm2
mulsd (%r9,%rax,8), %xmm2
movq 0x40(%rsp), %rax
mulsd (%r9,%rcx,8), %xmm4
addsd %xmm2, %xmm4
mulsd %xmm5, %xmm4
mulsd %xmm5, %xmm4
divsd 0xcf895(%rip), %xmm4    # 0xe6650
addsd %xmm1, %xmm3
addsd %xmm3, %xmm4
movsd %xmm4, (%rax)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq