// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::DrawQuads(int, int) const
void RGBDImage::
DrawQuads(int color_scheme, int skip) const
{
  // Get info about current view
  GLint viewport[4];
  GLdouble modelview_matrix[16];
  GLdouble projection_matrix[16];
  glGetIntegerv(GL_VIEWPORT, viewport);
  glGetDoublev(GL_MODELVIEW_MATRIX, modelview_matrix);
  glGetDoublev(GL_PROJECTION_MATRIX, projection_matrix);

  // Push transformation
  CameraToWorld().Push();

  // Enable lighting and material
  if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_LIGHTING);
  }

  // Draw color
  LoadColor(color_scheme);

  // Draw quads
  RNGrfxBegin(RN_GRFX_TRIANGLES);
  for (int ix = 0; ix < NPixels(RN_X)-skip; ix += skip) {
    for (int iy = 0; iy < NPixels(RN_Y)-skip; iy += skip) {
      R3Point p1, p2, p3, p4;
      if (!RGBDTransformImageToCamera(R2Point(ix, iy), p1, this)) continue;
      if (!RGBDTransformImageToCamera(R2Point(ix+skip, iy), p2, this)) continue;
      if (!RGBDTransformImageToCamera(R2Point(ix+skip, iy+skip), p3, this)) continue;
      if (!RGBDTransformImageToCamera(R2Point(ix, iy+skip), p4, this)) continue;
      R3Plane plane(p1, p2, p3);
      RNScalar dot = plane.Normal().Dot(p1.Vector());
      if (dot < -0.5) {
        if ((fabs(p1.Z() - p2.Z())/-p1.Z() < 0.05) &&
            (fabs(p2.Z() - p3.Z())/-p2.Z() < 0.05) &&
            (fabs(p3.Z() - p1.Z())/-p3.Z() < 0.05)) {
          R3LoadNormal(plane.Normal());
          if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) RNLoadRgb(PixelColor(ix, iy));
          R3LoadPoint(p1);
          if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) RNLoadRgb(PixelColor(ix+skip, iy));
          R3LoadPoint(p2);
          if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) RNLoadRgb(PixelColor(ix+skip, iy+skip));
          R3LoadPoint(p3);
        }
        if ((fabs(p1.Z() - p3.Z())/-p1.Z() < 0.05) &&
            (fabs(p3.Z() - p4.Z())/-p3.Z() < 0.05) &&
            (fabs(p4.Z() - p1.Z())/-p4.Z() < 0.05)) {
          R3LoadNormal(plane.Normal());
          if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) RNLoadRgb(PixelColor(ix, iy));
          R3LoadPoint(p1);
          if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) RNLoadRgb(PixelColor(ix+skip, iy+skip));
          R3LoadPoint(p3);
          if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) RNLoadRgb(PixelColor(ix, iy+skip));
          R3LoadPoint(p4);
        }
      }
    }
  }
  RNGrfxEnd();

  // Disable lighting and material
  if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    glDisable(GL_COLOR_MATERIAL);
    glDisable(GL_LIGHTING);
  }

  // Pop transformation
  CameraToWorld().Pop();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movl %edx, %r14d
