// File: /workspace/github_cpp_makefile_star2_O3/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 0x116a0
leaq 0xe0(%rsp), %rsi
movl $0xba7, %edi            # imm = 0xBA7
callq 0x116a0
leaq 0x30(%r12), %rdi
movq 0x30(%r12), %rax
movq %rdi, 0x60(%rsp)
callq *0xb0(%rax)
movl %ebx, 0x8(%rsp)
cmpl $0x2, %ebx
jne 0x1f420
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
movl 0x28(%r12), %ecx
cmpl %r14d, %ecx
jle 0x1f8c9
movl 0x2c(%r12), %eax
xorl %esi, %esi
leaq 0x80(%rsp), %r13
leaq 0xc0(%rsp), %rbx
cmpl %r14d, %eax
jle 0x1f8b5
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd %xmm0, 0x40(%rsp)
movq %rsi, 0x30(%rsp)
leal (%rsi,%r14), %eax
movl %eax, 0xc(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x38(%rsp)
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x4b600
leaq 0x68(%rsp), %rdi
callq 0x4b600
leaq 0x48(%rsp), %rdi
callq 0x4b600
leaq 0x98(%rsp), %rdi
callq 0x4b600
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
movq %rbx, %rdi
movsd 0x40(%rsp), %xmm0
movsd %xmm1, 0x28(%rsp)
callq 0x6f0d6
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x1643b
testl %eax, %eax
je 0x1f894
movq %rbx, %rdi
movsd 0x38(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
callq 0x6f0d6
movq %rbx, %rdi
leaq 0x68(%rsp), %rsi
movq %r12, %rdx
callq 0x1643b
testl %eax, %eax
je 0x1f894
leal (%r14,%r15), %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movq %rbx, %rdi
movsd 0x38(%rsp), %xmm0
movsd %xmm1, 0x28(%rsp)
callq 0x6f0d6
movq %rbx, %rdi
leaq 0x48(%rsp), %rsi
movq %r12, %rdx
callq 0x1643b
testl %eax, %eax
je 0x1f894
movq %rbx, %rdi
movsd 0x40(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
callq 0x6f0d6
movq %rbx, %rdi
leaq 0x98(%rsp), %rsi
movq %r12, %rdx
callq 0x1643b
testl %eax, %eax
je 0x1f894
movl %ebp, 0x28(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x68(%rsp), %rdx
leaq 0x48(%rsp), %rcx
callq 0x4a2ee
movsd 0x80(%rsp), %xmm0
movsd 0x88(%rsp), %xmm1
movsd 0x90(%rsp), %xmm2
movq %r13, %rbp
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x4c096
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %r13
callq 0x4c322
movsd 0x9ca76(%rip), %xmm1    # 0xbc050
ucomisd %xmm0, %xmm1
movapd 0x9bfaa(%rip), %xmm5    # 0xbb590
movapd 0x9ba62(%rip), %xmm6    # 0xbb050
movsd 0x9ca62(%rip), %xmm7    # 0xbc058
jbe 0x1f894
movsd 0x90(%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 0x58(%rsp), %xmm1
jbe 0x1f769
movapd %xmm3, %xmm4
subsd %xmm1, %xmm4
andpd %xmm5, %xmm4
xorpd %xmm6, %xmm3
divsd %xmm3, %xmm4
ucomisd %xmm4, %xmm7
jbe 0x1f769
movapd %xmm1, %xmm3
subsd %xmm0, %xmm3
andpd %xmm5, %xmm3
movapd %xmm1, %xmm4
xorpd %xmm6, %xmm4
divsd %xmm4, %xmm3
ucomisd %xmm3, %xmm7
jbe 0x1f769
movq %rbx, %rdi
callq 0x118c0
cmpl $0x1, 0x8(%rsp)
jne 0x1f71e
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq 0x30(%rsp), %rdx
movl %r15d, %ecx
callq 0x1d72e
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x118f0
movq %r13, %rdi
callq 0x11170
movq %rbp, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %ebp
movl %ebp, %edx
movl %r15d, %ecx
callq 0x1d72e
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x118f0
leaq 0x68(%rsp), %rdi
callq 0x11170
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movl %ebp, %edx
movl 0x28(%rsp), %ecx
callq 0x1d72e
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x118f0
jmp 0x1f730
movq %r13, %rdi
callq 0x11170
leaq 0x68(%rsp), %rdi
callq 0x11170
leaq 0x48(%rsp), %rdi
callq 0x11170
movsd 0x90(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movapd %xmm0, %xmm2
movapd 0x9b8fb(%rip), %xmm6    # 0xbb050
xorpd %xmm6, %xmm2
movapd 0x9be2f(%rip), %xmm5    # 0xbb590
movsd 0x9c8ef(%rip), %xmm7    # 0xbc058
movapd %xmm0, %xmm3
subsd %xmm1, %xmm3
andpd %xmm5, %xmm3
divsd %xmm2, %xmm3
ucomisd %xmm3, %xmm7
jbe 0x1f894
movsd 0xa8(%rsp), %xmm2
movapd %xmm1, %xmm3
subsd %xmm2, %xmm3
andpd %xmm5, %xmm3
xorpd %xmm6, %xmm1
divsd %xmm1, %xmm3
ucomisd %xmm3, %xmm7
jbe 0x1f894
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
andpd %xmm5, %xmm1
xorpd %xmm6, %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm7
jbe 0x1f894
movq %rbx, %rdi
callq 0x118c0
cmpl $0x1, 0x8(%rsp)
jne 0x1f875
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq 0x30(%rsp), %rdx
movl %r15d, %ecx
callq 0x1d72e
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x118f0
movq %r13, %rdi
callq 0x11170
movq %rbp, %rdi
movq %r12, %rsi
movl 0xc(%rsp), %edx
movl 0x28(%rsp), %ebp
movl %ebp, %ecx
callq 0x1d72e
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x118f0
leaq 0x48(%rsp), %rdi
callq 0x11170
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq 0x30(%rsp), %rdx
movl %ebp, %ecx
callq 0x1d72e
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
callq 0x118f0
jmp 0x1f887
movq %r13, %rdi
callq 0x11170
leaq 0x48(%rsp), %rdi
callq 0x11170
leaq 0x98(%rsp), %rdi
callq 0x11170
addl %r14d, %r15d
movl 0x2c(%r12), %eax
movl %eax, %ecx
subl %r14d, %ecx
cmpl %ecx, %r15d
jl 0x1f493
movl 0x28(%r12), %ecx
movl 0xc(%rsp), %edi
jmp 0x1f8ba
addl %r14d, %esi
movl %esi, %edi
movl %ecx, %edx
subl %r14d, %edx
movl %edi, %esi
cmpl %edx, %edi
jl 0x1f460
callq 0x117c0
cmpl $0x2, 0x8(%rsp)
jne 0x1f8e9
movl $0xb57, %edi            # imm = 0xB57
callq 0x11180
movl $0xb50, %edi            # imm = 0xB50
callq 0x11180
movq 0x60(%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