// File: /workspace/github_cpp_makefile_star2_O1/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, 0x78(%rsp)
callq *0xb0(%rax)
movl %ebx, 0x8(%rsp)
cmpl $0x2, %ebx
jne 0x1f6c0
movl $0xb57, %edi            # imm = 0xB57
callq 0x11540
movl $0x408, %edi            # imm = 0x408
movl $0x1602, %esi           # imm = 0x1602
callq 0x113b0
movl $0xb50, %edi            # imm = 0xB50
callq 0x11540
movq (%r12), %rax
movq %r12, %rdi
movl 0x8(%rsp), %esi
callq *0xf0(%rax)
movl $0x4, %edi
callq 0x11150
cmpl %r14d, 0x28(%r12)
jle 0x1fb4b
movq $0x0, 0x28(%rsp)
leaq 0x38(%rsp), %rbp
leaq 0xc0(%rsp), %r13
cmpl %r14d, 0x2c(%r12)
jle 0x1fb2e
movq 0x28(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x58(%rsp)
addl %r14d, %eax
movl %eax, 0xc(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x50(%rsp)
xorl %ebx, %ebx
movq %rbp, %rdi
callq 0x4be44
leaq 0x80(%rsp), %rdi
callq 0x4be44
leaq 0x60(%rsp), %rdi
callq 0x4be44
leaq 0x98(%rsp), %rdi
callq 0x4be44
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movq %r13, %rdi
movsd 0x58(%rsp), %xmm0
movsd %xmm1, 0x30(%rsp)
callq 0x6fee6
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x16507
testl %eax, %eax
je 0x1fb1b
movq %r13, %rdi
movsd 0x50(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
callq 0x6fee6
movq %r13, %rdi
leaq 0x80(%rsp), %rsi
movq %r12, %rdx
callq 0x16507
testl %eax, %eax
je 0x1fb1b
leal (%r14,%rbx), %r15d
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
movq %r13, %rdi
movsd 0x50(%rsp), %xmm0
movsd %xmm1, 0x30(%rsp)
callq 0x6fee6
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
movq %r12, %rdx
callq 0x16507
testl %eax, %eax
je 0x1fb1b
movq %r13, %rdi
movsd 0x58(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
callq 0x6fee6
movq %r13, %rdi
leaq 0x98(%rsp), %rsi
movq %r12, %rdx
callq 0x16507
testl %eax, %eax
je 0x1fb1b
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x80(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0x4ab32
movsd 0x38(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x4c8de
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4cb76
movsd 0x9e7e4(%rip), %xmm1    # 0xbe050
ucomisd %xmm0, %xmm1
movapd 0x9dd18(%rip), %xmm4    # 0xbd590
movapd 0x9d7d0(%rip), %xmm5    # 0xbd050
movsd 0x9e7d0(%rip), %xmm6    # 0xbe058
jbe 0x1fb16
movsd 0x48(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
andpd %xmm4, %xmm2
movapd %xmm0, %xmm3
xorpd %xmm5, %xmm3
divsd %xmm3, %xmm2
ucomisd %xmm2, %xmm6
jbe 0x1f9dd
movsd 0x70(%rsp), %xmm2
movapd %xmm1, %xmm3
subsd %xmm2, %xmm3
andpd %xmm4, %xmm3
xorpd %xmm5, %xmm1
divsd %xmm1, %xmm3
ucomisd %xmm3, %xmm6
jbe 0x1f9dd
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
andpd %xmm4, %xmm1
xorpd %xmm5, %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm6
jbe 0x1f9dd
movq %r13, %rdi
callq 0x118d0
cmpl $0x1, 0x8(%rsp)
jne 0x1f972
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq 0x28(%rsp), %rdx
movl %ebx, %ecx
callq 0x1d9d8
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x11900
leaq 0x38(%rsp), %rdi
callq 0x11170
movq %rbp, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl %ebx, %ecx
callq 0x1d9d8
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x11900
jmp 0x1f97c
leaq 0x38(%rsp), %rdi
callq 0x11170
leaq 0x80(%rsp), %rdi
callq 0x11170
cmpl $0x1, 0x8(%rsp)
jne 0x1f9bb
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl %r15d, %ecx
callq 0x1d9d8
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x11900
leaq 0x60(%rsp), %rdi
callq 0x11170
movapd 0x9dbc3(%rip), %xmm4    # 0xbd590
movapd 0x9d67b(%rip), %xmm5    # 0xbd050
movsd 0x9e67b(%rip), %xmm6    # 0xbe058
movsd 0x48(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
andpd %xmm4, %xmm2
movapd %xmm0, %xmm3
xorpd %xmm5, %xmm3
divsd %xmm3, %xmm2
ucomisd %xmm2, %xmm6
jbe 0x1fb16
movsd 0xa8(%rsp), %xmm2
movapd %xmm1, %xmm3
subsd %xmm2, %xmm3
andpd %xmm4, %xmm3
xorpd %xmm5, %xmm1
divsd %xmm1, %xmm3
ucomisd %xmm3, %xmm6
jbe 0x1fb16
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
andpd %xmm4, %xmm1
xorpd %xmm5, %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm6
jbe 0x1fb16
movq %r13, %rdi
callq 0x118d0
cmpl $0x1, 0x8(%rsp)
jne 0x1fac2
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq 0x28(%rsp), %rdx
movl %ebx, %ecx
callq 0x1d9d8
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x11900
leaq 0x38(%rsp), %rdi
callq 0x11170
movq %rbp, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl %r15d, %ecx
callq 0x1d9d8
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x11900
jmp 0x1facc
leaq 0x38(%rsp), %rdi
callq 0x11170
leaq 0x60(%rsp), %rdi
callq 0x11170
cmpl $0x1, 0x8(%rsp)
jne 0x1fb09
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq 0x28(%rsp), %rdx
movl %r15d, %ecx
callq 0x1d9d8
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x11900
leaq 0x98(%rsp), %rdi
callq 0x11170
leaq 0x38(%rsp), %rbp
addl %r14d, %ebx
movl 0x2c(%r12), %eax
subl %r14d, %eax
cmpl %eax, %ebx
jl 0x1f72f
movq 0x28(%rsp), %rcx
addl %r14d, %ecx
movl 0x28(%r12), %eax
subl %r14d, %eax
movq %rcx, 0x28(%rsp)
cmpl %eax, %ecx
jl 0x1f6fc
callq 0x117d0
cmpl $0x2, 0x8(%rsp)
jne 0x1fb6b
movl $0xb57, %edi            # imm = 0xB57
callq 0x11180
movl $0xb50, %edi            # imm = 0xB50
callq 0x11180
movq 0x78(%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
nop