// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_interpolate_two_bis
int array_interpolate_two_bis(
		   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+inf*n_columns_y+i) * (1.-weight)
      + weight * *(array_y+sup*n_columns_y+i) ;

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x50(%rsp), %r14
decl %r9d
movslq %edx, %r12
leaq (%rdi,%r12,8), %r13
movsd (%r13), %xmm1
movl %r9d, %eax
imull %esi, %eax
leal (%r12,%rax), %edi
movslq %edi, %rbp
movsd (%rbx,%rbp,8), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x18286
ucomisd %xmm0, %xmm1
jbe 0x182eb
leaq 0xcee9b(%rip), %rbx     # 0xe70df
leaq 0xcf145(%rip), %r15     # 0xe7390
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xb2c, %r8d            # imm = 0xB2C
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 $0xb2c, %r8d            # imm = 0xB2C
jmp 0x1838c
cltq
leaq (%rbx,%rax,8), %rbp
movsd (%rbp,%r12,8), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x1833e
leaq 0xcee3b(%rip), %rbx     # 0xe70df
leaq 0xcf0e5(%rip), %r15     # 0xe7390
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xb42, %r8d            # imm = 0xB42
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 $0xb42, %r8d            # imm = 0xB42
jmp 0x1838c
ucomisd %xmm2, %xmm0
jbe 0x183aa
leaq 0xcee10(%rip), %r15     # 0xe710c
leaq 0xcf08d(%rip), %r12     # 0xe7390
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0xb31, %r8d            # imm = 0xB31
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 $0xb31, %r8d            # imm = 0xB31
jmp 0x1838c
ucomisd %xmm1, %xmm0
jbe 0x183f0
leaq 0xcedbd(%rip), %rbx     # 0xe710c
leaq 0xcf03a(%rip), %r15     # 0xe7390
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xb47, %r8d            # imm = 0xB47
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 $0xb47, %r8d            # imm = 0xB47
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 %eax, %eax
movsd 0xcd8fc(%rip), %xmm2    # 0xe5cb0
movl %r9d, %edi
subl %eax, %edi
cmpl $0x2, %edi
jl 0x1842e
leal (%rax,%r9), %edi
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, %r9d
cmoval %eax, %edi
movl %edi, %eax
jmp 0x183b4
xorl %eax, %eax
movsd 0xcd8b6(%rip), %xmm2    # 0xe5cb0
movl %r9d, %edx
subl %eax, %edx
cmpl $0x2, %edx
jl 0x1842e
leal (%rax,%r9), %edx
cvtsi2sd %edx, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %edx
movl %edx, %edi
imull %esi, %edi
movslq %edi, %rdi
ucomisd (%r13,%rdi,8), %xmm0
cmoval %edx, %r9d
cmoval %eax, %edx
movl %edx, %eax
jmp 0x183fa
movl 0x48(%rsp), %edx
movq 0x40(%rsp), %rdi
movl %eax, %r10d
imull %esi, %r10d
movslq %r10d, %r10
leaq (%rbx,%r10,8), %r10
movsd (%r10,%r12,8), %xmm2
subsd %xmm2, %xmm0
imull %r9d, %esi
movslq %esi, %rsi
leaq (%rbx,%rsi,8), %rsi
movsd (%rsi,%r12,8), %xmm1
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
imull %r8d, %eax
cltq
leaq (%rcx,%rax,8), %rsi
movsd 0xccde6(%rip), %xmm3    # 0xe5260
subsd %xmm0, %xmm3
imull %r8d, %r9d
movslq %r9d, %rax
leaq (%rcx,%rax,8), %rcx
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
xorl %r8d, %r8d
cmpq %r8, %rdx
je 0x1839b
movsd (%rcx,%r8,8), %xmm1
mulsd %xmm0, %xmm1
movsd (%rsi,%r8,8), %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rdi,%r8,8)
incq %r8
jmp 0x18493