// File: /workspace/github_c_makefile_star2_O1/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, %r13
movsd (%rdi,%r13,8), %xmm1
movl %eax, %edi
imull %esi, %edi
leal (%rdi,%r13), %r8d
movslq %r8d, %rbp
movsd (%rbx,%rbp,8), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x19ff1
ucomisd %xmm0, %xmm1
jbe 0x1a055
leaq 0xd9160(%rip), %r15     # 0xf310f
leaq 0xd93f4(%rip), %r12     # 0xf33aa
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0xae1, %r8d            # imm = 0xAE1
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 $0xae1, %r8d            # imm = 0xAE1
jmp 0x1a0f6
movslq %edi, %rdx
leaq (%rbx,%rdx,8), %r12
movsd (%r12,%r13,8), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x1a0a8
leaq 0xd9100(%rip), %rbx     # 0xf310f
leaq 0xd9394(%rip), %r15     # 0xf33aa
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 0x8550
incl %eax
movslq %eax, %rsi
movsd (%r12,%r13,8), %xmm1
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xaf7, %r8d            # imm = 0xAF7
jmp 0x1a0f6
ucomisd %xmm2, %xmm0
jbe 0x1a116
leaq 0xd90d6(%rip), %r15     # 0xf313c
leaq 0xd933d(%rip), %r12     # 0xf33aa
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 0x8550
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 0x1a0f6
ucomisd %xmm1, %xmm0
jbe 0x1a16d
leaq 0xd9083(%rip), %r15     # 0xf313c
leaq 0xd92ea(%rip), %r12     # 0xf33aa
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0xafc, %r8d            # imm = 0xAFC
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 $0xafc, %r8d            # imm = 0xAFC
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x8550
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, %r9d
jl 0x1a1bd
xorl %r8d, %r8d
movsd 0xd7ba5(%rip), %xmm2    # 0xf1cd0
leal (%r8,%rax), %edi
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %edi
movl %edi, %r10d
imull %esi, %r10d
addl %edx, %r10d
movslq %r10d, %r10
movsd (%rbx,%r10,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %edi, %eax
cmoval %r8d, %edi
movl %eax, %r10d
subl %edi, %r10d
movl %edi, %r8d
cmpl $0x1, %r10d
jg 0x1a12b
jmp 0x1a1bf
cmpl $0x3, %r9d
jl 0x1a1bd
leaq (%rbx,%r13,8), %rdx
xorl %r8d, %r8d
movsd 0xd7b4e(%rip), %xmm2    # 0xf1cd0
leal (%r8,%rax), %edi
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %edi
movl %edi, %r10d
imull %esi, %r10d
movslq %r10d, %r10
ucomisd (%rdx,%r10,8), %xmm0
cmoval %edi, %eax
cmoval %r8d, %edi
movl %eax, %r10d
subl %edi, %r10d
movl %edi, %r8d
cmpl $0x1, %r10d
jg 0x1a182
jmp 0x1a1bf
xorl %edi, %edi
movl 0x48(%rsp), %r10d
testl %r10d, %r10d
jle 0x1a248
movq 0x40(%rsp), %rdx
movslq %edi, %r8
imull %esi, %edi
movslq %edi, %rdi
leaq (%rbx,%rdi,8), %rdi
movsd (%rdi,%r13,8), %xmm2
subsd %xmm2, %xmm0
imull %eax, %esi
movslq %esi, %rsi
leaq (%rbx,%rsi,8), %rsi
movsd (%rsi,%r13,8), %xmm1
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd 0xd705b(%rip), %xmm3    # 0xf1260
subsd %xmm0, %xmm3
movslq %eax, %rsi
movslq %r9d, %rdi
movl %r10d, %r9d
shlq $0x3, %rdi
xorl %eax, %eax
xorl %r10d, %r10d
movsd (%rcx,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
movsd (%rcx,%r8,8), %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rdx,%r10,8)
incq %r10
addq %rdi, %rcx
cmpq %r10, %r9
jne 0x1a21b
jmp 0x1a107
xorl %eax, %eax
jmp 0x1a107