// File: /workspace/github_c_makefile_star2_O2/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 0x10cd9
leaq 0xd5e54(%rip), %rsi     # 0xe6ae5
leaq 0x800(%rsp), %r14
movq %r14, %rdi
movl %r9d, %edx
xorl %eax, %eax
callq 0x2e014
leaq 0xd43d5(%rip), %rsi     # 0xe5082
leaq 0xd5e6b(%rip), %rdx     # 0xe6b1f
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd4369(%rip), %rsi     # 0xe5034
leaq 0xd5e80(%rip), %rdx     # 0xe6b52
pushq $0x1b
jmp 0x10e65
leal (%rcx,%rsi), %eax
cltq
movsd (%rdi,%rax,8), %xmm0
movslq %ecx, %r15
subsd (%rdi,%r15,8), %xmm0
leal (%r8,%rsi), %eax
cltq
movsd (%rdi,%rax,8), %xmm1
movslq %r8d, %r14
subsd (%rdi,%r14,8), %xmm1
leal -0x1(%rdx), %ecx
movslq %r9d, %rax
addl $-0x2, %edx
movslq %ecx, %rcx
movslq %esi, %r12
leaq (,%r12,8), %rsi
leaq (,%rax,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
shlq $0x4, %r12
leaq (%r12,%rax,8), %r11
leaq (%r12,%r14,8), %r14
leaq (%r12,%r15,8), %r15
pushq $0x1
popq %r12
xorpd %xmm2, %xmm2
movq %rdi, %r13
cmpq %rcx, %r12
jge 0x10e1a
ucomisd %xmm2, %xmm0
jne 0x10d6b
jnp 0x10e1e
movsd (%r13,%r15), %xmm3
subsd (%r13,%r10), %xmm3
ucomisd %xmm2, %xmm3
jne 0x10d85
jnp 0x10e1e
movsd (%r13,%r14), %xmm4
subsd (%r13,%r9), %xmm4
movapd %xmm3, %xmm6
mulsd %xmm3, %xmm6
movapd %xmm0, %xmm7
mulsd %xmm0, %xmm7
movapd %xmm7, %xmm8
mulsd %xmm4, %xmm8
movapd %xmm6, %xmm5
mulsd %xmm1, %xmm5
addsd %xmm8, %xmm5
mulsd %xmm3, %xmm7
mulsd %xmm0, %xmm6
addsd %xmm7, %xmm6
divsd %xmm6, %xmm5
movsd %xmm5, (%r13,%r8)
cmpq $0x1, %r12
jne 0x10de8
addsd %xmm1, %xmm1
divsd %xmm0, %xmm1
subsd %xmm5, %xmm1
movsd %xmm1, (%rdi,%rax,8)
cmpq %r12, %rdx
jne 0x10e07
movapd %xmm4, %xmm0
addsd %xmm4, %xmm0
divsd %xmm3, %xmm0
subsd (%r13,%r8), %xmm0
movsd %xmm0, (%r13,%r11)
addq %rsi, %r13
incq %r12
movapd %xmm3, %xmm0
movapd %xmm4, %xmm1
jmp 0x10d56
xorl %eax, %eax
jmp 0x10e76
leaq 0xd5ed8(%rip), %rsi     # 0xe6cfd
leaq 0x800(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0xd4244(%rip), %rsi     # 0xe5082
leaq 0xd5d1a(%rip), %rdx     # 0xe6b5f
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd41d8(%rip), %rsi     # 0xe5034
leaq 0xd5cef(%rip), %rdx     # 0xe6b52
pushq $0x28
popq %rcx
movq %rbx, %rdi
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq