// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3CatmullRomSpline.cpp
// Function: gaps::R3CatmullRomSpline::PointDerivative(double) const
R3Vector R3CatmullRomSpline::
PointDerivative(RNScalar u) const
{
  // Return tangent vector at parametric value u

  // Get index variables
  int i = VertexIndex(u);
  double denom = VertexParameter(i+1) - VertexParameter(i);
  if (RNIsZero(denom)) return R3zero_vector;
  double t = (u - VertexParameter(i)) / denom;

  // Get control vertex_positions
  R3Point P0 = (i > 0) ? VertexPosition(i-1) : VertexPosition(0);
  R3Point P1 = VertexPosition(i);
  R3Point P2 = VertexPosition(i+1);
  R3Point P3 = (i < NVertices()-2) ? VertexPosition(i+2) : VertexPosition(NVertices()-1);

  // Compute derivative vector
  R3Vector v = R3zero_vector;
  v += BlendingWeightDerivative(t, -1) * P0.Vector();
  v += BlendingWeightDerivative(t,  0) * P1.Vector();
  v += BlendingWeightDerivative(t,  1) * P2.Vector();
  v += BlendingWeightDerivative(t,  2) * P3.Vector();

  // Return derivative vector
  return v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
movsd %xmm0, (%rsp)
callq *0x268(%rax)
movl %eax, %r15d
leal 0x1(%r15), %ecx
movq 0x10(%r14), %rax
movslq %ecx, %r12
testq %rax, %rax
je 0x4f3a7
movsd (%rax,%r12,8), %xmm0
jmp 0x4f3ae
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movslq %r15d, %r13
testq %rax, %rax
je 0x4f3be
movsd (%rax,%r13,8), %xmm1
jmp 0x4f3c3
cvtsi2sd %r15d, %xmm1
subsd %xmm1, %xmm0
leaq 0x967ca(%rip), %rcx     # 0xe5b98
movsd (%rcx), %xmm1
movapd 0x52c46(%rip), %xmm2    # 0xa2020
xorpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jb 0x4f3fe
ucomisd %xmm0, %xmm1
jb 0x4f3fe
leaq 0x592ef(%rip), %rsi     # 0xa86e0
movq %rbx, %rdi
callq 0x3d4ce
jmp 0x4f6be
testq %rax, %rax
je 0x4f40b
movsd (%rax,%r13,8), %xmm1
jmp 0x4f413
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
movsd (%rsp), %xmm2
subsd %xmm1, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, (%rsp)
testl %r15d, %r15d
movq 0x8(%r14), %rax
movl %r15d, %ecx
leaq (%rcx,%rcx,2), %rcx
leaq -0x18(%rax,%rcx,8), %rsi
cmovleq %rax, %rsi
leaq 0x90(%rsp), %rbp
movq %rbp, %rdi
callq 0x3ca36
leaq (,%r13,2), %rsi
addq %r13, %rsi
shlq $0x3, %rsi
addq 0x8(%r14), %rsi
leaq 0x78(%rsp), %r13
movq %r13, %rdi
callq 0x3ca36
leaq (%r12,%r12,2), %rsi
shlq $0x3, %rsi
addq 0x8(%r14), %rsi
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x3ca36
movl 0x20(%r14), %eax
leal -0x2(%rax), %ecx
cmpl %ecx, %r15d
cmovll %r15d, %eax
movq 0x8(%r14), %rcx
cltq
leaq (%rax,%rax,2), %rax
leaq 0x30(%rcx,%rax,8), %rdx
leaq -0x18(%rcx,%rax,8), %rsi
cmovlq %rdx, %rsi
leaq 0x48(%rsp), %rdi
callq 0x3ca36
leaq 0x59224(%rip), %rsi     # 0xa86e0
movq %rbx, %rdi
callq 0x3d4ce
movsd (%rsp), %xmm1
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, %xmm2
movsd %xmm0, 0x10(%rsp)
movsd 0x60(%r14), %xmm3
movsd 0x52d07(%rip), %xmm0    # 0xa21f0
mulsd %xmm3, %xmm0
mulsd %xmm1, %xmm0
subsd %xmm3, %xmm0
mulsd 0x59b1b(%rip), %xmm3    # 0xa9018
mulsd %xmm2, %xmm3
addsd %xmm0, %xmm3
movsd %xmm3, 0x8(%rsp)
movsd (%rbp), %xmm0
movsd 0x8(%rbp), %xmm1
movsd 0x10(%rbp), %xmm2
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0x3d4be
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x3de8e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3deb0
movsd 0x60(%r14), %xmm0
movsd 0x59ac2(%rip), %xmm2    # 0xa9018
addsd %xmm0, %xmm2
addsd %xmm2, %xmm2
movsd 0x52ca2(%rip), %xmm1    # 0xa2208
subsd %xmm0, %xmm1
mulsd 0x52c66(%rip), %xmm1    # 0xa21d8
mulsd 0x10(%rsp), %xmm1
mulsd (%rsp), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd (%r13), %xmm0
movsd 0x8(%r13), %xmm1
movsd 0x10(%r13), %xmm2
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x3d4be
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x3de8e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3deb0
movsd 0x60(%r14), %xmm3
movapd %xmm3, %xmm0
addsd %xmm3, %xmm0
movsd 0x52bfb(%rip), %xmm2    # 0xa21d8
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
addsd %xmm1, %xmm1
mulsd (%rsp), %xmm1
addsd %xmm3, %xmm1
addsd 0x52c06(%rip), %xmm3    # 0xa2200
mulsd %xmm2, %xmm3
mulsd 0x10(%rsp), %xmm3
addsd %xmm1, %xmm3
movsd %xmm3, 0x8(%rsp)
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movsd 0x10(%r12), %xmm2
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x3d4be
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x3de8e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3deb0
movsd 0x60(%r14), %xmm0
movsd 0x52ba2(%rip), %xmm1    # 0xa2200
mulsd %xmm0, %xmm1
mulsd 0x52b6e(%rip), %xmm0    # 0xa21d8
mulsd 0x10(%rsp), %xmm0
mulsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
leaq 0x48(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x3d4be
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movsd (%rsp), %xmm0
callq 0x3de8e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3deb0
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop