// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_interpolate_extrapolate_spline_one_column
int array_interpolate_extrapolate_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;

  if (x > x_array[x_size-2] || x < x_array[0]) {

    /*interpolate/extrapolate linearly y as a function of x*/

    h = x_array[x_size-1] - x_array[x_size-2];
    b = (x-x_array[x_size-2])/h;
    a = 1-b;

    *y = a * y_array[index_y * x_size + (x_size-2)] +
	     b * y_array[index_y * x_size + (x_size-1)];


  }

  else {

    /*interpolate y as a function of x with a spline*/

    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:
subq $0x78, %rsp
movq 0x88(%rsp), %rax
movq 0x80(%rsp), %rax
movq %rdi, 0x68(%rsp)
movl %esi, 0x64(%rsp)
movq %rdx, 0x58(%rsp)
movl %ecx, 0x54(%rsp)
movl %r8d, 0x50(%rsp)
movq %r9, 0x48(%rsp)
movsd %xmm0, 0x40(%rsp)
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
ucomisd (%rax,%rcx,8), %xmm0
ja 0x25cdb
movsd 0x40(%rsp), %xmm1
movq 0x68(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x25da6
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
divsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x1ac511(%rip), %xmm0   # 0x1d2248
subsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm0
movq 0x58(%rsp), %rax
movl 0x50(%rsp), %ecx
imull 0x64(%rsp), %ecx
movl 0x64(%rsp), %edx
subl $0x2, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x18(%rsp), %xmm1
movq 0x58(%rsp), %rax
movl 0x50(%rsp), %ecx
imull 0x64(%rsp), %ecx
movl 0x64(%rsp), %edx
subl $0x1, %edx
addl %edx, %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x80(%rsp), %rax
movsd %xmm0, (%rax)
jmp 0x262b7
movl $0x0, 0x3c(%rsp)
movl 0x64(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x38(%rsp)
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x68(%rsp), %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x25f96
movsd 0x40(%rsp), %xmm1
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x25e8c
jmp 0x25e02
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
xorl %eax, %eax
movl %eax, %esi
leaq 0x1ae2e4(%rip), %rdx    # 0x1d4106
leaq 0x1ae405(%rip), %rcx    # 0x1d422e
movl $0x8bf, %r8d            # imm = 0x8BF
movq %rsi, %rdi
movb $0x2, %al
callq 0x8540
movl %eax, 0x14(%rsp)
movq 0x88(%rsp), %rdi
movl 0x14(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x1ae29b(%rip), %rdx    # 0x1d4106
leaq 0x1ae3bc(%rip), %rcx    # 0x1d422e
movl $0x8bf, %r8d            # imm = 0x8BF
movb $0x2, %al
callq 0x8540
movl $0x1, 0x74(%rsp)
jmp 0x262bf
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x38(%rsp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x25f33
jmp 0x25ea9
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
xorl %eax, %eax
movl %eax, %esi
leaq 0x1ae26a(%rip), %rdx    # 0x1d4133
leaq 0x1ae35e(%rip), %rcx    # 0x1d422e
movl $0x8c4, %r8d            # imm = 0x8C4
movq %rsi, %rdi
movb $0x2, %al
callq 0x8540
movl %eax, 0x10(%rsp)
movq 0x88(%rsp), %rdi
movl 0x10(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x1ae221(%rip), %rdx    # 0x1d4133
leaq 0x1ae315(%rip), %rcx    # 0x1d422e
movl $0x8c4, %r8d            # imm = 0x8C4
movb $0x2, %al
callq 0x8540
movl $0x1, 0x74(%rsp)
jmp 0x262bf
jmp 0x25f35
movl 0x38(%rsp), %eax
subl 0x3c(%rsp), %eax
cmpl $0x1, %eax
jle 0x25f91
movl 0x3c(%rsp), %eax
addl 0x38(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x1acd32(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x34(%rsp)
movsd 0x40(%rsp), %xmm1
movq 0x68(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x25f87
movl 0x34(%rsp), %eax
movl %eax, 0x38(%rsp)
jmp 0x25f8f
movl 0x34(%rsp), %eax
movl %eax, 0x3c(%rsp)
jmp 0x25f35
jmp 0x26144
movsd 0x40(%rsp), %xmm1
movq 0x68(%rsp), %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x26041
jmp 0x25fb7
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
xorl %eax, %eax
movl %eax, %esi
leaq 0x1ae12f(%rip), %rdx    # 0x1d4106
leaq 0x1ae250(%rip), %rcx    # 0x1d422e
movl $0x8d5, %r8d            # imm = 0x8D5
movq %rsi, %rdi
movb $0x2, %al
callq 0x8540
movl %eax, 0xc(%rsp)
movq 0x88(%rsp), %rdi
movl 0xc(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x1ae0e6(%rip), %rdx    # 0x1d4106
leaq 0x1ae207(%rip), %rcx    # 0x1d422e
movl $0x8d5, %r8d            # imm = 0x8D5
movb $0x2, %al
callq 0x8540
movl $0x1, 0x74(%rsp)
jmp 0x262bf
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x260e8
jmp 0x2605e
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
xorl %eax, %eax
movl %eax, %esi
leaq 0x1ae0b5(%rip), %rdx    # 0x1d4133
leaq 0x1ae1a9(%rip), %rcx    # 0x1d422e
movl $0x8da, %r8d            # imm = 0x8DA
movq %rsi, %rdi
movb $0x2, %al
callq 0x8540
movl %eax, 0x8(%rsp)
movq 0x88(%rsp), %rdi
movl 0x8(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x1ae06c(%rip), %rdx    # 0x1d4133
leaq 0x1ae160(%rip), %rcx    # 0x1d422e
movl $0x8da, %r8d            # imm = 0x8DA
movb $0x2, %al
callq 0x8540
movl $0x1, 0x74(%rsp)
jmp 0x262bf
jmp 0x260ea
movl 0x38(%rsp), %eax
subl 0x3c(%rsp), %eax
cmpl $0x1, %eax
jle 0x26142
movl 0x3c(%rsp), %eax
addl 0x38(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x1acb7d(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x34(%rsp)
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x34(%rsp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x26138
movl 0x34(%rsp), %eax
movl %eax, 0x38(%rsp)
jmp 0x26140
movl 0x34(%rsp), %eax
movl %eax, 0x3c(%rsp)
jmp 0x260ea
jmp 0x26144
movq 0x68(%rsp), %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x3c(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
divsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x1ac0b7(%rip), %xmm0   # 0x1d2248
subsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm0
movq 0x58(%rsp), %rax
movl 0x50(%rsp), %ecx
imull 0x64(%rsp), %ecx
addl 0x3c(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x18(%rsp), %xmm1
movq 0x58(%rsp), %rax
movl 0x50(%rsp), %ecx
imull 0x64(%rsp), %ecx
addl 0x38(%rsp), %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x20(%rsp), %xmm1
mulsd 0x20(%rsp), %xmm1
movsd 0x20(%rsp), %xmm3
movsd 0x20(%rsp), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movq 0x48(%rsp), %rax
movl 0x50(%rsp), %ecx
imull 0x64(%rsp), %ecx
addl 0x3c(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm3
movsd 0x18(%rsp), %xmm2
mulsd 0x18(%rsp), %xmm2
movsd 0x18(%rsp), %xmm5
movsd 0x18(%rsp), %xmm4
movq %xmm4, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm4
mulsd %xmm5, %xmm2
addsd %xmm4, %xmm2
movq 0x48(%rsp), %rax
movl 0x50(%rsp), %ecx
imull 0x64(%rsp), %ecx
addl 0x38(%rsp), %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd 0x28(%rsp), %xmm1
mulsd 0x28(%rsp), %xmm1
movsd 0x1ad3e5(%rip), %xmm2   # 0x1d3688
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0x80(%rsp), %rax
movsd %xmm0, (%rax)
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax,%rax)