// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3CatmullRomSpline.cpp
// Function: gaps::R3CatmullRomSpline::PointPosition(double) const
R3Point R3CatmullRomSpline::
PointPosition(RNScalar u) const
{
  // Return position at parametric value u

  // Get index variables
  int i = VertexIndex(u);
  double denom = VertexParameter(i+1) - VertexParameter(i);
  if (RNIsZero(denom)) return VertexPosition(i);
  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 position
  R3Point p = R3zero_point;
  p += BlendingWeight(t, -1) * P0.Vector();
  p += BlendingWeight(t,  0) * P1.Vector();
  p += BlendingWeight(t,  1) * P2.Vector();
  p += BlendingWeight(t,  2) * P3.Vector();

  // Return position
  return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
movsd %xmm0, 0x8(%rsp)
callq *0x268(%rax)
leal 0x1(%rax), %edx
movq 0x10(%r14), %rcx
movslq %eax, %r15
movslq %edx, %r12
testq %rcx, %rcx
je 0x4e3d6
movsd (%rcx,%r12,8), %xmm0
subsd (%rcx,%r15,8), %xmm0
leaq 0x977e6(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
movapd 0x53c62(%rip), %xmm2    # 0xa2020
xorpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jb 0x4e3ce
ucomisd %xmm0, %xmm1
jae 0x4e408
movsd (%rcx,%r15,8), %xmm1
jmp 0x4e421
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
leaq 0x977ac(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm2
movapd 0x53c28(%rip), %xmm3    # 0xa2020
xorpd %xmm2, %xmm3
ucomisd %xmm3, %xmm0
jb 0x4e421
ucomisd %xmm0, %xmm2
jb 0x4e421
leaq (%r15,%r15,2), %rsi
shlq $0x3, %rsi
addq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x3c542
jmp 0x4e6c6
movsd 0x8(%rsp), %xmm2
subsd %xmm1, %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, 0x8(%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 0xa0(%rsp), %rbp
movq %rbp, %rdi
callq 0x3c542
movq %r15, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
movq 0x8(%r14), %rsi
addq %r13, %rsi
leaq 0x70(%rsp), %rdi
callq 0x3c542
leaq (%r12,%r12,2), %rsi
shlq $0x3, %rsi
addq 0x8(%r14), %rsi
leaq 0x88(%rsp), %r12
movq %r12, %rdi
callq 0x3c542
movslq 0x20(%r14), %rax
leal -0x2(%rax), %ecx
cmpl %ecx, %r15d
movq 0x8(%r14), %rcx
leaq (%rax,%rax,2), %rax
leaq -0x18(%rcx,%rax,8), %rax
leaq 0x30(%rcx,%r13), %rsi
cmovgeq %rax, %rsi
leaq 0x58(%rsp), %rdi
callq 0x3c542
leaq 0x49859b(%rip), %rsi    # 0x4e6a60
movq %rbx, %rdi
callq 0x3c542
movsd 0x8(%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
movapd %xmm0, %xmm2
movapd %xmm0, %xmm3
mulsd %xmm1, %xmm2
movsd %xmm2, 0x10(%rsp)
movsd 0x60(%r14), %xmm0
movapd %xmm0, %xmm4
addsd %xmm0, %xmm4
mulsd %xmm1, %xmm4
movapd %xmm0, %xmm1
mulsd %xmm3, %xmm1
subsd %xmm1, %xmm4
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm4
movsd %xmm4, 0x18(%rsp)
movsd (%rbp), %xmm0
movsd 0x8(%rbp), %xmm1
movsd 0x10(%rbp), %xmm2
leaq 0x28(%rsp), %rbp
movq %rbp, %rdi
callq 0x3cfc6
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movsd 0x18(%rsp), %xmm0
callq 0x3d962
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3c914
movsd 0x60(%r14), %xmm0
movsd 0x5aaae(%rip), %xmm1    # 0xa9018
addsd %xmm0, %xmm1
mulsd 0x20(%rsp), %xmm1
addsd 0x53abc(%rip), %xmm1    # 0xa2038
movsd 0x53c84(%rip), %xmm2    # 0xa2208
subsd %xmm0, %xmm2
mulsd 0x10(%rsp), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0x18(%rsp)
leaq 0x70(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x3cfc6
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movsd 0x18(%rsp), %xmm0
callq 0x3d962
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3c914
movsd 0x60(%r14), %xmm2
movapd %xmm2, %xmm0
addsd %xmm2, %xmm0
movsd 0x53be9(%rip), %xmm1    # 0xa21d8
subsd %xmm0, %xmm1
mulsd 0x20(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd 0x53bf1(%rip), %xmm2    # 0xa2200
mulsd 0x10(%rsp), %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
movsd 0x10(%r12), %xmm2
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x3cfc6
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x3d962
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3c914
movsd 0x60(%r14), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x20(%rsp), %xmm2
mulsd %xmm0, %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, 0x10(%rsp)
leaq 0x58(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm1
movsd 0x10(%rax), %xmm2
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x3cfc6
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movsd 0x10(%rsp), %xmm0
callq 0x3d962
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3c914
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop