// File: /workspace/github_cpp_makefile_star2_O3/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 %rdi, %r12
movq (%rdi), %rax
movsd (%rax), %xmm0
movq %rdx, 0x78(%rsp)
movq (%rdx), %rdx
movsd %xmm0, (%rdx)
movq %rsi, 0x80(%rsp)
movq (%rsi), %rdx
movq (%rdx), %xmm0
movq %rcx, 0xa0(%rsp)
movq (%rcx), %rcx
movq %xmm0, (%rcx)
movq 0x8(%rdi), %rsi
subq %rax, %rsi
sarq $0x3, %rsi
leaq 0x88(%rsp), %rbx
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x3d90
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
je 0x49e2
sarq $0x3, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
leaq 0x1(%rdx), %rcx
andq $-0x2, %rcx
decq %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x17a2(%rip), %xmm1     # 0x6100
xorl %edx, %edx
movdqa 0x17a8(%rip), %xmm2     # 0x6110
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x17a8(%rip), %xmm4     # 0x6120
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %esi
notl %esi
testb $0x1, %sil
je 0x49b6
xorps %xmm6, %xmm6
cvtsi2sd %edx, %xmm6
movsd %xmm6, (%rax,%rdx,8)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0x49d5
leal 0x1(%rdx), %esi
xorps %xmm5, %xmm5
cvtsi2sd %esi, %xmm5
movsd %xmm5, 0x8(%rax,%rdx,8)
addq $0x2, %rdx
paddq %xmm4, %xmm1
cmpq %rdx, %rcx
jne 0x4978
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x3, %rsi
leaq 0x28(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x3d90
movq 0x28(%rsp), %rax
movq $0x0, (%rax)
movq 0x30(%rsp), %rsi
subq %rax, %rsi
sarq $0x3, %rsi
cmpq $0x2, %rsi
jb 0x4aaa
movq 0x90(%rsp), %rcx
subq 0x88(%rsp), %rcx
sarq $0x3, %rcx
decq %rcx
movq %rcx, %xmm1
movq 0x16e9(%rip), %xmm2     # 0x6130
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x16ed(%rip), %xmm3     # 0x6140
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq 0x78(%rsp), %rdx
movq 0x8(%rdx), %rcx
subq (%rdx), %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
movsd (%rax), %xmm1
movl $0x1, %ecx
addsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x4a99
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x3d90
movq 0x30(%rsp), %rsi
subq 0x28(%rsp), %rsi
sarq $0x3, %rsi
leaq 0x40(%rsp), %rdi
movq %rsp, %rdx
callq 0x3d90
leaq 0x88(%rsp), %rsi
movq 0x8(%rsi), %rbx
subq (%rsi), %rbx
leaq 0x150(%rsp), %rdi
callq 0x3e1e
leaq 0x138(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x3e1e
shrq $0x3, %rbx
movq %rsp, %rdi
leaq 0x150(%rsp), %rdx
leaq 0x138(%rsp), %rcx
movl %ebx, %esi
callq 0x43d6
movq 0x60(%rsp), %rdi
movq 0x70(%rsp), %rsi
movapd (%rsp), %xmm0
movapd %xmm0, 0x60(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x70(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x4b77
subq %rdi, %rsi
callq 0x2190
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x4b77
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x4b94
movq 0x148(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x4bb1
movq 0x160(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
leaq 0x88(%rsp), %rsi
movq 0x8(%rsi), %rbx
subq (%rsi), %rbx
leaq 0x120(%rsp), %rdi
callq 0x3e1e
leaq 0x108(%rsp), %rdi
movq %r12, %rsi
callq 0x3e1e
shrq $0x3, %rbx
movq %rsp, %rdi
leaq 0x120(%rsp), %rdx
leaq 0x108(%rsp), %rcx
movl %ebx, %esi
callq 0x43d6
movq 0x40(%rsp), %rdi
movq 0x50(%rsp), %rsi
movaps (%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x4c4b
subq %rdi, %rsi
callq 0x2190
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x4c4b
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x4c68
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x4c85
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq (%r12), %rax
movq 0x8(%r12), %rcx
movsd (%rax), %xmm1
subsd -0x8(%rcx), %xmm1
andpd 0x14b1(%rip), %xmm1     # 0x6150
movsd 0x1439(%rip), %xmm0     # 0x60e0
ucomisd %xmm1, %xmm0
jbe 0x4cf9
movq 0x80(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movsd (%rax), %xmm1
subsd -0x8(%rcx), %xmm1
andpd 0x1483(%rip), %xmm1     # 0x6150
ucomisd %xmm1, %xmm0
jbe 0x4cf9
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rcx)
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rcx)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
cmpq $0x9, %rcx
jb 0x4ff3
movl $0x1, %r15d
leaq 0x88(%rsp), %rbp
leaq 0x40(%rsp), %rbx
movq 0x88(%rsp), %rcx
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x20(%rsp)
ucomisd (%rcx), %xmm0
movl $0x0, %r14d
jbe 0x4d73
movq 0x90(%rsp), %rax
subq %rcx, %rax
sarq $0x3, %rax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x4d70
leaq 0x1(%rdx), %r14
movsd 0x20(%rsp), %xmm0
ucomisd 0x8(%rcx,%rdx,8), %xmm0
movq %r14, %rdx
ja 0x4d54
jmp 0x4d73
movq %rax, %r14
leaq 0xf0(%rsp), %rdi
movq %rbp, %rsi
callq 0x3e1e
leaq 0xd8(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x3e1e
leaq 0x180(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x3e1e
movslq %r14d, %r14
movq 0xf0(%rsp), %rax
movsd -0x8(%rax,%r14,8), %xmm0
movsd 0x20(%rsp), %xmm5
subsd %xmm0, %xmm5
movl %r14d, %r13d
movsd (%rax,%r13,8), %xmm1
subsd %xmm0, %xmm1
divsd %xmm1, %xmm5
movq 0x180(%rsp), %rdi
movq 0xd8(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movsd -0x8(%rax,%r14,8), %xmm2
movapd %xmm5, %xmm3
mulsd %xmm0, %xmm3
subsd %xmm2, %xmm0
movsd -0x8(%rdi,%r14,8), %xmm4
mulsd %xmm1, %xmm4
subsd %xmm0, %xmm4
mulsd (%rdi,%r13,8), %xmm1
subsd %xmm1, %xmm0
movsd 0x11e7(%rip), %xmm1     # 0x6008
subsd %xmm5, %xmm1
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
movapd %xmm5, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm5, %xmm0
mulsd %xmm4, %xmm1
addsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movq 0xa0(%rsp), %rax
movq (%rax), %rax
movsd %xmm1, (%rax,%r15,8)
movq 0x190(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x4e87
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x4ea4
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x28(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0xc0(%rsp), %rdi
movq %rbp, %rsi
callq 0x3e1e
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x3e1e
leaq 0x168(%rsp), %rdi
movq %rbx, %rsi
callq 0x3e1e
decq %r14
movq 0xc0(%rsp), %rax
movsd (%rax,%r14,8), %xmm0
movsd 0x20(%rsp), %xmm5
subsd %xmm0, %xmm5
movsd (%rax,%r13,8), %xmm1
subsd %xmm0, %xmm1
divsd %xmm1, %xmm5
movq 0x168(%rsp), %rdi
movq 0xa8(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
movsd (%rax,%r14,8), %xmm2
movapd %xmm5, %xmm3
mulsd %xmm0, %xmm3
subsd %xmm2, %xmm0
movsd (%rdi,%r14,8), %xmm4
mulsd %xmm1, %xmm4
subsd %xmm0, %xmm4
mulsd (%rdi,%r13,8), %xmm1
subsd %xmm1, %xmm0
movsd 0x10b2(%rip), %xmm1     # 0x6008
subsd %xmm5, %xmm1
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
movapd %xmm5, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm5, %xmm0
mulsd %xmm4, %xmm1
addsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movq 0x78(%rsp), %rax
movq (%rax), %rax
movsd %xmm1, (%rax,%r15,8)
movq 0x178(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x4fb9
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x4fd6
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
incq %r15
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x4d23
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x500a
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x5021
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x5038
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x5055
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x508c
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
jmp 0x508c
movq %rax, %rbx
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x5192
movq 0x130(%rsp), %rsi
jmp 0x5185
jmp 0x518f
movq %rax, %rbx
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x50d4
movq 0x148(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
jmp 0x50d4
movq %rax, %rbx
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x5192
movq 0x160(%rsp), %rsi
jmp 0x5185
jmp 0x518f
movq %rax, %rbx
jmp 0x51a9
movq %rax, %rbx
jmp 0x51c0
movq %rax, %rbx
jmp 0x51d7
movq %rax, %rbx
jmp 0x5134
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x5134
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x5192
movq 0x100(%rsp), %rsi
jmp 0x5185
movq %rax, %rbx
jmp 0x5170
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x5170
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x5192
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
jmp 0x5192
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x51a9
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x51c0
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x51d7
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x51f4
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2270