// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/apps/gapsview/gapsview.cpp
// Function: DrawImageInset(ImageData*, double, double, double)
static void
DrawImageInset(ImageData *data,
  double x, double y, double scale)
{
  // Check if drawing image insets
  if (!show_image_insets) return;

  // Get convenient variables
  double w = scale * data->image_width;
  double h = scale * data->image_height;
  if ((w == 0) || (h == 0)) return;

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

  // Set viewing transformation
  glMatrixMode(GL_PROJECTION);  
  glPushMatrix();
  glLoadIdentity();
  glOrtho(0, GLUTwindow_width, 0, GLUTwindow_height, 0, 1);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();

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

  // Draw textured polygon
  RNLoadRgb(1, 1, 1);
  RNGrfxBegin(RN_GRFX_POLYGON);
  R3LoadTextureCoords(0, 0);
  R3LoadPoint(x, y, -0.5);
  R3LoadTextureCoords(1, 0);
  R3LoadPoint(x+w, y, -0.5);
  R3LoadTextureCoords(1, 1);
  R3LoadPoint(x+w, y+h, -0.5);
  R3LoadTextureCoords(0, 1);
  R3LoadPoint(x, y+h, -0.5);
  RNGrfxEnd();

  // Disable texture
  glDisable(GL_TEXTURE_2D);

  // Restore viewing transformation
  glMatrixMode(GL_PROJECTION);  
  glPopMatrix();
  glMatrixMode(GL_MODELVIEW);  
  glPopMatrix();
}

// Assembly:
pushq %rbx
subq $0x30, %rsp
cmpl $0x0, 0x1aa1a8(%rip)    # 0x1db3ac
je 0x313b8
movq %rdi, %rbx
cvtdq2pd 0x768(%rdi), %xmm2
mulpd 0x11b163(%rip), %xmm2   # 0x14c380
xorpd %xmm1, %xmm1
movapd %xmm2, 0x10(%rsp)
cmpeqpd %xmm2, %xmm1
movmskpd %xmm1, %eax
testl %eax, %eax
jne 0x313b8
movq %rbx, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x321fa
cmpl $0x0, 0x770(%rbx)
je 0x313b8
movl $0x1701, %edi           # imm = 0x1701
callq 0x27d30
callq 0x27fe0
callq 0x27cc0
xorps %xmm1, %xmm1
cvtsi2sdl 0x1a477e(%rip), %xmm1 # 0x1d59f0
cvtsi2sdl 0x1a477a(%rip), %xmm3 # 0x1d59f4
movsd 0x11adf6(%rip), %xmm5   # 0x14c078
xorps %xmm0, %xmm0
xorpd %xmm2, %xmm2
xorps %xmm4, %xmm4
callq 0x28270
movl $0x1700, %edi           # imm = 0x1700
callq 0x27d30
callq 0x27fe0
callq 0x27cc0
movl 0x770(%rbx), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27be0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27880
movss 0x11ae65(%rip), %xmm0   # 0x14c12c
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x28380
movl $0x9, %edi
callq 0x271a0
xorl %edi, %edi
xorl %esi, %esi
callq 0x276d0
movsd 0x11adfb(%rip), %xmm2   # 0x14c0e8
xorps %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x27ee0
movl $0x1, %edi
xorl %esi, %esi
callq 0x276d0
movapd 0x10(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
xorps %xmm1, %xmm1
movsd 0x11adc4(%rip), %xmm2   # 0x14c0e8
callq 0x27ee0
movl $0x1, %edi
movl $0x1, %esi
callq 0x276d0
movapd 0x10(%rsp), %xmm1
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd 0x11acf6(%rip), %xmm1   # 0x14c040
movapd %xmm1, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movsd 0x11ad8b(%rip), %xmm2   # 0x14c0e8
callq 0x27ee0
xorl %edi, %edi
movl $0x1, %esi
callq 0x276d0
movsd 0x8(%rsp), %xmm0
movaps 0x10(%rsp), %xmm1
movsd 0x11ad67(%rip), %xmm2   # 0x14c0e8
callq 0x27ee0
callq 0x27cd0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27200
movl $0x1701, %edi           # imm = 0x1701
callq 0x27d30
callq 0x28250
movl $0x1700, %edi           # imm = 0x1700
callq 0x27d30
addq $0x30, %rsp
popq %rbx
jmp 0x28250
addq $0x30, %rsp
popq %rbx
retq