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

  // Load texture
  LoadTexture(data);
  if (data->texture_id == 0) return;

  // Enable texture
  glBindTexture(GL_TEXTURE_2D, data->texture_id);
  glEnable(GL_TEXTURE_2D);

  // Draw textured polygon
  R3Point origin = viewpoint + towards * image_billboard_depth;
  R3Vector dx = right * image_billboard_depth * tan(xfov);
  R3Vector dy = up * image_billboard_depth * tan(yfov);
  R3Point ur = origin + dx + dy;
  R3Point lr = origin + dx - dy;
  R3Point ul = origin - dx + dy;
  R3Point ll = origin - dx - dy;
  RNLoadRgb(1, 1, 1);
  RNGrfxBegin(RN_GRFX_POLYGON);
  R3LoadTextureCoords(0,0);
  R3LoadPoint(ll);
  R3LoadTextureCoords(1,0);
  R3LoadPoint(lr);
  R3LoadTextureCoords(1, 1);
  R3LoadPoint(ur);
  R3LoadTextureCoords(0,1);
  R3LoadPoint(ul);
  RNGrfxEnd();
  
  // Disable texture
  glDisable(GL_TEXTURE_2D);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x8(%rsp)
cmpl $0x0, 0x1a9e88(%rip)    # 0x1db3b0
je 0x31715
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r13
callq 0x321fa
movl 0x770(%r13), %esi
testl %esi, %esi
je 0x31715
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27be0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27880
leaq 0x90(%rsp), %r13
movsd 0x11ab03(%rip), %xmm0   # 0x14c078
movq %r13, %rdi
movq %rbx, %rsi
callq 0xd580e
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xd4723
leaq 0x78(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movsd 0x11aacf(%rip), %xmm0   # 0x14c078
callq 0xd580e
movsd 0x8(%rsp), %xmm0
callq 0x274e0
leaq 0x90(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0xd580e
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movsd 0x11aa99(%rip), %xmm0   # 0x14c078
callq 0xd580e
movsd 0x10(%rsp), %xmm0
callq 0x274e0
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0xd580e
leaq 0x60(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xd4723
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xd4723
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xd4723
leaq 0x60(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xd4dff
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xd4dff
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0xd4723
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xd4dff
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0xd4dff
movss 0x11aa8d(%rip), %xmm0   # 0x14c12c
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x28380
movl $0x9, %edi
callq 0x271a0
xorl %edi, %edi
xorl %esi, %esi
callq 0x276d0
movq %rbx, %rdi
callq 0x271c0
movl $0x1, %edi
xorl %esi, %esi
callq 0x276d0
movq %r13, %rdi
callq 0x271c0
movl $0x1, %edi
movl $0x1, %esi
callq 0x276d0
leaq 0x18(%rsp), %rdi
callq 0x271c0
xorl %edi, %edi
movl $0x1, %esi
callq 0x276d0
movq %r12, %rdi
callq 0x271c0
callq 0x27cd0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27200
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq