// File: /workspace/github_c_makefile_star2_O1/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 0x12a37
leaq 0xe01be(%rip), %rsi     # 0xf2ba8
leaq 0x800(%rsp), %r14
movq %r14, %rdi
movl %ebp, %edx
movl %r9d, %ecx
xorl %eax, %eax
callq 0x30c2c
leaq 0xde67a(%rip), %rsi     # 0xf1082
leaq 0xe01cc(%rip), %rdx     # 0xf2bdb
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xde60e(%rip), %rsi     # 0xf1034
leaq 0xe01c4(%rip), %rdx     # 0xf2bf1
movq %rbx, %rdi
movl $0x49, %ecx
jmp 0x12a89
cmpl $0x2, %esi
jge 0x12aaa
leaq 0xe01c2(%rip), %rsi     # 0xf2c05
leaq 0x800(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xde626(%rip), %rsi     # 0xf1082
leaq 0xe01d2(%rip), %rdx     # 0xf2c35
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xde5ba(%rip), %rsi     # 0xf1034
leaq 0xe0170(%rip), %rdx     # 0xf2bf1
movq %rbx, %rdi
movl $0x4d, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
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 0xdfb88(%rip), %xmm1    # 0xf2668
xorl %eax, %eax
movsd 0x8(%rdi,%rax,8), %xmm2
subsd (%rdi,%rax,8), %xmm2
ucomisd %xmm0, %xmm2
jne 0x12af9
jnp 0x12b9c
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 0x12ae2
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 0xdfb01(%rip), %xmm0    # 0xf2670
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 0x12a98
leaq 0xe009c(%rip), %r14     # 0xf2c3f
leaq 0xe0047(%rip), %r15     # 0xf2bf1
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 0x12a93