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

  // Update normal buffer
  if (vbo_normal_buffer == 0) {
    glGenBuffers(1, (GLuint *) &vbo_normal_buffer);
    if (vbo_normal_buffer > 0) {
      std::vector<GLfloat> normals;
      for (int i = 0; i < NPoints(); i++) {
        const R3Vector& normal = PointNormal(i);
        normals.push_back(normal.X());
        normals.push_back(normal.Y());
        normals.push_back(normal.Z());
      }
      glBindBuffer(GL_ARRAY_BUFFER, vbo_normal_buffer);
      glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(GLfloat), &normals[0], GL_STATIC_DRAW);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
  }

  // Return buffer object identifier
  return vbo_normal_buffer;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq 0x98(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x32400
cmpl $0x0, %eax
jne 0xddb36
movl $0x0, 0xa4(%rsp)
jmp 0xddd4e
movq 0x48(%rsp), %rax
cmpl $0x0, 0x10c(%rax)
jne 0xddd3c
movq 0x48(%rsp), %rsi
movq 0x14b454(%rip), %rax    # 0x228fa8
movq (%rax), %rax
addq $0x10c, %rsi            # imm = 0x10C
movl $0x1, %edi
callq *%rax
movq 0x48(%rsp), %rax
cmpl $0x0, 0x10c(%rax)
jbe 0xddd3a
leaq 0x80(%rsp), %rdi
callq 0xaf8f0
movl $0x0, 0x7c(%rsp)
movq 0x48(%rsp), %rdi
movl 0x7c(%rsp), %eax
movl %eax, 0x40(%rsp)
callq 0x32400
movl %eax, 0x44(%rsp)
jmp 0xddba4
movl 0x40(%rsp), %eax
movl 0x44(%rsp), %ecx
cmpl %ecx, %eax
jge 0xddca7
movq 0x48(%rsp), %rdi
movl 0x7c(%rsp), %esi
callq 0xe01e0
movq %rax, 0x38(%rsp)
jmp 0xddbc9
movq 0x38(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x36d00
movsd %xmm0, 0x30(%rsp)
jmp 0xddbe5
movsd 0x30(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x5c(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x5c(%rsp), %rsi
callq 0xaf900
jmp 0xddc09
movq 0x60(%rsp), %rdi
callq 0x36d10
movsd %xmm0, 0x28(%rsp)
jmp 0xddc1b
movsd 0x28(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x58(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xaf900
jmp 0xddc3f
movq 0x60(%rsp), %rdi
callq 0x36d20
movsd %xmm0, 0x20(%rsp)
jmp 0xddc51
movsd 0x20(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x54(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x54(%rsp), %rsi
callq 0xaf900
jmp 0xddc75
jmp 0xddc77
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0xddb8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x80(%rsp), %rdi
callq 0xaf970
jmp 0xddd5d
movq 0x48(%rsp), %rcx
movq 0x14b315(%rip), %rax    # 0x228fc8
movq (%rax), %rax
movl 0x10c(%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
jmp 0xddcc5
movq 0x14b30c(%rip), %rax    # 0x228fd8
movq (%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x80(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xaf930
movq 0x8(%rsp), %rdi
shlq $0x2, %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0xaf950
movq 0x10(%rsp), %rsi
movq %rax, %rdx
movq 0x18(%rsp), %rax
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *%rax
jmp 0xddd18
movq 0x14b2a9(%rip), %rax    # 0x228fc8
movq (%rax), %rax
movl $0x8892, %edi           # imm = 0x8892
xorl %esi, %esi
callq *%rax
jmp 0xddd2d
leaq 0x80(%rsp), %rdi
callq 0xaf970
jmp 0xddd3c
movq 0x48(%rsp), %rax
movl 0x10c(%rax), %eax
movl %eax, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
addq $0xa8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x24250
nopw (%rax,%rax)