// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/gapsview/gapsview.cpp
// Function: DrawDotOnImageBillboard(ImageData*, gaps::R3Point const&, gaps::R3Vector const&, gaps::R3Vector const&, gaps::R3Vector const&, double, double, double, gaps::R2Point const&, double)
static void
DrawDotOnImageBillboard(ImageData *data, const R3Point& viewpoint,
  const R3Vector& towards, const R3Vector& right, const R3Vector& up,
  RNAngle xfov, RNAngle yfov, RNLength image_billboard_depth,
  const R2Point& image_position, RNLength radius)
{
  // Check if drawing image billboards
  if (!show_image_billboards) return;

  // Get convenient variables
  int w = data->image_width;
  int h = data->image_height;
  if ((w == 0) || (h == 0)) return;
  
  // Check 2D image_position
  if (image_position.X() < 0) return;
  if (image_position.Y() < 0) return;
  if (image_position.X() >= w) return;
  if (image_position.Y() >= h) return;

  // Compute 3D position
  RNScalar dx = 2.0 * (image_position.X() - 0.5 * w) / w;
  RNScalar dy = 2.0 * (image_position.Y() - 0.5 * h) / h;
  R3Point world_position = viewpoint + image_billboard_depth * towards;
  world_position += image_billboard_depth * dx * right * tan(xfov);
  world_position += image_billboard_depth * dy * up * tan(yfov);

  // Draw sphere
  RNLoadRgb(1, 0, 0);
  R3Sphere(world_position, radius).Draw();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x80, %rsp
cmpl $0x0, 0x1a9c72(%rip)    # 0x1db3b0
je 0x318ce
movl 0x768(%rdi), %eax
testl %eax, %eax
je 0x318ce
movq %rcx, %r14
movl 0x76c(%rdi), %ecx
testl %ecx, %ecx
je 0x318ce
movapd %xmm0, %xmm5
xorpd %xmm0, %xmm0
ucomisd %xmm2, %xmm0
ja 0x318ce
ucomisd %xmm3, %xmm0
ja 0x318ce
cvtsi2sd %eax, %xmm4
ucomisd %xmm4, %xmm2
jae 0x318ce
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
ucomisd %xmm0, %xmm3
jae 0x318ce
movq %r8, %rbx
movq %rsi, %r12
movsd 0x11a93c(%rip), %xmm6   # 0x14c0e8
movapd %xmm4, %xmm7
mulsd %xmm6, %xmm7
addsd %xmm2, %xmm7
addsd %xmm7, %xmm7
divsd %xmm4, %xmm7
movsd %xmm7, 0x10(%rsp)
mulsd %xmm0, %xmm6
addsd %xmm3, %xmm6
addsd %xmm6, %xmm6
divsd %xmm0, %xmm6
movsd %xmm6, 0x20(%rsp)
leaq 0x28(%rsp), %r13
movsd 0x11a88f(%rip), %xmm0   # 0x14c078
movq %r13, %rdi
movq %rdx, %rsi
movsd %xmm1, 0x18(%rsp)
movsd %xmm5, 0x8(%rsp)
callq 0xd580e
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xd4723
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movsd 0x10(%rsp), %xmm0
callq 0xd580e
movsd 0x8(%rsp), %xmm0
callq 0x274e0
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0xd580e
movq %r15, %rdi
movq %r14, %rsi
callq 0xd47c0
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movsd 0x20(%rsp), %xmm0
callq 0xd580e
movsd 0x18(%rsp), %xmm0
callq 0x274e0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd580e
movq %r15, %rdi
movq %rbx, %rsi
callq 0xd47c0
movss 0x11a899(%rip), %xmm0   # 0x14c12c
xorps %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x28380
leaq 0x28(%rsp), %rbx
movsd 0x11a7a4(%rip), %xmm0   # 0x14c050
movq %rbx, %rdi
movq %r15, %rsi
callq 0xbb3fa
movl $0x772, %esi            # imm = 0x772
movq %rbx, %rdi
callq 0x915b2
leaq 0x28(%rsp), %rdi
callq 0xbe790
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xbe790
movq %rbx, %rdi
callq 0x28150