// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_derive_spline
int array_derive_spline(
		 double * x_array,
		 int n_lines,
		 double * array,
		 double * array_splined,
		 int n_columns,
		 int index_y,
		 int index_dydx,
		 ErrorMsg errmsg) {

  int i;

  double h;

  class_test(index_dydx == index_y,
	     errmsg,
	     "Output column %d must differ from input columns %d",
	     index_dydx,
	     index_y);

  class_test(n_lines<2,
	     errmsg,
	     "no possible derivation with less than two lines");

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

    h = x_array[i+1] - x_array[i];
    if (h == 0) {
      class_sprintf(errmsg,"%s(L:%d) h=0, stop to avoid division by zero",__func__,__LINE__);
      return _FAILURE_;
    }

    array[i*n_columns+index_dydx] =
      (array[(i+1)*n_columns+index_y] - array[i*n_columns+index_y])/h
      - h / 6. * (array_splined[(i+1)*n_columns+index_y] + 2. * array_splined[i*n_columns+index_y]);

  }

  h = x_array[n_lines-1] - x_array[n_lines-2];

  array[(n_lines-1)*n_columns+index_dydx] =
    (array[(n_lines-1)*n_columns+index_y] - array[(n_lines-2)*n_columns+index_y])/h
    + h / 6. * (2. * array_splined[(n_lines-1)*n_columns+index_y] + array_splined[(n_lines-2)*n_columns+index_y]);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1008, %rsp           # imm = 0x1008
movq 0x1048(%rsp), %rbx
movl 0x1040(%rsp), %ebp
cmpl %r9d, %ebp
jne 0x10ef9
leaq 0xd5cc5(%rip), %rsi     # 0xe6b78
leaq 0x800(%rsp), %r14
movq %r14, %rdi
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0xd41b2(%rip), %rsi     # 0xe5082
leaq 0xd5cd4(%rip), %rdx     # 0xe6bab
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd4146(%rip), %rsi     # 0xe5034
leaq 0xd5ccc(%rip), %rdx     # 0xe6bc1
pushq $0x49
jmp 0x10f45
cmpl $0x2, %esi
jge 0x10f68
leaq 0xd5cd0(%rip), %rsi     # 0xe6bd5
leaq 0x800(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0xd4164(%rip), %rsi     # 0xe5082
leaq 0xd5ce0(%rip), %rdx     # 0xe6c05
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xd40f8(%rip), %rsi     # 0xe5034
leaq 0xd5c7e(%rip), %rdx     # 0xe6bc1
pushq $0x4d
popq %rcx
movq %rbx, %rdi
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal -0x1(%rsi), %r10d
movslq %r8d, %r11
movslq %r9d, %rax
movslq %ebp, %rbx
leaq (%rdx,%rbx,8), %r14
leaq (%rdx,%rax,8), %r15
leaq (%rcx,%rax,8), %r12
addq %r11, %rax
shlq $0x3, %r11
leaq (%rdx,%rax,8), %r13
leaq (%rcx,%rax,8), %rbp
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
movsd 0xd56aa(%rip), %xmm1    # 0xe6648
xorl %eax, %eax
cmpq %rax, %r10
je 0x10ff7
movsd 0x8(%rdi,%rax,8), %xmm2
subsd (%rdi,%rax,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x10fbc
jnp 0x1105c
movsd (%r13,%rbx), %xmm3
subsd (%r15,%rbx), %xmm3
divsd %xmm2, %xmm3
movsd (%r12,%rbx), %xmm4
addsd %xmm4, %xmm4
addsd (%rbp,%rbx), %xmm4
divsd %xmm1, %xmm2
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
movsd %xmm2, (%r14,%rbx)
addq %r11, %rbx
incq %rax
jmp 0x10fa0
movsd (%rdi,%r10,8), %xmm0
addl $-0x2, %esi
subsd (%rdi,%rsi,8), %xmm0
imull %r8d, %r10d
leal (%r10,%r9), %eax
cltq
movsd (%rdx,%rax,8), %xmm1
imull %r8d, %esi
addl %r9d, %esi
movslq %esi, %rsi
subsd (%rdx,%rsi,8), %xmm1
divsd %xmm0, %xmm1
divsd 0xd5621(%rip), %xmm0    # 0xe6650
movsd (%rcx,%rax,8), %xmm2
addsd %xmm2, %xmm2
addsd (%rcx,%rsi,8), %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
addl 0x1040(%rsp), %r10d
movslq %r10d, %rax
movsd %xmm2, (%rdx,%rax,8)
xorl %eax, %eax
jmp 0x10f56
leaq 0xd5bac(%rip), %r14     # 0xe6c0f
leaq 0xd5b57(%rip), %r15     # 0xe6bc1
pushq $0x53
popq %rbp
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
movq 0x1048(%rsp), %rdi
movq %r14, %rdx
movq %r15, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x8580
jmp 0x10f53