// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_interpolate_spline_transposed
int array_interpolate_spline_transposed(double * array,
                                        int x_size,
                                        int y_size,
                                        int index_x,
                                        int index_y,
                                        int index_ddy,
                                        double x,
                                        int * last_index,
                                        double * result,
                                        ErrorMsg errmsg) {

  int inf,sup,mid;
  double h,a,b;

  inf=0;
  sup=x_size-1;

  if (array[inf*y_size+index_x] < array[sup*y_size+index_x]){

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

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

    while (sup-inf > 1) {

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

    }

  }

  else {

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

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

    while (sup-inf > 1) {

      mid=(int)(0.5*(inf+sup));
      if (x > array[mid*y_size+index_x]) {sup=mid;}
      else {inf=mid;}

    }

  }

  *last_index = inf;

  h = array[sup*y_size+index_x]-array[inf*y_size+index_x];
  b = (x - array[inf*y_size+index_x])/h;
  a = 1.0 - b;

  *result= (a*array[inf*y_size+index_y]+b*array[sup*y_size+index_y]
            + ((a*a*a-a)* array[inf*y_size+index_ddy] + (b*b*b-b)* array[sup*y_size+index_ddy])*h*h/6.);

  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(%rsi), %eax
movslq %ecx, %r13
movsd (%rdi,%r13,8), %xmm1
movl %eax, %edi
imull %edx, %edi
addl %r13d, %edi
movslq %edi, %rbp
movsd (%rbx,%rbp,8), %xmm2
ucomisd %xmm1, %xmm2
jbe 0x17e02
ucomisd %xmm0, %xmm1
jbe 0x17e58
leaq 0xd835f(%rip), %r15     # 0xf011f
leaq 0xd83a0(%rip), %r12     # 0xf0167
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x6d1, %r8d            # imm = 0x6D1
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 $0x6d1, %r8d            # imm = 0x6D1
jmp 0x17ef9
ucomisd %xmm0, %xmm2
jbe 0x17eab
leaq 0xd830c(%rip), %r15     # 0xf011f
leaq 0xd834d(%rip), %r12     # 0xf0167
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x6e7, %r8d            # imm = 0x6E7
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 $0x6e7, %r8d            # imm = 0x6E7
jmp 0x17ef9
ucomisd %xmm2, %xmm0
jbe 0x17f0f
leaq 0xd82e3(%rip), %r15     # 0xf014c
leaq 0xd82f7(%rip), %r12     # 0xf0167
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x6d6, %r8d            # imm = 0x6D6
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 $0x6d6, %r8d            # imm = 0x6D6
jmp 0x17ef9
ucomisd %xmm1, %xmm0
jbe 0x17f61
leaq 0xd8290(%rip), %r15     # 0xf014c
leaq 0xd82a4(%rip), %r12     # 0xf0167
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl $0x6ec, %r8d            # imm = 0x6EC
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 $0x6ec, %r8d            # imm = 0x6EC
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x8550
movl $0x1, %eax
jmp 0x18062
cmpl $0x3, %esi
jl 0x17fab
xorl %edi, %edi
movsd 0xd6dae(%rip), %xmm2    # 0xeecd0
leal (%rdi,%rax), %esi
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %esi
movl %esi, %r10d
imull %edx, %r10d
addl %ecx, %r10d
movslq %r10d, %r10
movsd (%rbx,%r10,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %esi, %eax
cmoval %edi, %esi
movl %eax, %r10d
subl %esi, %r10d
movl %esi, %edi
cmpl $0x1, %r10d
jg 0x17f22
jmp 0x17fad
cmpl $0x3, %esi
jl 0x17fab
xorl %edi, %edi
movsd 0xd6d60(%rip), %xmm2    # 0xeecd0
leal (%rdi,%rax), %esi
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %esi
movl %esi, %r10d
imull %edx, %r10d
addl %ecx, %r10d
movslq %r10d, %r10
ucomisd (%rbx,%r10,8), %xmm0
cmoval %esi, %eax
cmoval %edi, %esi
movl %eax, %r10d
subl %esi, %r10d
movl %esi, %edi
cmpl $0x1, %r10d
jg 0x17f70
jmp 0x17fad
xorl %esi, %esi
movq 0x40(%rsp), %rdi
movl %esi, (%rdi)
imull %edx, %eax
leal (%rax,%rcx), %edi
movslq %edi, %rdi
movsd (%rbx,%rdi,8), %xmm5
imull %edx, %esi
addl %esi, %ecx
movslq %ecx, %rcx
movsd (%rbx,%rcx,8), %xmm1
subsd %xmm1, %xmm5
subsd %xmm1, %xmm0
divsd %xmm5, %xmm0
movsd 0xd627d(%rip), %xmm4    # 0xee260
subsd %xmm0, %xmm4
leal (%rsi,%r8), %ecx
movslq %ecx, %rcx
addl %eax, %r8d
movslq %r8d, %rdx
movsd (%rbx,%rdx,8), %xmm1
mulsd %xmm0, %xmm1
movsd (%rbx,%rcx,8), %xmm2
mulsd %xmm4, %xmm2
movapd %xmm4, %xmm3
mulsd %xmm4, %xmm3
mulsd %xmm4, %xmm3
subsd %xmm4, %xmm3
movapd %xmm0, %xmm4
mulsd %xmm0, %xmm4
mulsd %xmm0, %xmm4
subsd %xmm0, %xmm4
movq 0x48(%rsp), %rcx
addl %r9d, %esi
addl %r9d, %eax
cltq
mulsd (%rbx,%rax,8), %xmm4
movslq %esi, %rax
mulsd (%rbx,%rax,8), %xmm3
addsd %xmm4, %xmm3
mulsd %xmm5, %xmm3
mulsd %xmm5, %xmm3
divsd 0xd761c(%rip), %xmm3    # 0xef670
addsd %xmm1, %xmm2
addsd %xmm2, %xmm3
movsd %xmm3, (%rcx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq