// File: /workspace/github_cpp_makefile_star2_O2/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, 0x194a15(%rip)    # 0x1c43cc
je 0x2fb5d
movq %rdi, %rbx
cvtdq2pd 0x768(%rdi), %xmm2
mulpd 0xfb9b0(%rip), %xmm2    # 0x12b380
xorpd %xmm1, %xmm1
movapd %xmm2, 0x10(%rsp)
cmpeqpd %xmm2, %xmm1
movmskpd %xmm1, %eax
testl %eax, %eax
jne 0x2fb5d
movq %rbx, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x3094d
cmpl $0x0, 0x770(%rbx)
je 0x2fb5d
movl $0x1701, %edi           # imm = 0x1701
callq 0x27d40
callq 0x28000
callq 0x27cd0
cvtsi2sdl 0x18efee(%rip), %xmm1 # 0x1bea10
cvtsi2sdl 0x18efea(%rip), %xmm3 # 0x1bea14
movsd 0xfb63e(%rip), %xmm5    # 0x12b070
xorps %xmm0, %xmm0
xorpd %xmm2, %xmm2
xorps %xmm4, %xmm4
callq 0x28290
movl $0x1700, %edi           # imm = 0x1700
callq 0x27d40
callq 0x28000
callq 0x27cd0
movl 0x770(%rbx), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27be0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27890
movss 0xfb6b5(%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
movsd 0xfb63d(%rip), %xmm2    # 0x12b0d8
xorps %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x27f00
pushq $0x1
popq %rbx
movl %ebx, %edi
xorl %esi, %esi
callq 0x276d0
movapd 0x10(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movapd %xmm0, 0x20(%rsp)
xorps %xmm1, %xmm1
movsd 0xfb606(%rip), %xmm2    # 0x12b0d8
callq 0x27f00
movl %ebx, %edi
movl %ebx, %esi
callq 0x276d0
movapd 0x10(%rsp), %xmm1
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd 0xfb606(%rip), %xmm1    # 0x12b0f8
movapd %xmm1, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movsd 0xfb5d3(%rip), %xmm2    # 0x12b0d8
callq 0x27f00
xorl %edi, %edi
movl %ebx, %esi
callq 0x276d0
movsd 0x8(%rsp), %xmm0
movaps 0x10(%rsp), %xmm1
movsd 0xfb5b2(%rip), %xmm2    # 0x12b0d8
callq 0x27f00
callq 0x27ce0
movl $0xde1, %edi            # imm = 0xDE1
callq 0x27220
movl $0x1701, %edi           # imm = 0x1701
callq 0x27d40
callq 0x28270
movl $0x1700, %edi           # imm = 0x1700
callq 0x27d40
addq $0x30, %rsp
popq %rbx
jmp 0x28270
addq $0x30, %rsp
popq %rbx
retq