// File: /workspace/github_cpp_makefile_star2_O1/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, 0x1abb0e(%rip)    # 0x1dd3c0
je 0x31a51
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 0x31a51
movsd (%r9), %xmm4
xorpd %xmm2, %xmm2
ucomisd %xmm4, %xmm2
ja 0x31a51
movaps %xmm0, %xmm5
movsd 0x8(%r9), %xmm0
ucomisd %xmm0, %xmm2
ja 0x31a51
cvtsi2sd %ecx, %xmm3
ucomisd %xmm3, %xmm4
jae 0x31a51
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
ucomisd %xmm2, %xmm0
jae 0x31a51
movq %r8, %rbx
movsd 0x11c7c1(%rip), %xmm6   # 0x14e0f0
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 0x11c71c(%rip), %xmm0   # 0x14e088
movq %r13, %rdi
movq %rdx, %rsi
movsd %xmm1, 0x18(%rsp)
movsd %xmm5, 0x8(%rsp)
callq 0xd7296
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xd6179
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movsd 0x10(%rsp), %xmm0
callq 0xd7296
movsd 0x8(%rsp), %xmm0
callq 0x274e0
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0xd7296
movq %r15, %rdi
movq %r14, %rsi
callq 0xd6216
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movsd 0x20(%rsp), %xmm0
callq 0xd7296
movsd 0x18(%rsp), %xmm0
callq 0x274e0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd7296
movq %r15, %rdi
movq %rbx, %rsi
callq 0xd6216
movss 0x11c71e(%rip), %xmm0   # 0x14e134
xorps %xmm1, %xmm1
xorpd %xmm2, %xmm2
callq 0x28390
leaq 0x28(%rsp), %rbx
movsd 0x11c621(%rip), %xmm0   # 0x14e050
movq %rbx, %rdi
movq %r15, %rsi
callq 0xbca82
movl $0x772, %esi            # imm = 0x772
movq %rbx, %rdi
callq 0x92364
leaq 0x28(%rsp), %rdi
callq 0xbfe90
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xbfe90
movq %rbx, %rdi
callq 0x28160