// File: /workspace/github_c_makefile_star2_O3/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 0x12bae
leaq 0xdd056(%rip), %rsi     # 0xefbb8
leaq 0x800(%rsp), %r14
movq %r14, %rdi
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
leaq 0xdb503(%rip), %rsi     # 0xee082
leaq 0xdd065(%rip), %rdx     # 0xefbeb
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xdb497(%rip), %rsi     # 0xee034
leaq 0xdd05d(%rip), %rdx     # 0xefc01
movq %rbx, %rdi
movl $0x49, %ecx
jmp 0x12c00
cmpl $0x2, %esi
jge 0x12c21
leaq 0xdd05b(%rip), %rsi     # 0xefc15
leaq 0x800(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0xdb4af(%rip), %rsi     # 0xee082
leaq 0xdd06b(%rip), %rdx     # 0xefc45
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xdb443(%rip), %rsi     # 0xee034
leaq 0xdd009(%rip), %rdx     # 0xefc01
movq %rbx, %rdi
movl $0x4d, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
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 0xdca11(%rip), %xmm1    # 0xef668
xorl %eax, %eax
movsd 0x8(%rdi,%rax,8), %xmm2
subsd (%rdi,%rax,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x12c70
jnp 0x12d13
movsd (%r13,%rbx), %xmm3
subsd (%r15,%rbx), %xmm3
incq %rax
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
cmpq %rax, %r10
jne 0x12c59
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 0xdc98a(%rip), %xmm0    # 0xef670
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 0x12c0f
leaq 0xdcf35(%rip), %r14     # 0xefc4f
leaq 0xdcee0(%rip), %r15     # 0xefc01
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x53, %r8d
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq 0x1048(%rsp), %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x53, %r8d
xorl %eax, %eax
callq 0x8550
jmp 0x12c0a