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

  int inf,sup,i;
  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));

  for (i=0; i<result_size; i++)
    *(result+i) = *(array+inf*n_columns+i) * (1.-weight)
      + weight * *(array+sup*n_columns+i);

  *(result+index_x) = x;

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x40(%rsp), %eax
movq %r8, (%rsp)
movslq (%r8), %r10
movslq %ecx, %r13
movslq %esi, %r8
leaq 0x1(%r10), %r15
imulq %r8, %r15
shlq $0x3, %r15
leaq (,%r8,8), %r11
movq %r11, %r12
negq %r12
imulq %r10, %r8
leaq (,%r13,8), %r14
leaq (%r14,%r8,8), %r14
movl %r10d, %ebp
imull %esi, %ebp
movq %rdi, %r8
movsd (%rdi,%r14), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1754f
leaq -0x1(%r10), %rbx
subl %esi, %ebp
addq %r12, %rdi
testq %r10, %r10
movq %rbx, %r10
jg 0x174e1
movq %r8, %rbx
movsd (%r8,%r13,8), %xmm1
leaq 0xcfbd1(%rip), %r15     # 0xe70df
leaq 0xcfd5f(%rip), %r12     # 0xe7274
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x97b, %r8d            # imm = 0x97B
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%rbx,%r13,8), %xmm1
movq 0x48(%rsp), %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x97b, %r8d            # imm = 0x97B
jmp 0x175c7
decl %edx
movslq %edx, %r12
addq %r15, %rdi
movsd (%rdi,%r13,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x175d8
incq %r10
addq %r11, %rdi
addl %esi, %ebp
cmpq %r12, %r10
jl 0x17557
imull %esi, %edx
addl %ecx, %edx
movslq %edx, %rbx
movq %r8, %r14
movsd (%r8,%rbx,8), %xmm1
leaq 0xcfb84(%rip), %r15     # 0xe710c
leaq 0xcfce5(%rip), %r12     # 0xe7274
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x984, %r8d            # imm = 0x984
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%r14,%rbx,8), %xmm1
movq 0x48(%rsp), %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x984, %r8d            # imm = 0x984
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x8580
pushq $0x1
popq %rax
jmp 0x17640
movq (%rsp), %rcx
movl %r10d, (%rcx)
movslq %ebp, %rcx
leaq (%r8,%rcx,8), %rcx
movsd (%rcx,%r13,8), %xmm2
movapd %xmm0, %xmm4
subsd %xmm2, %xmm4
subsd %xmm2, %xmm1
divsd %xmm1, %xmm4
movsd 0xcdc5c(%rip), %xmm1    # 0xe5260
subsd %xmm4, %xmm1
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
cmpq %rdx, %rax
je 0x17638
movsd (%rdi), %xmm2
mulsd %xmm4, %xmm2
movsd (%rcx,%rdx,8), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%r9,%rdx,8)
incq %rdx
addq $0x8, %rdi
jmp 0x1760f
movsd %xmm0, (%r9,%r13,8)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq