// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_interpolate_spline_growing_hunt
int array_interpolate_spline_growing_hunt(
					     double * x_array,
					     int n_lines,
					     double * array,
					     double * array_splined,
					     int n_columns,
					     double x,
					     int * last_index,
					     double * result,
					     int result_size, /** from 1 to n_columns */
					     ErrorMsg errmsg) {

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

  inc=1;

  if (x >= x_array[*last_index]) {
    if (x > x_array[n_lines-1]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,
	      x,x_array[n_lines-1]);
      return _FAILURE_;
    }
    /* try closest neighboor upward */
    inf = *last_index;
    sup = inf + inc;
    if (x > x_array[sup]) {
      /* hunt upward */
      while (x > x_array[sup]) {
	inf = sup;
	inc += 1;
	sup += inc;
	if (sup > n_lines-1) {
	  sup = n_lines-1;
	}
      }
      /* bisect */
      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[0]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,
	      x,x_array[0]);
      return _FAILURE_;
    }
    /* try closest neighboor downward */
    sup = *last_index;
    inf = sup - inc;
    if (x < x_array[inf]) {
      /* hunt downward */
      while (x < x_array[inf]) {
	sup = inf;
	inc += 1;
	inf -= inc;
	if (inf < 0) {
	  inf = 0;
	}
      }
      /* bisect */
      while (sup-inf > 1) {
	mid=(int)(0.5*(inf+sup));
	if (x < x_array[mid]) {sup=mid;}
	else {inf=mid;}
      }
    }
  }

  *last_index = inf;

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

  for (i=0; i<result_size; i++)
    *(result+i) =
      a * *(array+inf*n_columns+i) +
      b * *(array+sup*n_columns+i) +
      ((a*a*a-a)* *(array_splined+inf*n_columns+i) +
       (b*b*b-b)* *(array_splined+sup*n_columns+i))*h*h/6.;

  return _SUCCESS_;
}

