// File: /workspace/github_cpp_makefile_star2_O1/fanyazhi[P]Spline-Fitting/src/cubicSpline.cpp
// Function: splineDerivative(int, std::vector<double, std::allocator<double>>, std::vector<double, std::allocator<double>>)
vector<double> splineDerivative(int d, vector<double> x, vector<double> y) {
    //solve a[][]k[] = b[] to find frst derivatives
    vector<double> k(d);
    CRSmatrix a(d, d);
    vector<double> b(d);

    //first row
    a.changeValue(2.0 / (x[1] - x[0]), 0, 0);
    a.changeValue(1.0 / (x[1] - x[0]), 0, 1);
    b[0] = 3.0 * (y[1] - y[0]) / pow((x[1] - x[0]), 2);

    //middle rows
    for (int i = 1; i < d - 1; i++) {
        a.changeValue(1.0 / (x[i] - x[i - 1]), i, i - 1);
        a.changeValue(2.0 * (1 / (x[i] - x[i - 1]) + 1 / (x[i + 1] - x[i])), i, i);
        a.changeValue(1.0 / (x[i + 1] - x[i]), i, i + 1);
        b[i] = 3.0 * (((y[i] - y[i - 1]) / pow((x[i] - x[i - 1]), 2)) + ((y[i + 1] - y[i]) / pow((x[i + 1] - x[i]), 2)));
    }

    //last row
    a.changeValue(1.0 / (x[d - 1] - x[d - 2]), d - 1, d - 1);
    a.changeValue(2.0 / (x[d - 1] - x[d - 2]), d - 1, d - 2);
    b[d - 1] = 3.0 * (y[d - 1] - y[d - 2]) / pow((x[d - 1] - x[d - 2]), 2);

    k = Jacobi(a, b);

    return k;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rcx, %r12
movq %rdx, %r15
movl %esi, %ebx
movslq %esi, %r14
leaq 0x40(%rsp), %rdx
movq %rdi, 0x8(%rsp)
movq %r14, %rsi
callq 0x3d60
leaq 0x40(%rsp), %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x2aea
leaq 0x10(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
movq %r14, %rsi
callq 0x3d60
movq (%r15), %rax
movsd 0x8(%rax), %xmm1
subsd (%rax), %xmm1
movsd 0x1ccf(%rip), %xmm0     # 0x60d0
divsd %xmm1, %xmm0
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2b7e
movq (%r15), %rax
movsd 0x8(%rax), %xmm1
subsd (%rax), %xmm1
movsd 0x1be1(%rip), %xmm0     # 0x6008
divsd %xmm1, %xmm0
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x2b7e
movq (%r12), %rax
movsd 0x8(%rax), %xmm0
subsd (%rax), %xmm0
mulsd 0x1c87(%rip), %xmm0     # 0x60d8
movq (%r15), %rax
movsd 0x8(%rax), %xmm1
subsd (%rax), %xmm1
mulsd %xmm1, %xmm1
divsd %xmm1, %xmm0
movq 0x10(%rsp), %rax
movsd %xmm0, (%rax)
leal -0x1(%rbx), %eax
movl %eax, 0x4(%rsp)
cmpl $0x3, %ebx
movsd 0x1b88(%rip), %xmm0     # 0x6008
jl 0x45a1
movl 0x4(%rsp), %ebp
decq %rbp
xorl %r13d, %r13d
leaq 0x40(%rsp), %rbx
movq (%r15), %rax
movsd 0x8(%rax,%r13,8), %xmm1
subsd (%rax,%r13,8), %xmm1
divsd %xmm1, %xmm0
leal 0x1(%r13), %esi
movq %rbx, %rdi
movl %r13d, %edx
callq 0x2b7e
movq (%r15), %rax
movsd 0x8(%rax,%r13,8), %xmm0
movsd 0x10(%rax,%r13,8), %xmm1
movapd %xmm0, %xmm2
subsd (%rax,%r13,8), %xmm2
subsd %xmm0, %xmm1
movsd 0x1b29(%rip), %xmm0     # 0x6008
movapd %xmm0, %xmm3
divsd %xmm2, %xmm3
divsd %xmm1, %xmm0
addsd %xmm3, %xmm0
addsd %xmm0, %xmm0
leal 0x1(%r13), %edx
movq %rbx, %rdi
movl %edx, %esi
callq 0x2b7e
movq (%r15), %rax
movsd 0x10(%rax,%r13,8), %xmm1
subsd 0x8(%rax,%r13,8), %xmm1
leal 0x2(%r13), %edx
movsd 0x1aea(%rip), %xmm0     # 0x6008
divsd %xmm1, %xmm0
leal 0x1(%r13), %esi
movq %rbx, %rdi
callq 0x2b7e
movq (%r12), %rax
movsd 0x8(%rax,%r13,8), %xmm1
movsd 0x10(%rax,%r13,8), %xmm0
subsd %xmm1, %xmm0
subsd (%rax,%r13,8), %xmm1
movq (%r15), %rax
movsd 0x8(%rax,%r13,8), %xmm2
movsd 0x10(%rax,%r13,8), %xmm3
subsd %xmm2, %xmm3
subsd (%rax,%r13,8), %xmm2
mulsd %xmm2, %xmm2
divsd %xmm2, %xmm1
mulsd %xmm3, %xmm3
divsd %xmm3, %xmm0
addsd %xmm1, %xmm0
mulsd 0x1b57(%rip), %xmm0     # 0x60d8
movq 0x10(%rsp), %rax
movsd %xmm0, 0x8(%rax,%r13,8)
incq %r13
cmpq %r13, %rbp
movsd 0x1a6d(%rip), %xmm0     # 0x6008
jne 0x4495
movl 0x4(%rsp), %ebp
movslq %ebp, %rbx
movq (%r15), %rax
movsd (%rax,%rbx,8), %xmm1
subsd -0x10(%rax,%r14,8), %xmm1
divsd %xmm1, %xmm0
leaq 0x40(%rsp), %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x2b7e
addq $-0x2, %r14
movq (%r15), %rax
movsd (%rax,%rbx,8), %xmm1
subsd (%rax,%r14,8), %xmm1
movsd 0x1aed(%rip), %xmm0     # 0x60d0
divsd %xmm1, %xmm0
leaq 0x40(%rsp), %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x2b7e
movq (%r12), %rax
movsd (%rax,%rbx,8), %xmm0
subsd (%rax,%r14,8), %xmm0
mulsd 0x1acb(%rip), %xmm0     # 0x60d8
movq (%r15), %rax
movsd (%rax,%rbx,8), %xmm1
subsd (%rax,%r14,8), %xmm1
mulsd %xmm1, %xmm1
divsd %xmm1, %xmm0
movq 0x10(%rsp), %rax
movsd %xmm0, (%rax,%rbx,8)
leaq 0x48(%rsp), %rsi
movq -0x8(%rsi), %rax
leaq 0x98(%rsp), %rdi
movq %rax, -0x8(%rdi)
callq 0x3dea
leaq 0xb0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movq 0x8(%rsp), %r14
callq 0x3eb0
leaq 0xc8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x3eb0
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x3dea
leaq 0xe0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x3041
leaq 0xe0(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x52c2
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x46c4
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x46db
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x46f8
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x4715
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x4732
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4749
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x4763
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x477a
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x4791
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq %r14, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x47c5
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
jmp 0x47c5
movq %rax, %r14
leaq 0x90(%rsp), %rdi
callq 0x3e6a
jmp 0x4829
movq %rax, %r14
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x47f9
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
jmp 0x47f9
movq %rax, %r14
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x4829
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
jmp 0x4829
jmp 0x4826
movq %rax, %r14
jmp 0x4840
movq %rax, %r14
jmp 0x484a
jmp 0x4826
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4840
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
leaq 0x40(%rsp), %rdi
callq 0x3e6a
movq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4868
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x2190
movq %r14, %rdi
callq 0x2270