// File: /workspace/github_c_makefile_star2_O3/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
movq %rdi, %rbx
movslq (%r8), %r10
movslq %ecx, %r13
movslq %esi, %rax
leaq 0x1(%r10), %r15
imulq %rax, %r15
shlq $0x3, %r15
leaq (,%rax,8), %r11
movq %r11, %r12
negq %r12
imulq %r10, %rax
leaq (,%r13,8), %r14
leaq (%r14,%rax,8), %r14
movl %r10d, %ebp
imull %esi, %ebp
movq %rdi, %rax
movsd (%rax,%r14), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1966d
leaq -0x1(%r10), %rdi
subl %esi, %ebp
addq %r12, %rax
testq %r10, %r10
movq %rdi, %r10
jg 0x19602
movsd (%rbx,%r13,8), %xmm1
leaq 0xd6af3(%rip), %r15     # 0xf011f
leaq 0xd6c81(%rip), %r12     # 0xf02b4
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x97b, %r8d            # imm = 0x97B
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8550
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 0x196e2
decl %edx
movslq %edx, %r12
addq %r15, %rax
movsd (%rax,%r13,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x196f5
incq %r10
addq %r11, %rax
addl %esi, %ebp
cmpq %r12, %r10
jl 0x19675
imull %esi, %edx
addl %ecx, %edx
movslq %edx, %r14
movsd (%rbx,%r14,8), %xmm1
leaq 0xd6aa9(%rip), %r15     # 0xf014c
leaq 0xd6c0a(%rip), %r12     # 0xf02b4
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x984, %r8d            # imm = 0x984
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8550
incl %eax
movslq %eax, %rsi
movsd (%rbx,%r14,8), %xmm1
movq 0x48(%rsp), %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0x984, %r8d            # imm = 0x984
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x8550
movl $0x1, %eax
jmp 0x1975c
movl %r10d, (%r8)
movl 0x40(%rsp), %edx
testl %edx, %edx
jle 0x19754
movslq %ebp, %rcx
leaq (%rbx,%rcx,8), %rcx
movsd (%rcx,%r13,8), %xmm2
movapd %xmm0, %xmm4
subsd %xmm2, %xmm4
subsd %xmm2, %xmm1
divsd %xmm1, %xmm4
movsd 0xd4b3b(%rip), %xmm1    # 0xee260
subsd %xmm4, %xmm1
movl %edx, %edx
xorl %esi, %esi
movsd (%rax), %xmm2
mulsd %xmm4, %xmm2
movsd (%rcx,%rsi,8), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%r9,%rsi,8)
incq %rsi
addq $0x8, %rax
cmpq %rsi, %rdx
jne 0x1972d
movsd %xmm0, (%r9,%r13,8)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq