// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_interpolate_two
int array_interpolate_two(
		   double * array_x,
		   int n_columns_x,
		   int index_x,   /** from 0 to (n_columns_x-1) */
		   double * array_y,
		   int n_columns_y,
		   int n_lines,  /** must be the same for array_x and array_y */
		   double x,
		   double * result,
		   int result_size, /** from 1 to n_columns_y */
		   ErrorMsg errmsg) {

  int inf,sup,mid,i;
  double weight;

  inf=0;
  sup=n_lines-1;

  if (array_x[inf*n_columns_x+index_x] < array_x[sup*n_columns_x+index_x]){

    if (x < array_x[inf*n_columns_x+index_x]) {

      class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,array_x[inf*n_columns_x+index_x]);
      return _FAILURE_;
    }

    if (x > array_x[sup*n_columns_x+index_x]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,array_x[sup*n_columns_x+index_x]);
      return _FAILURE_;
    }

    while (sup-inf > 1) {

      mid=(int)(0.5*(inf+sup));
      if (x < array_x[mid*n_columns_x+index_x]) {sup=mid;}
      else {inf=mid;}

    }

  }

  else {

    if (x < *(array_x+sup*n_columns_x+index_x)) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,x,*(array_x+sup*n_columns_x+index_x));
      return _FAILURE_;
    }

    if (x > *(array_x+inf*n_columns_x+index_x)) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,x,*(array_x+inf*n_columns_x+index_x));
      return _FAILURE_;
    }

    while (sup-inf > 1) {

      mid=(int)(0.5*(inf+sup));
      if (x > *(array_x+mid*n_columns_x+index_x)) {sup=mid;}
      else {inf=mid;}

    }

  }

  weight=(x-*(array_x+inf*n_columns_x+index_x))/(*(array_x+sup*n_columns_x+index_x)-*(array_x+inf*n_columns_x+index_x));

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

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x50(%rsp), %r14
leal -0x1(%r9), %eax
movslq %edx, %r12
leaq (%rdi,%r12,8), %r13
movsd (%r13), %xmm1
movl %eax, %edi
imull %esi, %edi
leal (%r12,%rdi), %r8d
movslq %r8d, %rbp
movsd (%rbx,%rbp,8), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x17fc4
ucomisd %xmm0, %xmm1
jbe 0x1802a
leaq 0xcf15d(%rip), %rbx     # 0xe70df
leaq 0xcf3f1(%rip), %r15     # 0xe737a
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xae1, %r8d            # imm = 0xAE1
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%r13), %xmm1
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xae1, %r8d            # imm = 0xAE1
jmp 0x180cb
movslq %edi, %rdx
leaq (%rbx,%rdx,8), %rbp
movsd (%rbp,%r12,8), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x1807d
leaq 0xcf0fc(%rip), %rbx     # 0xe70df
leaq 0xcf390(%rip), %r15     # 0xe737a
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xaf7, %r8d            # imm = 0xAF7
movapd %xmm2, %xmm1
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%rbp,%r12,8), %xmm1
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xaf7, %r8d            # imm = 0xAF7
jmp 0x180cb
ucomisd %xmm2, %xmm0
jbe 0x180e9
leaq 0xcf0d1(%rip), %r15     # 0xe710c
leaq 0xcf338(%rip), %r12     # 0xe737a
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0xae6, %r8d            # imm = 0xAE6
movapd %xmm2, %xmm1
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%rbx,%rbp,8), %xmm1
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movl $0xae6, %r8d            # imm = 0xAE6
jmp 0x180cb
ucomisd %xmm1, %xmm0
jbe 0x18135
leaq 0xcf07e(%rip), %rbx     # 0xe710c
leaq 0xcf2e5(%rip), %r15     # 0xe737a
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xafc, %r8d            # imm = 0xAFC
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8580
incl %eax
movslq %eax, %rsi
movsd (%r13), %xmm1
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xafc, %r8d            # imm = 0xAFC
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x8580
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
movsd 0xcdbbd(%rip), %xmm2    # 0xe5cb0
movl %eax, %r8d
subl %edi, %r8d
cmpl $0x2, %r8d
jl 0x18172
leal (%rdi,%rax), %r8d
cvtsi2sd %r8d, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %r8d
movl %r8d, %r10d
imull %esi, %r10d
addl %edx, %r10d
movslq %r10d, %r10
movsd (%rbx,%r10,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %r8d, %eax
cmoval %edi, %r8d
movl %r8d, %edi
jmp 0x180f3
xorl %edi, %edi
movsd 0xcdb71(%rip), %xmm2    # 0xe5cb0
movl %eax, %edx
subl %edi, %edx
cmpl $0x2, %edx
jl 0x18172
leal (%rdi,%rax), %edx
cvtsi2sd %edx, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %edx
movl %edx, %r8d
imull %esi, %r8d
movslq %r8d, %r8
ucomisd (%r13,%r8,8), %xmm0
cmoval %edx, %eax
cmoval %edi, %edx
movl %edx, %edi
jmp 0x1813f
movl 0x48(%rsp), %edx
movq 0x40(%rsp), %r8
movslq %edi, %r10
imull %esi, %edi
movslq %edi, %rdi
leaq (%rbx,%rdi,8), %rdi
movsd (%rdi,%r12,8), %xmm2
subsd %xmm2, %xmm0
imull %eax, %esi
movslq %esi, %rsi
leaq (%rbx,%rsi,8), %rsi
movsd (%rsi,%r12,8), %xmm1
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0xcd0ae(%rip), %xmm3    # 0xe5260
subsd %xmm0, %xmm3
movslq %eax, %rsi
movslq %r9d, %rdi
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
shlq $0x3, %rdi
xorl %r9d, %r9d
cmpq %r9, %rdx
je 0x180da
movsd (%rcx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movsd (%rcx,%r10,8), %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%r8,%r9,8)
incq %r9
addq %rdi, %rcx
jmp 0x181ca