// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3CatmullRomSpline.cpp
// Function: gaps::R3CatmullRomSpline::PhantomVertexPosition(int, int) const
R3Point R3CatmullRomSpline::
PhantomVertexPosition(int i, int j) const
{
  // Return position of phantom Bezier curve control point within ith segment
  // j=0 means first phantom point, and j=1 means second phantom point
  if ((i == 0) && (j == 0)) {
    // Return first phantom point on first curve segment
    return tao * (VertexPosition(0) + PhantomVertexPosition(0, 1));
  }
  else if ((i == NVertices()-1) && (j == 1)) {
    // Return last phantom point on last curve segment
    return tao * (VertexPosition(NVertices()-1) + PhantomVertexPosition(NVertices()-1, 0));
  }
  else {
    // Return phantom point near vertex in middle of spline
    int vertex_index = (j == 0) ? i : i+1;
    R3Point p = VertexPosition(vertex_index);
    R3Vector v = VertexPosition(vertex_index+1) - VertexPosition(vertex_index-1);
    if (j == 0) return p + tao * v;
    else return p - tao * v;
  }
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x20(%rsp)
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0x170(%rsp)
movq %rsi, 0x168(%rsp)
movl %edx, 0x164(%rsp)
movl %ecx, 0x160(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x164(%rsp)
jne 0x90b15
cmpl $0x0, 0x160(%rsp)
jne 0x90b15
movq 0x30(%rsp), %rsi
movsd 0x60(%rsi), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x130(%rsp), %rdi
xorl %edx, %edx
callq 0x919b0
movq 0x30(%rsp), %rsi
leaq 0x118(%rsp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x90a50
leaq 0x148(%rsp), %rdi
leaq 0x130(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0x6fa40
movq 0x20(%rsp), %rdi
movsd 0x18(%rsp), %xmm0
leaq 0x148(%rsp), %rsi
callq 0x36b10
jmp 0x90cdc
movq 0x30(%rsp), %rdi
movl 0x164(%rsp), %eax
movl %eax, 0x14(%rsp)
callq 0x91990
movl %eax, %ecx
movl 0x14(%rsp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x90bd2
cmpl $0x1, 0x160(%rsp)
jne 0x90bd2
movq 0x30(%rsp), %rdi
movsd 0x60(%rdi), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x91990
movq 0x30(%rsp), %rsi
movl %eax, %edx
subl $0x1, %edx
leaq 0xe8(%rsp), %rdi
callq 0x919b0
movq 0x30(%rsp), %rdi
callq 0x91990
movq 0x30(%rsp), %rsi
movl %eax, %edx
subl $0x1, %edx
leaq 0xd0(%rsp), %rdi
xorl %ecx, %ecx
callq 0x90a50
leaq 0x100(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0x6fa40
movq 0x20(%rsp), %rdi
movsd 0x8(%rsp), %xmm0
leaq 0x100(%rsp), %rsi
callq 0x36b10
jmp 0x90cdc
cmpl $0x0, 0x160(%rsp)
jne 0x90be9
movl 0x164(%rsp), %eax
movl %eax, 0x4(%rsp)
jmp 0x90bf7
movl 0x164(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
movq 0x30(%rsp), %rsi
movl 0x4(%rsp), %eax
movl %eax, 0xcc(%rsp)
movl 0xcc(%rsp), %edx
leaq 0xb0(%rsp), %rdi
callq 0x919b0
movq 0x30(%rsp), %rsi
movl 0xcc(%rsp), %edx
addl $0x1, %edx
leaq 0x80(%rsp), %rdi
callq 0x919b0
movq 0x30(%rsp), %rsi
movl 0xcc(%rsp), %edx
subl $0x1, %edx
leaq 0x68(%rsp), %rdi
callq 0x919b0
leaq 0x98(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0x6eeb0
cmpl $0x0, 0x160(%rsp)
jne 0x90ca9
movq 0x30(%rsp), %rax
movsd 0x60(%rax), %xmm0
leaq 0x50(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x13800
movq 0x20(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x6f110
jmp 0x90cdc
movq 0x30(%rsp), %rax
movsd 0x60(%rax), %xmm0
leaq 0x38(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x13800
movq 0x20(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x6fab0
movq 0x28(%rsp), %rax
addq $0x178, %rsp            # imm = 0x178
retq
nopl (%rax)