// File: /workspace/github_c_makefile_star2_O3/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
leal -0x1(%r9), %eax
movslq %edx, %r12
leaq (%rdi,%r12,8), %r13
movsd (%r13), %xmm1
movl %eax, %edi
imull %esi, %edi
leal (%r12,%rdi), %r10d
movslq %r10d, %rbp
movsd (%rbx,%rbp,8), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x1a3ff
ucomisd %xmm0, %xmm1
jbe 0x1a465
leaq 0xd5d62(%rip), %rbx     # 0xf011f
leaq 0xd600c(%rip), %r15     # 0xf03d0
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xb2c, %r8d            # imm = 0xB2C
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8550
incl %eax
movslq %eax, %rsi
movsd (%r13), %xmm1
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xb2c, %r8d            # imm = 0xB2C
jmp 0x1a506
movslq %edi, %rdx
leaq (%rbx,%rdx,8), %rbp
movsd (%rbp,%r12,8), %xmm2
ucomisd %xmm0, %xmm2
jbe 0x1a4b8
leaq 0xd5d01(%rip), %rbx     # 0xf011f
leaq 0xd5fab(%rip), %r15     # 0xf03d0
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 0x8550
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 0x1a506
ucomisd %xmm2, %xmm0
jbe 0x1a526
leaq 0xd5cd6(%rip), %r15     # 0xf014c
leaq 0xd5f53(%rip), %r12     # 0xf03d0
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 0x8550
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 0x1a506
ucomisd %xmm1, %xmm0
jbe 0x1a57d
leaq 0xd5c83(%rip), %rbx     # 0xf014c
leaq 0xd5f00(%rip), %r15     # 0xf03d0
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %rcx
movl $0xb47, %r8d            # imm = 0xB47
movb $0x2, %al
movsd %xmm0, (%rsp)
callq 0x8550
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 0x8550
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, %r9d
jl 0x1a5c6
xorl %r9d, %r9d
movsd 0xd4795(%rip), %xmm2    # 0xeecd0
leal (%r9,%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 %r9d, %edi
movl %eax, %r10d
subl %edi, %r10d
movl %edi, %r9d
cmpl $0x1, %r10d
jg 0x1a53b
jmp 0x1a5c8
cmpl $0x3, %r9d
jl 0x1a5c6
xorl %edx, %edx
movsd 0xd4743(%rip), %xmm2    # 0xeecd0
leal (%rdx,%rax), %edi
xorps %xmm1, %xmm1
cvtsi2sd %edi, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %edi
movl %edi, %r9d
imull %esi, %r9d
movslq %r9d, %r9
ucomisd (%r13,%r9,8), %xmm0
cmoval %edi, %eax
cmoval %edx, %edi
movl %eax, %r9d
subl %edi, %r9d
movl %edi, %edx
cmpl $0x1, %r9d
jg 0x1a58d
jmp 0x1a5c8
xorl %edi, %edi
movl 0x48(%rsp), %r9d
testl %r9d, %r9d
jle 0x1a65f
movq 0x40(%rsp), %rdx
movl %edi, %r10d
imull %esi, %r10d
movslq %r10d, %r10
leaq (%rbx,%r10,8), %r10
movsd (%r10,%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
imull %r8d, %edi
movslq %edi, %rsi
leaq (%rcx,%rsi,8), %rsi
movsd 0xd3c42(%rip), %xmm3    # 0xee260
subsd %xmm0, %xmm3
imull %r8d, %eax
cltq
leaq (%rcx,%rax,8), %rcx
movl %r9d, %edi
xorl %eax, %eax
xorl %r8d, %r8d
movsd (%rcx,%r8,8), %xmm1
mulsd %xmm0, %xmm1
movsd (%rsi,%r8,8), %xmm2
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rdx,%r8,8)
incq %r8
cmpq %r8, %rdi
jne 0x1a634
jmp 0x1a517
xorl %eax, %eax
jmp 0x1a517