// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::DrawFaces(gaps::RNFlags) const
void R3Mesh::
DrawFaces(const R3DrawFlags draw_flags) const
{
  // Bind face position buffer
  if (GLFacePositionBufferObject() <= 0) return;
  glBindBuffer(GL_ARRAY_BUFFER, vbo_face_position_buffer);
  glVertexPointer(3, GL_FLOAT, 0, 0);
  glEnableClientState(GL_VERTEX_ARRAY);
  
  // Bind face normal buffer
  if (draw_flags & R3_SURFACE_NORMALS_DRAW_FLAG) {  
    if (GLFaceNormalBufferObject() > 0) {
      glBindBuffer(GL_ARRAY_BUFFER, vbo_face_normal_buffer);
      glNormalPointer(GL_FLOAT, 0, 0);
      glEnableClientState(GL_NORMAL_ARRAY);
    }
  }
  
  // Bind face texcoord buffer
  if (draw_flags & R3_SURFACE_TEXTURE_DRAW_FLAG) {  
    if (GLFaceTextureCoordBufferObject() > 0) {
      glBindBuffer(GL_ARRAY_BUFFER, vbo_face_texcoord_buffer);
      glTexCoordPointer(2, GL_FLOAT, 0, 0);
      glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    }
  }
  
  // Bind face color buffer
  if (draw_flags[R3_SURFACE_PICK_DRAW_FLAG]) {
    if (GLFacePickColorBufferObject() > 0) {
      glBindBuffer(GL_ARRAY_BUFFER, vbo_face_pick_color_buffer);
      glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
      glEnableClientState(GL_COLOR_ARRAY);
    }
  }
  else if (draw_flags[R3_VERTEX_COLORS_DRAW_FLAG]) {
    if (GLFaceRgbColorBufferObject() > 0) {
      glBindBuffer(GL_ARRAY_BUFFER, vbo_face_rgb_color_buffer);
      glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
      glEnableClientState(GL_COLOR_ARRAY);
    }
  }
  
  // Draw vertices
  glDrawArrays(GL_TRIANGLES, 0, 3 * NFaces());

  // Reset everything
  glBindBuffer(GL_ARRAY_BUFFER, 0);
  glDisableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x240(%rax)
testl %eax, %eax
je 0x18363
movq 0xc1d0b(%rip), %r15     # 0xd9fb0
movl 0x50(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%r15)
pushq $0x3
popq %rdi
movl $0x1406, %esi           # imm = 0x1406
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe490
movl $0x8074, %edi           # imm = 0x8074
callq 0xe2d0
testb $0x20, %r14b
je 0x18304
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x248(%rax)
testl %eax, %eax
je 0x18304
movl 0x54(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%r15)
movl $0x1406, %edi           # imm = 0x1406
xorl %esi, %esi
xorl %edx, %edx
callq 0xe7f0
movl $0x8075, %edi           # imm = 0x8075
callq 0xe2d0
testb $0x30, %r14b
je 0x18340
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x250(%rax)
testl %eax, %eax
je 0x18340
movl 0x58(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%r15)
pushq $0x2
popq %rdi
movl $0x1406, %esi           # imm = 0x1406
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe910
movl $0x8078, %edi           # imm = 0x8078
callq 0xe2d0
btl $0xe, %r14d
jb 0x18369
btl $0xa, %r14d
jae 0x1839f
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x258(%rax)
testl %eax, %eax
je 0x1839f
movl 0x5c(%rbx), %esi
jmp 0x1837c
popq %rbx
popq %r14
popq %r15
retq
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x260(%rax)
testl %eax, %eax
je 0x1839f
movl 0x60(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%r15)
pushq $0x4
popq %rdi
movl $0x1401, %esi           # imm = 0x1401
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe470
movl $0x8076, %edi           # imm = 0x8076
callq 0xe2d0
imull $0x3, 0x34(%rbx), %edx
pushq $0x4
popq %rdi
xorl %esi, %esi
callq 0xe060
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *(%r15)
movl $0x8074, %edi           # imm = 0x8074
callq 0xe2b0
movl $0x8075, %edi           # imm = 0x8075
callq 0xe2b0
movl $0x8078, %edi           # imm = 0x8078
callq 0xe2b0
movl $0x8076, %edi           # imm = 0x8076
popq %rbx
popq %r14
popq %r15
jmp 0xe2b0