// File: /workspace/github_cpp_makefile_star2_O2/fanyazhi[P]Spline-Fitting/src/cubicSpline.cpp
// Function: cubicSpline(std::vector<double, std::allocator<double>>, std::vector<double, std::allocator<double>>, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&)
void cubicSpline(vector<double> x, vector<double> y, vector<double> &qx, vector<double> &qy) {
    //initialize qx and qy for extraction
    qx[0] = x[0];
    qy[0] = y[0];

    //initialize variable t to breakdown a and y into monotonic functions
    vector<double> t(x.size());
    for (int i = 0; i < t.size(); i++) {
        t[i] = i;
    }
    vector<double> qt(qx.size());
    qt[0] = 0;
    for (int i = 1; i < qt.size(); i++) {
        qt[i] = qt[i - 1] + 1.0 * (t.size() - 1) / qx.size();
    }

    //obtain derivatives
    vector<double> ky(qt.size());
    vector<double> kx(qt.size());
    ky = splineDerivative(t.size(), t, y);
    kx = splineDerivative(t.size(), t, x);

    //if the first point and the last points are exactly the same, then the
    //curve is enclosed, and derivatives should match at the enclosure point
    double epislon = 1E-7;
    if ((abs(x[0] - x[x.size() - 1]) < epislon) && (abs(y[0] - y[y.size() - 1]) < epislon)) {
        ky[ky.size() - 1] = ky[0];
        kx[kx.size() - 1] = kx[0];
    }

    for (int j = 1; j < qt.size(); j++) {
        int i = 0;
        while (t[i] < qt[j] && i < t.size()) {
            i++;
        }
        qy[j] = cubicPoint(i, qt[j], t, y, ky);
        qx[j] = cubicPoint(i, qt[j], t, x, kx);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdx, %r14
movq (%rdi), %rax
movsd (%rax), %xmm0
movq (%rdx), %rdx
movsd %xmm0, (%rdx)
movq %rsi, 0x10(%rsp)
movq (%rsi), %rdx
movsd (%rdx), %xmm0
movq %rcx, 0x88(%rsp)
movq (%rcx), %rcx
movsd %xmm0, (%rcx)
movq %rdi, 0x18(%rsp)
movq 0x8(%rdi), %rsi
subq %rax, %rsi
sarq $0x3, %rsi
leaq 0x38(%rsp), %rbx
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x3336
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x4042
cvtsi2sd %edx, %xmm0
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
jmp 0x402f
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x3, %rsi
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x3336
movq 0x20(%rsp), %rax
andq $0x0, (%rax)
movq 0x28(%rsp), %rsi
subq %rax, %rsi
sarq $0x3, %rsi
movq 0x40(%rsp), %rcx
subq 0x38(%rsp), %rcx
sarq $0x3, %rcx
decq %rcx
movq %rcx, %xmm1
movq 0x1061(%rip), %xmm2     # 0x50f0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x1065(%rip), %xmm3     # 0x5100
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq 0x8(%r14), %rcx
subq (%r14), %rcx
sarq $0x3, %rcx
movq %rcx, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
pushq $0x1
popq %rcx
cmpq %rcx, %rsi
jbe 0x40ef
movsd -0x8(%rax,%rcx,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rcx,8)
incq %rcx
jmp 0x40d6
leaq 0x68(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x3336
movq 0x28(%rsp), %rsi
subq 0x20(%rsp), %rsi
sarq $0x3, %rsi
leaq 0x50(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x3336
leaq 0x38(%rsp), %rsi
movq 0x8(%rsi), %rbx
subq (%rsi), %rbx
leaq 0xf0(%rsp), %rdi
callq 0x3470
leaq 0xd8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3470
shrq $0x3, %rbx
leaq 0x90(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
leaq 0xd8(%rsp), %rcx
movl %ebx, %esi
callq 0x3c6e
leaq 0x68(%rsp), %rdi
leaq 0x90(%rsp), %rbx
movq %rbx, %rsi
callq 0x3b9a
movq %rbx, %rdi
callq 0x3692
leaq 0xd8(%rsp), %rdi
callq 0x3692
leaq 0xf0(%rsp), %rdi
callq 0x3692
leaq 0x38(%rsp), %rsi
movq 0x8(%rsi), %rbx
subq (%rsi), %rbx
leaq 0xc0(%rsp), %rdi
callq 0x3470
leaq 0xa8(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x3470
shrq $0x3, %rbx
leaq 0x90(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
leaq 0xa8(%rsp), %rcx
movl %ebx, %esi
callq 0x3c6e
movq %r14, 0x80(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x90(%rsp), %rbx
movq %rbx, %rsi
callq 0x3b9a
movq %rbx, %rdi
callq 0x3692
leaq 0xa8(%rsp), %rdi
callq 0x3692
leaq 0xc0(%rsp), %rdi
callq 0x3692
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movsd (%rax), %xmm1
subsd -0x8(%rcx), %xmm1
andpd 0xec3(%rip), %xmm1      # 0x5110
movsd 0xe7b(%rip), %xmm0      # 0x50d0
ucomisd %xmm1, %xmm0
jbe 0x42a4
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movsd (%rax), %xmm1
subsd -0x8(%rcx), %xmm1
andpd 0xe98(%rip), %xmm1      # 0x5110
ucomisd %xmm1, %xmm0
jbe 0x42a4
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rcx)
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rcx)
pushq $0x1
popq %rbx
leaq 0x38(%rsp), %r15
leaq 0x180(%rsp), %r14
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rax
subq %rdx, %rax
sarq $0x3, %rax
cmpq %rbx, %rax
jbe 0x4430
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
movsd (%rdx,%rbx,8), %xmm0
movsd %xmm0, 0x8(%rsp)
subq %rax, %rcx
sarq $0x3, %rcx
xorl %edx, %edx
leaq 0x1(%rdx), %r13
movsd 0x8(%rsp), %xmm0
ucomisd (%rax,%rdx,8), %xmm0
jbe 0x4305
cmpq %rdx, %rcx
movq %r13, %rdx
ja 0x42ec
leaq 0x150(%rsp), %rdi
movq %r15, %rsi
callq 0x3470
leaq 0x138(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3470
movq %r15, %r12
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x3470
movq %r14, %rbp
decq %r13
movl %r13d, %edi
movsd 0x8(%rsp), %xmm0
leaq 0x150(%rsp), %r15
movq %r15, %rsi
leaq 0x138(%rsp), %r14
movq %r14, %rdx
movq %rbp, %rcx
callq 0x3bec
movq 0x88(%rsp), %rax
movq (%rax), %rax
movsd %xmm0, (%rax,%rbx,8)
movq %rbp, %rdi
callq 0x3692
movq %r14, %rdi
callq 0x3692
movq %r15, %rdi
callq 0x3692
movq 0x20(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x120(%rsp), %rdi
movq %r12, %r15
movq %r12, %rsi
callq 0x3470
movq %rbp, %r14
leaq 0x108(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x3470
leaq 0x168(%rsp), %rbp
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
callq 0x3470
movl %r13d, %edi
movsd 0x8(%rsp), %xmm0
leaq 0x120(%rsp), %r12
movq %r12, %rsi
leaq 0x108(%rsp), %r13
movq %r13, %rdx
movq %rbp, %rcx
callq 0x3bec
movq 0x80(%rsp), %rax
movq (%rax), %rax
movsd %xmm0, (%rax,%rbx,8)
movq %rbp, %rdi
callq 0x3692
movq %r13, %rdi
callq 0x3692
movq %r12, %rdi
callq 0x3692
incq %rbx
jmp 0x42b4
leaq 0x50(%rsp), %rdi
callq 0x3692
leaq 0x68(%rsp), %rdi
callq 0x3692
leaq 0x20(%rsp), %rdi
callq 0x3692
leaq 0x38(%rsp), %rdi
callq 0x3692
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x3692
jmp 0x447f
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x44f7
jmp 0x44fe
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x3692
jmp 0x44a0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
jmp 0x44f7
jmp 0x44fe
movq %rax, %rbx
jmp 0x450b
movq %rax, %rbx
jmp 0x4515
movq %rax, %rbx
jmp 0x451f
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x3692
jmp 0x44d0
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
jmp 0x44f7
movq %rax, %rbx
jmp 0x44ef
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x3692
leaq 0x150(%rsp), %rdi
callq 0x3692
jmp 0x4501
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3692
leaq 0x68(%rsp), %rdi
callq 0x3692
leaq 0x20(%rsp), %rdi
callq 0x3692
leaq 0x38(%rsp), %rdi
callq 0x3692
movq %rbx, %rdi
callq 0x2220