// Assembly:
subq $0x78, %rsp
movq 0x90(%rsp), %rax
movl 0x88(%rsp), %eax
movq 0x80(%rsp), %rax
movq %rdi, 0x68(%rsp)
movl %esi, 0x64(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movl %r8d, 0x4c(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r9, 0x38(%rsp)
movl $0x1, 0x24(%rsp)
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movq 0x38(%rsp), %rcx
movslq (%rcx), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jb 0x27a85
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x2799a
jmp 0x27906
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
xorl %eax, %eax
movl %eax, %esi
leaq 0x1ac808(%rip), %rdx    # 0x1d4133
leaq 0x1aca16(%rip), %rcx    # 0x1d4348
movl $0xa28, %r8d            # imm = 0xA28
movq %rsi, %rdi
movb $0x2, %al
callq 0x8540
movl %eax, 0x4(%rsp)
movq 0x90(%rsp), %rdi
movl 0x4(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
leaq 0x1ac7ba(%rip), %rdx    # 0x1d4133
leaq 0x1ac9c8(%rip), %rcx    # 0x1d4348
movl $0xa28, %r8d            # imm = 0xA28
movb $0x2, %al
callq 0x8540
movl $0x1, 0x74(%rsp)
jmp 0x27dd4
movq 0x38(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
addl 0x24(%rsp), %eax
movl %eax, 0x30(%rsp)
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x30(%rsp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x27a80
jmp 0x279ce
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x30(%rsp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x27a20
movl 0x30(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
addl 0x30(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x30(%rsp), %eax
movl 0x64(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x27a1e
movl 0x64(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x279ce
jmp 0x27a22
movl 0x30(%rsp), %eax
subl 0x34(%rsp), %eax
cmpl $0x1, %eax
jle 0x27a7e
movl 0x34(%rsp), %eax
addl 0x30(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x1ab245(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x2c(%rsp)
movsd 0x40(%rsp), %xmm1
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x27a74
movl 0x2c(%rsp), %eax
movl %eax, 0x30(%rsp)
jmp 0x27a7c
movl 0x2c(%rsp), %eax
movl %eax, 0x34(%rsp)
jmp 0x27a22
jmp 0x27a80
jmp 0x27bff
movsd 0x40(%rsp), %xmm1
movq 0x68(%rsp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x27b18
jmp 0x27a9c
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movsd (%rax), %xmm1
xorl %eax, %eax
movl %eax, %esi
leaq 0x1ac650(%rip), %rdx    # 0x1d4106
leaq 0x1ac88b(%rip), %rcx    # 0x1d4348
movl $0xa43, %r8d            # imm = 0xA43
movq %rsi, %rdi
movb $0x2, %al
callq 0x8540
movl %eax, (%rsp)
movq 0x90(%rsp), %rdi
movl (%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movsd (%rax), %xmm1
leaq 0x1ac60f(%rip), %rdx    # 0x1d4106
leaq 0x1ac84a(%rip), %rcx    # 0x1d4348
movl $0xa43, %r8d            # imm = 0xA43
movb $0x2, %al
callq 0x8540
movl $0x1, 0x74(%rsp)
jmp 0x27dd4
movq 0x38(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x30(%rsp)
movl 0x30(%rsp), %eax
subl 0x24(%rsp), %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 0x27bfd
jmp 0x27b50
movsd 0x40(%rsp), %xmm1
movq 0x68(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x27b9d
movl 0x34(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %ecx
movl 0x34(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jge 0x27b9b
movl $0x0, 0x34(%rsp)
jmp 0x27b50
jmp 0x27b9f
movl 0x30(%rsp), %eax
subl 0x34(%rsp), %eax
cmpl $0x1, %eax
jle 0x27bfb
movl 0x34(%rsp), %eax
addl 0x30(%rsp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x1ab0c8(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x2c(%rsp)
movsd 0x40(%rsp), %xmm1
movq 0x68(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x27bf1
movl 0x2c(%rsp), %eax
movl %eax, 0x30(%rsp)
jmp 0x27bf9
movl 0x2c(%rsp), %eax
movl %eax, 0x34(%rsp)
jmp 0x27b9f
jmp 0x27bfd
jmp 0x27bff
movl 0x34(%rsp), %ecx
movq 0x38(%rsp), %rax
movl %ecx, (%rax)
movq 0x68(%rsp), %rax
movslq 0x30(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x68(%rsp), %rax
movslq 0x34(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x40(%rsp), %xmm0
movq 0x68(%rsp), %rax
movslq 0x34(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
divsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x1aa5f1(%rip), %xmm0   # 0x1d2248
subsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x88(%rsp), %eax
jge 0x27dcc
movsd 0x10(%rsp), %xmm0
movq 0x58(%rsp), %rax
movl 0x34(%rsp), %ecx
imull 0x4c(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x28(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x8(%rsp), %xmm1
movq 0x58(%rsp), %rax
movl 0x30(%rsp), %ecx
imull 0x4c(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x28(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm1
mulsd 0x10(%rsp), %xmm1
movsd 0x10(%rsp), %xmm3
movsd 0x10(%rsp), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movq 0x50(%rsp), %rax
movl 0x34(%rsp), %ecx
imull 0x4c(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x28(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm3
movsd 0x8(%rsp), %xmm2
mulsd 0x8(%rsp), %xmm2
movsd 0x8(%rsp), %xmm5
movsd 0x8(%rsp), %xmm4
movq %xmm4, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm4
mulsd %xmm5, %xmm2
addsd %xmm4, %xmm2
movq 0x50(%rsp), %rax
movl 0x30(%rsp), %ecx
imull 0x4c(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x28(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd 0x18(%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
movsd 0x1ab8e6(%rip), %xmm2   # 0x1d3688
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0x80(%rsp), %rax
movslq 0x28(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x27c6b
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax)