// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Mesh.cpp
// Function: gaps::R3Mesh::GLFacePositionBufferObject() const
unsigned int R3Mesh::
GLFacePositionBufferObject(void) const
{
  // Check if nothing to be done
  if (NFaces() == 0) return 0;
  
  // Update position buffer
  if (vbo_face_position_buffer == 0) {
    glGenBuffers(1, (GLuint *) &vbo_face_position_buffer);
    if (vbo_face_position_buffer > 0) {
      std::vector<GLfloat> positions;
      for (int i = 0; i < NFaces(); i++) {
        R3MeshFace *face = Face(i);
        for (int j = 0; j < 3; j++){
          R3MeshVertex *vertex = VertexOnFace(face, j);
          const R3Point& position = VertexPosition(vertex);
          positions.push_back(position.X());
          positions.push_back(position.Y());
          positions.push_back(position.Z());
        }
      }
      glBindBuffer(GL_ARRAY_BUFFER, vbo_face_position_buffer);
      glBufferData(GL_ARRAY_BUFFER, positions.size() * sizeof(GLfloat), &positions[0], GL_STATIC_DRAW);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
  }

  // Return position buffer identifier
  return vbo_face_position_buffer;
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x135a0
cmpl $0x0, %eax
jne 0x22096
movl $0x0, 0xc4(%rsp)
jmp 0x22321
movq 0x50(%rsp), %rax
cmpl $0x0, 0x50(%rax)
jne 0x22312
movq 0x50(%rsp), %rsi
movq 0x14cef7(%rip), %rax    # 0x16efa8
movq (%rax), %rax
addq $0x50, %rsi
movl $0x1, %edi
callq *%rax
movq 0x50(%rsp), %rax
cmpl $0x0, 0x50(%rax)
jbe 0x22310
leaq 0xa0(%rsp), %rdi
callq 0x38b40
movl $0x0, 0x9c(%rsp)
movq 0x50(%rsp), %rdi
movl 0x9c(%rsp), %eax
movl %eax, 0x48(%rsp)
callq 0x135a0
movl %eax, 0x4c(%rsp)
jmp 0x22101
movl 0x48(%rsp), %eax
movl 0x4c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x22282
movq 0x50(%rsp), %rdi
movl 0x9c(%rsp), %esi
callq 0x136d0
movq %rax, 0x40(%rsp)
jmp 0x22129
movq 0x40(%rsp), %rax
movq %rax, 0x80(%rsp)
movl $0x0, 0x7c(%rsp)
cmpl $0x3, 0x7c(%rsp)
jge 0x2226a
movq 0x50(%rsp), %rdi
movq 0x80(%rsp), %rsi
movl 0x7c(%rsp), %edx
callq 0x13700
movq %rax, 0x38(%rsp)
jmp 0x22166
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rsi
callq 0x13660
movq %rax, 0x30(%rsp)
jmp 0x22186
movq 0x30(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x37820
movsd %xmm0, 0x28(%rsp)
jmp 0x221a2
movsd 0x28(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x64(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x64(%rsp), %rsi
callq 0x38b50
jmp 0x221c6
movq 0x68(%rsp), %rdi
callq 0x37870
movsd %xmm0, 0x20(%rsp)
jmp 0x221d8
movsd 0x20(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x60(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x38b50
jmp 0x221fc
movq 0x68(%rsp), %rdi
callq 0x378c0
movsd %xmm0, 0x18(%rsp)
jmp 0x2220e
movsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x5c(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x5c(%rsp), %rsi
callq 0x38b50
jmp 0x22232
jmp 0x22234
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x2213e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x38bc0
jmp 0x22330
jmp 0x2226c
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x220e6
movq 0x50(%rsp), %rcx
movq 0x14cd32(%rip), %rax    # 0x16efc0
movq (%rax), %rax
movl 0x50(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
jmp 0x2229d
movq 0x14cd2c(%rip), %rax    # 0x16efd0
movq (%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0xa0(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x38b80
movq (%rsp), %rdi
shlq $0x2, %rax
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x38ba0
movq 0x8(%rsp), %rsi
movq %rax, %rdx
movq 0x10(%rsp), %rax
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *%rax
jmp 0x222ee
movq 0x14cccb(%rip), %rax    # 0x16efc0
movq (%rax), %rax
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *%rax
jmp 0x22303
leaq 0xa0(%rsp), %rdi
callq 0x38bc0
jmp 0x22312
movq 0x50(%rsp), %rax
movl 0x50(%rax), %eax
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
addq $0xc8, %rsp
retq
movq 0x90(%rsp), %rdi
callq 0xf890
nopl (%rax)