// File: /workspace/github_cpp_makefile_star2_O2/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, 0x194512(%rip)    # 0x1c43d0
je 0x3005a
movq %rcx, %r14
movq %rsi, %r12
movl 0x768(%rdi), %ecx
movl 0x76c(%rdi), %eax
testl %ecx, %ecx
sete %sil
testl %eax, %eax
sete %dil
orb %sil, %dil
jne 0x3005a
movsd (%r9), %xmm4
xorpd %xmm2, %xmm2
ucomisd %xmm4, %xmm2
ja 0x3005a
movaps %xmm0, %xmm5
movsd 0x8(%r9), %xmm0
ucomisd %xmm0, %xmm2
ja 0x3005a
cvtsi2sd %ecx, %xmm3
ucomisd %xmm3, %xmm4
jae 0x3005a
cvtsi2sd %eax, %xmm2
ucomisd %xmm2, %xmm0
jae 0x3005a
movq %r8, %rbx
movsd 0xfb1a0(%rip), %xmm6    # 0x12b0d8
movapd %xmm3, %xmm7
mulsd %xmm6, %xmm7
addsd %xmm4, %xmm7
addsd %xmm7, %xmm7
divsd %xmm3, %xmm7
movsd %xmm7, 0x10(%rsp)
mulsd %xmm2, %xmm6
addsd %xmm0, %xmm6
addsd %xmm6, %xmm6
divsd %xmm2, %xmm6
movsd %xmm6, 0x20(%rsp)
leaq 0x28(%rsp), %r13
movsd 0xfb0fb(%rip), %xmm0    # 0x12b070
movq %r13, %rdi
movq %rdx, %rsi
movsd %xmm1, 0x18(%rsp)
movsd %xmm5, 0x8(%rsp)
callq 0xc1cb2
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xc10c3
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movsd 0x10(%rsp), %xmm0
callq 0xc1cb2
movsd 0x8(%rsp), %xmm0
callq 0x274e0
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0xc1cb2
movq %r15, %rdi
movq %r14, %rsi
callq 0xc114c
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movsd 0x20(%rsp), %xmm0
callq 0xc1cb2
movsd 0x18(%rsp), %xmm0
callq 0x274e0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc1cb2
movq %r15, %rdi
movq %rbx, %rsi
callq 0xc114c
movss 0xfb10d(%rip), %xmm0    # 0x12b12c
xorps %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x283c0
leaq 0x28(%rsp), %rbx
movsd 0xfb010(%rip), %xmm0    # 0x12b048
movq %rbx, %rdi
movq %r15, %rsi
callq 0xaa6c8
movl $0x772, %esi            # imm = 0x772
movq %rbx, %rdi
callq 0x84a86
leaq 0x28(%rsp), %rdi
callq 0xad65a
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xad65a
movq %rbx, %rdi
callq 0x28170