// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/GSV/GSVSegment.cpp
// Function: gaps::GSVSegment::Front(double) const
R3Vector GSVSegment::
Front(RNScalar timestamp) const
{
  // Interpolate panorama front vectors
  if (NPanoramas() == 0) return R3zero_vector;
  GSVPanorama *panorama0 = FindPanoramaBeforeTimestamp(timestamp);
  if (!panorama0) return R3zero_vector;
  int i0 = panorama0->SegmentIndex();
  if (i0 >= NPanoramas()-1) return panorama0->Front();
  GSVPanorama *panorama1 = Panorama(i0 + 1);
  RNScalar t0 = panorama0->Timestamp();
  RNScalar t1 = panorama1->Timestamp();
  if (t1 <= t0) return panorama0->Front();
  RNScalar t = (timestamp - t0) / (t1 - t0);
  if (t <= 0) return panorama0->Front();
  else if (t >= 1) return panorama1->Front();
  R3Vector front = (1 - t) * panorama0->Front() + t * panorama1->Front();

  // Make sure orhtogonal to positive z (up)
  front[2] = 0; front.Normalize();

  // Return front direction of the car at timestamp
  return front;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x4c(%rsi)
je 0x3a1de
movq %rsi, %r15
movq %rsi, %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x39da8
testq %rax, %rax
je 0x3a1de
movq %rax, %r14
movslq 0x10(%rax), %rax
movl 0x4c(%r15), %ecx
decl %ecx
cmpl %ecx, %eax
jge 0x3a1ea
movq 0x40(%r15), %rcx
movq 0x8(%rcx,%rax,8), %r15
movsd 0x70(%r14), %xmm0
ucomisd 0x113fac(%rip), %xmm0   # 0x14e070
jne 0x3a0d0
jp 0x3a0d0
movq %r14, %rdi
callq 0x3d230
movsd 0x70(%r14), %xmm2
movsd 0x70(%r15), %xmm0
ucomisd 0x113f8c(%rip), %xmm0   # 0x14e070
jne 0x3a0fc
jp 0x3a0fc
movq %r15, %rdi
movsd %xmm2, 0x8(%rsp)
callq 0x3d230
movsd 0x8(%rsp), %xmm2
movsd 0x70(%r15), %xmm0
ucomisd %xmm0, %xmm2
jae 0x3a1ea
movsd 0x10(%rsp), %xmm1
subsd %xmm2, %xmm1
subsd %xmm2, %xmm0
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jae 0x3a1ea
ucomisd 0x113f54(%rip), %xmm1   # 0x14e088
jae 0x3a226
movsd 0x113f46(%rip), %xmm0   # 0x14e088
movsd %xmm1, 0x10(%rsp)
subsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r14, %r12
addq $0x40, %r12
leaq 0x11ebe0(%rip), %rsi    # 0x158d40
movq %r12, %rdi
callq 0xd6b84
testl %eax, %eax
je 0x3a174
movq %r14, %rdi
callq 0x3cf6e
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
movsd 0x8(%rsp), %xmm0
callq 0xd7296
leaq 0x40(%r15), %r14
leaq 0x11ebae(%rip), %rsi    # 0x158d40
movq %r14, %rdi
callq 0xd6b84
testl %eax, %eax
je 0x3a1a6
movq %r15, %rdi
callq 0x3cf6e
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movsd 0x10(%rsp), %xmm0
callq 0xd7296
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0xd757c
movq $0x0, 0x10(%rbx)
movq %rbx, %rdi
callq 0xd6be8
jmp 0x3a217
leaq 0x11eb5b(%rip), %rsi    # 0x158d40
movq %rbx, %rdi
jmp 0x3a212
movq %r14, %r15
addq $0x40, %r15
leaq 0x11eb48(%rip), %rsi    # 0x158d40
movq %r15, %rdi
callq 0xd6b84
testl %eax, %eax
je 0x3a20c
movq %r14, %rdi
callq 0x3cf6e
movq %rbx, %rdi
movq %r15, %rsi
callq 0xd68d6
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x40(%r15), %r14
leaq 0x11eb0f(%rip), %rsi    # 0x158d40
movq %r14, %rdi
callq 0xd6b84
testl %eax, %eax
je 0x3a245
movq %r15, %rdi
callq 0x3cf6e
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x3a212
nop