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

  // Update texcoord buffer
  if (vbo_face_texcoord_buffer == 0) {
    glGenBuffers(1, (GLuint *) &vbo_face_texcoord_buffer);
    if (vbo_face_texcoord_buffer > 0) {
      std::vector<GLfloat> texcoords;
      for (int i = 0; i < NFaces(); i++) {
        R3MeshFace *face = Face(i);
        for (int j = 0; j < 3; j++){
          R3MeshVertex *vertex = VertexOnFace(face, j);
          const R2Point& texcoord = VertexTextureCoords(vertex);
          texcoords.push_back(texcoord.X());
          texcoords.push_back(texcoord.Y());
        }
      }
      glBindBuffer(GL_ARRAY_BUFFER, vbo_face_texcoord_buffer);
      glBufferData(GL_ARRAY_BUFFER, texcoords.size() * sizeof(GLfloat), &texcoords[0], GL_STATIC_DRAW);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
  }

  // Return texcoord buffer identifier
  return vbo_face_texcoord_buffer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
xorl %eax, %eax
cmpl $0x0, 0x34(%rdi)
je 0x18eb8
movq %rdi, %rbx
movl 0x58(%rdi), %eax
testl %eax, %eax
jne 0x18eb8
leaq 0x58(%rbx), %r14
movq 0xcc215(%rip), %rax     # 0xe4f88
movl $0x1, %edi
movq %r14, %rsi
callq *(%rax)
movl (%r14), %esi
movl $0x0, %eax
testl %esi, %esi
je 0x18eb8
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x34(%rbx)
jle 0x18e67
movq %r14, 0x28(%rsp)
xorl %r13d, %r13d
leaq 0x10(%rsp), %r15
leaq 0xc(%rsp), %r12
movq %rbx, 0x30(%rsp)
movq 0x28(%rbx), %rax
movq (%rax,%r13,8), %rbp
movl $0x1, %ebx
movq (%rbp,%rbx,8), %r14
xorps %xmm0, %xmm0
cvtsd2ss 0x48(%r14), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rax
cmpq %rax, %rsi
je 0x18dfe
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x18e13
movq %r15, %rdi
movq %r12, %rdx
callq 0x254f2
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rax
xorps %xmm0, %xmm0
cvtsd2ss 0x50(%r14), %xmm0
movss %xmm0, 0xc(%rsp)
cmpq %rax, %rsi
je 0x18e36
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x18e41
movq %r15, %rdi
movq %r12, %rdx
callq 0x254f2
incq %rbx
cmpq $0x4, %rbx
jne 0x18dcc
incq %r13
movq 0x30(%rsp), %rbx
movslq 0x34(%rbx), %rax
cmpq %rax, %r13
jl 0x18dbf
movq 0x28(%rsp), %r14
movl (%r14), %esi
movq 0xcc13a(%rip), %rbx     # 0xe4fa8
movl $0x8892, %edi           # imm = 0x8892
callq *(%rbx)
movq 0xcc144(%rip), %rax     # 0xe4fc0
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rsi
subq %rdx, %rsi
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *(%rax)
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *(%rbx)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18eb5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0xe450
movl (%r14), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x18ecb
jmp 0x18ecb
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18ee5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0xe450
movq %rbx, %rdi
callq 0xe7e0
nop