// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_derive
int array_derive(
		 double * array,
		 int n_columns,
		 int n_lines,
		 int index_x,   /** from 0 to (n_columns-1) */
		 int index_y,
		 int index_dydx,
		 ErrorMsg errmsg) {

  int i;

  double dx1,dx2,dy1,dy2,weight1,weight2;

  class_test((index_dydx == index_x) || (index_dydx == index_y),
	     errmsg,
	     "output column %d must differ from input columns %d and %d",index_dydx,index_x,index_y);

  dx2=array[1*n_columns+index_x]-array[0*n_columns+index_x];
  dy2=array[1*n_columns+index_y]-array[0*n_columns+index_y];

  for (i=1; i<n_lines-1; i++) {

    dx1 = dx2;
    dy1 = dy2;
    dx2 = array[(i+1)*n_columns+index_x]-array[i*n_columns+index_x];
    dy2 = array[(i+1)*n_columns+index_y]-array[i*n_columns+index_y];
    class_test((dx1 == 0) || (dx2 == 0),
	       errmsg,
	       "stop to avoid division by zero");
    weight1 = dx2*dx2;
    weight2 = dx1*dx1;
    array[i*n_columns+index_dydx] = (weight1*dy1+weight2*dy2) / (weight1*dx1+weight2*dx2);

    if (i == 1)
      array[(i-1)*n_columns+index_dydx] = 2.*dy1/dx1 - array[i*n_columns+index_dydx];

    if (i == n_lines-2)
      array[(i+1)*n_columns+index_dydx] = 2.*dy2/dx2 - array[i*n_columns+index_dydx];
  }

  return _SUCCESS_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movq 0x1030(%rsp), %rbx
cmpl %ecx, %r9d
setne %al
cmpl %r8d, %r9d
setne %r10b
testb %r10b, %al
jne 0x12807
leaq 0xe035c(%rip), %rsi     # 0xf2b15
leaq 0x800(%rsp), %r14
movq %r14, %rdi
movl %r9d, %edx
xorl %eax, %eax
callq 0x30c2c
leaq 0xde8ad(%rip), %rsi     # 0xf1082
leaq 0xe0373(%rip), %rdx     # 0xf2b4f
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xde841(%rip), %rsi     # 0xf1034
leaq 0xe0388(%rip), %rdx     # 0xf2b82
movq %rbx, %rdi
movl $0x1b, %ecx
jmp 0x1299e
cmpl $0x3, %edx
jl 0x1294d
leal (%r8,%rsi), %eax
cltq
movsd (%rdi,%rax,8), %xmm0
movslq %r8d, %r14
subsd (%rdi,%r14,8), %xmm0
leal (%rcx,%rsi), %eax
cltq
movsd (%rdi,%rax,8), %xmm1
movslq %ecx, %r15
subsd (%rdi,%r15,8), %xmm1
leal -0x1(%rdx), %eax
movslq %r9d, %rcx
addl $-0x2, %edx
movslq %esi, %r12
decq %rdx
leaq (,%r12,8), %rsi
leaq (,%rcx,8), %r8
leaq (%r8,%r12,8), %r8
leaq (,%r14,8), %r9
leaq (%r9,%r12,8), %r9
leaq (,%r15,8), %r10
leaq (%r10,%r12,8), %r10
decq %rax
shlq $0x4, %r12
leaq (%r12,%rcx,8), %r11
leaq (%r12,%r14,8), %r14
leaq (%r12,%r15,8), %r15
xorl %r12d, %r12d
xorpd %xmm2, %xmm2
movq %rdi, %r13
ucomisd %xmm2, %xmm1
jne 0x1289b
jnp 0x12951
movsd (%r13,%r15), %xmm3
subsd (%r13,%r10), %xmm3
ucomisd %xmm2, %xmm3
jne 0x128b5
jnp 0x12951
movsd (%r13,%r14), %xmm4
subsd (%r13,%r9), %xmm4
movapd %xmm3, %xmm6
mulsd %xmm3, %xmm6
movapd %xmm1, %xmm7
mulsd %xmm1, %xmm7
movapd %xmm7, %xmm8
mulsd %xmm4, %xmm8
movapd %xmm6, %xmm5
mulsd %xmm0, %xmm5
addsd %xmm8, %xmm5
mulsd %xmm3, %xmm7
mulsd %xmm1, %xmm6
addsd %xmm7, %xmm6
divsd %xmm6, %xmm5
movsd %xmm5, (%r13,%r8)
testq %r12, %r12
jne 0x12917
addsd %xmm0, %xmm0
divsd %xmm1, %xmm0
subsd %xmm5, %xmm0
movsd %xmm0, (%rdi,%rcx,8)
cmpq %r12, %rdx
jne 0x12936
movapd %xmm4, %xmm0
addsd %xmm4, %xmm0
divsd %xmm3, %xmm0
subsd (%r13,%r8), %xmm0
movsd %xmm0, (%r13,%r11)
incq %r12
addq %rsi, %r13
movapd %xmm4, %xmm0
movapd %xmm3, %xmm1
cmpq %r12, %rax
jne 0x1288f
xorl %eax, %eax
jmp 0x129ad
leaq 0xe03d5(%rip), %rsi     # 0xf2d2d
leaq 0x800(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xde711(%rip), %rsi     # 0xf1082
leaq 0xe0217(%rip), %rdx     # 0xf2b8f
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xde6a5(%rip), %rsi     # 0xf1034
leaq 0xe01ec(%rip), %rdx     # 0xf2b82
movq %rbx, %rdi
movl $0x28, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq