// File: /workspace/github_cpp_makefile_star2_O3/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 0x19ec5
movq 0xcb1a5(%rip), %r15     # 0xe4fa8
movl 0x50(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%r15)
movl $0x3, %edi
movl $0x1406, %esi           # imm = 0x1406
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe470
movl $0x8074, %edi           # imm = 0x8074
callq 0xe2c0
testb $0x20, %r14b
je 0x19e64
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x248(%rax)
testl %eax, %eax
je 0x19e64
movl 0x54(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%r15)
movl $0x1406, %edi           # imm = 0x1406
xorl %esi, %esi
xorl %edx, %edx
callq 0xe7c0
movl $0x8075, %edi           # imm = 0x8075
callq 0xe2c0
testb $0x30, %r14b
je 0x19ea2
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x250(%rax)
testl %eax, %eax
je 0x19ea2
movl 0x58(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%r15)
movl $0x2, %edi
movl $0x1406, %esi           # imm = 0x1406
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe8e0
movl $0x8078, %edi           # imm = 0x8078
callq 0xe2c0
btl $0xe, %r14d
jb 0x19ecb
btl $0xa, %r14d
jae 0x19f03
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x258(%rax)
testl %eax, %eax
je 0x19f03
movl 0x5c(%rbx), %esi
jmp 0x19ede
popq %rbx
popq %r14
popq %r15
retq
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x260(%rax)
testl %eax, %eax
je 0x19f03
movl 0x60(%rbx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%r15)
movl $0x4, %edi
movl $0x1401, %esi           # imm = 0x1401
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe460
movl $0x8076, %edi           # imm = 0x8076
callq 0xe2c0
movl 0x34(%rbx), %eax
leal (%rax,%rax,2), %edx
movl $0x4, %edi
xorl %esi, %esi
callq 0xe060
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *(%r15)
movl $0x8074, %edi           # imm = 0x8074
callq 0xe2a0
movl $0x8075, %edi           # imm = 0x8075
callq 0xe2a0
movl $0x8078, %edi           # imm = 0x8078
callq 0xe2a0
movl $0x8076, %edi           # imm = 0x8076
popq %rbx
popq %r14
popq %r15
jmp 0xe2a0