// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::GLFacePickColorBufferObject() const
unsigned int R3Mesh::
GLFacePickColorBufferObject(void) const
{
  // Check if nothing to be done
  if (NFaces() == 0) return 0;

  // Update pick color buffer
  if (vbo_face_pick_color_buffer == 0) {
    glGenBuffers(1, (GLuint *) &vbo_face_pick_color_buffer);
    if (vbo_face_pick_color_buffer > 0) {
      std::vector<GLubyte> pick_colors;
      for (int i = 0; i < NFaces(); i++) {
        for (int j = 0; j < 3; j++){
          unsigned char pick_color[4];
          EncodePickColor(i, 255, pick_color);
          pick_colors.push_back(pick_color[0]);
          pick_colors.push_back(pick_color[1]);
          pick_colors.push_back(pick_color[2]);
          pick_colors.push_back(pick_color[3]);
        }
      }
      glBindBuffer(GL_ARRAY_BUFFER, vbo_face_pick_color_buffer);
      glBufferData(GL_ARRAY_BUFFER, pick_colors.size() * sizeof(GLubyte), &pick_colors[0], GL_STATIC_DRAW);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
  }

  // Return pick color buffer identifier
  return vbo_face_pick_color_buffer;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movq 0x68(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x135a0
cmpl $0x0, %eax
jne 0x22c0a
movl $0x0, 0x74(%rsp)
jmp 0x22dba
movq 0x28(%rsp), %rax
cmpl $0x0, 0x60(%rax)
jne 0x22dae
movq 0x28(%rsp), %rsi
movq 0x14c383(%rip), %rax    # 0x16efa8
movq (%rax), %rax
addq $0x60, %rsi
movl $0x1, %edi
callq *%rax
movq 0x28(%rsp), %rax
cmpl $0x0, 0x60(%rax)
jbe 0x22dac
leaq 0x50(%rsp), %rdi
callq 0x38c70
movl $0x0, 0x4c(%rsp)
movq 0x28(%rsp), %rdi
movl 0x4c(%rsp), %eax
movl %eax, 0x20(%rsp)
callq 0x135a0
movl %eax, 0x24(%rsp)
jmp 0x22c6c
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jge 0x22d26
movl $0x0, 0x38(%rsp)
cmpl $0x3, 0x38(%rsp)
jge 0x22d14
movl 0x4c(%rsp), %edi
movl $0xff, %esi
leaq 0x34(%rsp), %rdx
callq 0xd0f00
jmp 0x22ca4
leaq 0x50(%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x38d80
jmp 0x22cb5
leaq 0x35(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x38d80
jmp 0x22cc6
leaq 0x36(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x38d80
jmp 0x22cd7
leaq 0x37(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x38d80
jmp 0x22ce8
jmp 0x22cea
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x22c84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x38d20
jmp 0x22dc3
jmp 0x22d16
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x22c54
movq 0x28(%rsp), %rcx
movq 0x14c28e(%rip), %rax    # 0x16efc0
movq (%rax), %rax
movl 0x60(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
jmp 0x22d41
movq 0x14c288(%rip), %rax    # 0x16efd0
movq (%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x50(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x38ce0
movq 0x8(%rsp), %rdi
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x38d00
movq 0x10(%rsp), %rsi
movq %rax, %rdx
movq 0x18(%rsp), %rax
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *%rax
jmp 0x22d8d
movq 0x14c22c(%rip), %rax    # 0x16efc0
movq (%rax), %rax
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *%rax
jmp 0x22da2
leaq 0x50(%rsp), %rdi
callq 0x38d20
jmp 0x22dae
movq 0x28(%rsp), %rax
movl 0x60(%rax), %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
movq 0x40(%rsp), %rdi
callq 0xf890
nopl (%rax)