// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_interpolate_one_growing_closeby
int array_interpolate_one_growing_closeby(
		   double * array,
		   int n_columns,
		   int n_lines,
		   int index_x,   /** from 0 to (n_columns-1) */
		   double x,
		   int * last_index,
           int index_y,
		   double * result,
		   ErrorMsg errmsg) {

  int inf,sup;
  double weight;

  inf = *last_index;
  sup = *last_index+1;

  while (x < *(array+inf*n_columns+index_x)) {
    inf--;
    if (inf < 0) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,
	      x,array[index_x]);
      return _FAILURE_;
    }
  }
  sup = inf+1;
  while (x > *(array+sup*n_columns+index_x)) {
    sup++;
    if (sup > (n_lines-1)) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,
	      x,array[(n_lines-1)*n_columns+index_x]);
      return _FAILURE_;
    }
  }
  inf = sup-1;

  *last_index = inf;

  weight=(x-*(array+inf*n_columns+index_x))/(*(array+sup*n_columns+index_x)-*(array+inf*n_columns+index_x));

  *result = *(array+inf*n_columns+index_y) * (1.-weight) + *(array+sup*n_columns+index_y) * weight;

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x48(%rsp), %r14
movslq (%r8), %r10
movslq %ecx, %r13
movslq %esi, %r15
movl %r15d, %r11d
imull %r10d, %r11d
leaq 0x1(%r10), %rdi
imulq %r15, %rdi
movq %r10, %rax
imulq %r15, %rax
leaq (,%r13,8), %r12
leaq (%r12,%rax,8), %rbp
addq %rbx, %rbp
xorl %r12d, %r12d
movsd (%rbp,%r12,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1981a
leaq -0x1(%r10), %rax
subl %r15d, %r11d
subq %r15, %r12
testq %r10, %r10
movq %rax, %r10
jg 0x197af
movsd (%rbx,%r13,8), %xmm1
leaq 0xd6944(%rip), %r15     # 0xf011f
leaq 0xd6af4(%rip), %r12     # 0xf02d6
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x9b1, %r8d            # imm = 0x9B1
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8550
incl %eax
movslq %eax, %rsi
movsd (%rbx,%r13,8), %xmm1
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x9b1, %r8d            # imm = 0x9B1
jmp 0x19891
decl %edx
movslq %edx, %rbp
leaq (%rbx,%r13,8), %rax
addq %r12, %rdi
movsd (%rax,%rdi,8), %xmm2
ucomisd %xmm2, %xmm0
jbe 0x198a4
incq %r10
addl %r15d, %r11d
addq %r15, %rdi
cmpq %rbp, %r10
jl 0x19826
imull %esi, %edx
addl %ecx, %edx
movslq %edx, %r13
movsd (%rbx,%r13,8), %xmm1
leaq 0xd68f8(%rip), %r15     # 0xf014c
leaq 0xd6a7b(%rip), %r12     # 0xf02d6
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x9ba, %r8d            # imm = 0x9BA
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8550
incl %eax
movslq %eax, %rsi
movsd (%rbx,%r13,8), %xmm1
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x9ba, %r8d            # imm = 0x9BA
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x8550
movl $0x1, %eax
jmp 0x198ec
movl %r10d, (%r8)
movslq %r11d, %rax
leaq (%rbx,%rax,8), %rax
movsd (%rax,%r13,8), %xmm1
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movslq %r9d, %rcx
movsd 0xd4995(%rip), %xmm1    # 0xee260
subsd %xmm0, %xmm1
leaq (%rbx,%rcx,8), %rdx
mulsd (%rdx,%rdi,8), %xmm0
mulsd (%rax,%rcx,8), %xmm1
addsd %xmm0, %xmm1
movq 0x40(%rsp), %rax
movsd %xmm1, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq