// File: /workspace/github_cpp_makefile_star2_O2/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, 0x19471d(%rip)    # 0x1c43d0
je 0x2fe95
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r13
callq 0x3094d
movl 0x770(%r13), %esi
testl %esi, %esi
je 0x2fe95
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27be0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27890
leaq 0x90(%rsp), %r13
movsd 0xfb370(%rip), %xmm0    # 0x12b070
movq %r13, %rdi
movq %rbx, %rsi
callq 0xc1cb2
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xc10c3
leaq 0x78(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movsd 0xfb33c(%rip), %xmm0    # 0x12b070
callq 0xc1cb2
movsd 0x8(%rsp), %xmm0
callq 0x274e0
leaq 0x90(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0xc1cb2
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movsd 0xfb306(%rip), %xmm0    # 0x12b070
callq 0xc1cb2
movsd 0x10(%rsp), %xmm0
callq 0x274e0
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0xc1cb2
leaq 0x60(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xc10c3
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xc10c3
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xc10c3
leaq 0x60(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xc154d
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xc154d
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0xc10c3
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xc154d
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0xc154d
movss 0xfb302(%rip), %xmm0    # 0x12b12c
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x283c0
pushq $0x9
popq %rdi
callq 0x271a0
xorl %edi, %edi
xorl %esi, %esi
callq 0x276d0
movq %rbx, %rdi
callq 0x271c0
pushq $0x1
popq %rbx
movl %ebx, %edi
xorl %esi, %esi
callq 0x276d0
movq %r13, %rdi
callq 0x271c0
movl %ebx, %edi
movl %ebx, %esi
callq 0x276d0
leaq 0x18(%rsp), %rdi
callq 0x271c0
xorl %edi, %edi
movl %ebx, %esi
callq 0x276d0
movq %r12, %rdi
callq 0x271c0
callq 0x27ce0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27220
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq