// File: /workspace/github_c_makefile_star2_O1/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), %r11
movslq %ecx, %r13
movl %r11d, %r10d
imull %esi, %r10d
leaq 0x1(%r11), %rdi
movslq %esi, %r15
imulq %r15, %rdi
movq %r11, %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 0x1968f
leaq -0x1(%r11), %rax
subl %r15d, %r10d
subq %r15, %r12
testq %r11, %r11
movq %rax, %r11
jg 0x19624
movsd (%rbx,%r13,8), %xmm1
leaq 0xd9abf(%rip), %r15     # 0xf310f
leaq 0xd9c6f(%rip), %r12     # 0xf32c6
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 0x19706
decl %edx
movslq %edx, %rbp
leaq (%rbx,%r13,8), %rax
addq %r12, %rdi
movsd (%rax,%rdi,8), %xmm2
ucomisd %xmm2, %xmm0
jbe 0x19719
incq %r11
addl %r15d, %r10d
addq %r15, %rdi
cmpq %rbp, %r11
jl 0x1969b
imull %esi, %edx
addl %ecx, %edx
movslq %edx, %r13
movsd (%rbx,%r13,8), %xmm1
leaq 0xd9a73(%rip), %r15     # 0xf313c
leaq 0xd9bf6(%rip), %r12     # 0xf32c6
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 0x19761
movl %r11d, (%r8)
movslq %r10d, %rax
leaq (%rbx,%rax,8), %rax
movsd (%rax,%r13,8), %xmm1
subsd %xmm1, %xmm0
subsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movslq %r9d, %rcx
movsd 0xd7b20(%rip), %xmm1    # 0xf1260
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