movl %esi, %ebx
movq %rdi, %r12
leaq 0xb0(%rsp), %rsi
movl $0xba2, %edi            # imm = 0xBA2
callq 0x11570
leaq 0x160(%rsp), %rsi
movl $0xba6, %edi            # imm = 0xBA6
callq 0x116b0
leaq 0xe0(%rsp), %rsi
movl $0xba7, %edi            # imm = 0xBA7
callq 0x116b0
leaq 0x30(%r12), %rdi
movq 0x30(%r12), %rax
movq %rdi, 0x48(%rsp)
callq *0xb0(%rax)
movl %ebx, 0x8(%rsp)
cmpl $0x2, %ebx
jne 0x1dd02
movl $0xb57, %edi            # imm = 0xB57
callq 0x11550
movl $0x408, %edi            # imm = 0x408
movl $0x1602, %esi           # imm = 0x1602
callq 0x113b0
movl $0xb50, %edi            # imm = 0xB50
callq 0x11550
movq (%r12), %rax
movq %r12, %rdi
movl 0x8(%rsp), %esi
callq *0xf0(%rax)
pushq $0x4
popq %rdi
callq 0x11150
xorl %ecx, %ecx
leaq 0x98(%rsp), %r13
leaq 0xc0(%rsp), %rbp
movl 0x28(%r12), %eax
subl %r14d, %eax
cmpl %eax, %ecx
jge 0x1e0fc
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x28(%rsp)
movq %rcx, 0x18(%rsp)
leal (%rcx,%r14), %eax
movl %eax, 0xc(%rsp)
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%rsp)
xorl %ebx, %ebx
movl 0x2c(%r12), %eax
subl %r14d, %eax
cmpl %eax, %ebx
jge 0x1e0f1
movq %r13, %rdi
callq 0x45d4a
leaq 0x68(%rsp), %rdi
callq 0x45d4a
leaq 0x30(%rsp), %rdi
callq 0x45d4a
leaq 0x80(%rsp), %rdi
callq 0x45d4a
cvtsi2sd %ebx, %xmm1
movq %rbp, %rdi
movsd 0x28(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
callq 0x66640
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x15cb3
testl %eax, %eax
je 0x1e0e9
movq %rbp, %rdi
movsd 0x20(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x66640
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
movq %r12, %rdx
callq 0x15cb3
testl %eax, %eax
je 0x1e0e9
leal (%r14,%rbx), %r15d
cvtsi2sd %r15d, %xmm1
movq %rbp, %rdi
movsd 0x20(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
callq 0x66640
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
callq 0x15cb3
testl %eax, %eax
je 0x1e0e9
movq %rbp, %rdi
movsd 0x28(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x66640
movq %rbp, %rdi
leaq 0x80(%rsp), %rsi
movq %r12, %rdx
callq 0x15cb3
testl %eax, %eax
je 0x1e0e9
movl %r15d, 0x10(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x68(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq 0x44b18
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x1faf0
movq %rbp, %rdi
movq %r15, %rsi
callq 0x46786
movsd 0x8b13c(%rip), %xmm1    # 0xa8fd0
ucomisd %xmm0, %xmm1
movapd 0x8a670(%rip), %xmm5    # 0xa8510
movapd 0x8a1a8(%rip), %xmm6    # 0xa8050
movsd 0x8b128(%rip), %xmm7    # 0xa8fd8
jbe 0x1e0e9
movsd 0xa8(%rsp), %xmm0
movsd 0x78(%rsp), %xmm3
movapd %xmm0, %xmm1
subsd %xmm3, %xmm1
andpd %xmm5, %xmm1
movapd %xmm0, %xmm2
xorpd %xmm6, %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm7
movsd 0x40(%rsp), %xmm1
jbe 0x1dff0
movapd %xmm3, %xmm4
subsd %xmm1, %xmm4
andpd %xmm5, %xmm4
xorpd %xmm6, %xmm3
divsd %xmm3, %xmm4
ucomisd %xmm4, %xmm7
jbe 0x1dff0
movapd %xmm1, %xmm3
subsd %xmm0, %xmm3
andpd %xmm5, %xmm3
movapd %xmm1, %xmm4
xorpd %xmm6, %xmm4
divsd %xmm4, %xmm3
ucomisd %xmm3, %xmm7
jbe 0x1dff0
movq %rbp, %rdi
callq 0x118e0
cmpl $0x1, 0x8(%rsp)
jne 0x1df7e
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl %ebx, %ecx
callq 0x1c31e
movq %r15, %rdi
callq 0x1b8bb
movq %r13, %rdi
callq 0x11170
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl %ebx, %ecx
callq 0x1c31e
movq %r15, %rdi
callq 0x1b8bb
jmp 0x1df86
movq %r13, %rdi
callq 0x11170
leaq 0x68(%rsp), %rdi
callq 0x11170
cmpl $0x1, 0x8(%rsp)
jne 0x1dfb7
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x10(%rsp), %ecx
callq 0x1c31e
movq %r15, %rdi
callq 0x1b8bb
leaq 0x30(%rsp), %rdi
callq 0x11170
movsd 0xa8(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movapd %xmm0, %xmm2
movapd 0x8a074(%rip), %xmm6    # 0xa8050
xorpd %xmm6, %xmm2
movapd 0x8a528(%rip), %xmm5    # 0xa8510
movsd 0x8afe8(%rip), %xmm7    # 0xa8fd8
movapd %xmm0, %xmm3
subsd %xmm1, %xmm3
andpd %xmm5, %xmm3
divsd %xmm2, %xmm3
ucomisd %xmm3, %xmm7
jbe 0x1e0e9
movsd 0x90(%rsp), %xmm2
movapd %xmm1, %xmm3
subsd %xmm2, %xmm3
andpd %xmm5, %xmm3
xorpd %xmm6, %xmm1
divsd %xmm1, %xmm3
ucomisd %xmm3, %xmm7
jbe 0x1e0e9
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
andpd %xmm5, %xmm1
xorpd %xmm6, %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm7
jbe 0x1e0e9
movq %rbp, %rdi
callq 0x118e0
cmpl $0x1, 0x8(%rsp)
jne 0x1e0a2
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl %ebx, %ecx
callq 0x1c31e
movq %r15, %rdi
callq 0x1b8bb
movq %r13, %rdi
callq 0x11170
movq %r15, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x10(%rsp), %ecx
callq 0x1c31e
movq %r15, %rdi
callq 0x1b8bb
jmp 0x1e0aa
movq %r13, %rdi
callq 0x11170
leaq 0x30(%rsp), %rdi
callq 0x11170
cmpl $0x1, 0x8(%rsp)
jne 0x1e0dc
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0x10(%rsp), %ecx
callq 0x1c31e
movq %r15, %rdi
callq 0x1b8bb
leaq 0x80(%rsp), %rdi
callq 0x11170
addl %r14d, %ebx
jmp 0x1dd60
movl 0xc(%rsp), %eax
movl %eax, %ecx
jmp 0x1dd2d
callq 0x117d0
cmpl $0x2, 0x8(%rsp)
jne 0x1e11c
movl $0xb57, %edi            # imm = 0xB57
callq 0x111a0
movl $0xb50, %edi            # imm = 0xB50
callq 0x111a0
movq 0x48(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq