// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::UpdateVBO()
void R3SurfelViewer::
UpdateVBO(void)
{
#if (R3_SURFEL_VIEWER_DRAW_METHOD == R3_SURFEL_VIEWER_DRAW_WITH_VBO)
  // Check if VBO is uptodate
  if (vbo_nsurfels > 0) return;

  // Compute VBO buffers
  std::vector<GLfloat> surfel_positions;
  std::vector<GLfloat> surfel_normals;
  std::vector<GLubyte> surfel_colors;
  ComputeVBOBuffers(surfel_positions, surfel_normals, surfel_colors);

  // Get/check number of surfels
  vbo_nsurfels = surfel_positions.size() / 3;
  if (vbo_nsurfels <= 0) return;
  assert(surfel_positions.size() == 3 * vbo_nsurfels);
  assert(surfel_normals.size() == 3 * vbo_nsurfels);
  assert(surfel_colors.size() == 2 * 3 * vbo_nsurfels);

  // Generate VBO buffers (first time only)
  if (vbo_position_buffer == 0) glGenBuffers(1, &vbo_position_buffer);
  if (vbo_normal_buffer == 0) glGenBuffers(1, &vbo_normal_buffer);
  if (vbo_color_buffer == 0) glGenBuffers(1, &vbo_color_buffer);

  // Load VBO buffers
  if (vbo_position_buffer) {
    glBindBuffer(GL_ARRAY_BUFFER, vbo_position_buffer);
    glBufferData(GL_ARRAY_BUFFER, 3 * vbo_nsurfels * sizeof(GLfloat), &surfel_positions[0], GL_STATIC_DRAW);
    glVertexPointer(3, GL_FLOAT, 0, 0);
  }
  if (vbo_normal_buffer) {
    glBindBuffer(GL_ARRAY_BUFFER, vbo_normal_buffer);
    glBufferData(GL_ARRAY_BUFFER, 3 * vbo_nsurfels * sizeof(GLfloat), &surfel_normals[0], GL_STATIC_DRAW);
    glNormalPointer(GL_FLOAT, 0, 0);
  }
  if (vbo_color_buffer) {
    glBindBuffer(GL_ARRAY_BUFFER, vbo_color_buffer);
    glBufferData(GL_ARRAY_BUFFER, 2 * 3 * vbo_nsurfels * sizeof(GLubyte), &surfel_colors[0], GL_STATIC_DRAW);
    glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
   }
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x58, %rsp
cmpl $0x0, 0x604(%rdi)
jne 0x32366
movq %rdi, %rbx
xorps %xmm0, %xmm0
movq %rsp, %rsi
andq $0x0, 0x10(%rsi)
leaq 0x40(%rsp), %rdx
andq $0x0, 0x10(%rdx)
movaps %xmm0, (%rsi)
movaps %xmm0, (%rdx)
leaq 0x20(%rsp), %rcx
movaps %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
movq (%rdi), %rax
callq *0x348(%rax)
movq 0x8(%rsp), %rax
subq (%rsp), %rax
sarq $0x2, %rax
pushq $0x3
popq %rcx
xorl %edx, %edx
divq %rcx
movl %eax, 0x604(%rbx)
testl %eax, %eax
je 0x3234a
leaq 0x5f8(%rbx), %r12
cmpl $0x0, 0x5f8(%rbx)
jne 0x32238
movq 0x174d00(%rip), %rax    # 0x1a6f30
pushq $0x1
popq %rdi
movq %r12, %rsi
callq *(%rax)
leaq 0x5fc(%rbx), %r15
cmpl $0x0, 0x5fc(%rbx)
jne 0x32257
movq 0x174ce1(%rip), %rax    # 0x1a6f30
pushq $0x1
popq %rdi
movq %r15, %rsi
callq *(%rax)
leaq 0x600(%rbx), %r14
cmpl $0x0, 0x600(%rbx)
jne 0x32276
movq 0x174cc2(%rip), %rax    # 0x1a6f30
pushq $0x1
popq %rdi
movq %r14, %rsi
callq *(%rax)
movl (%r12), %esi
testl %esi, %esi
je 0x322bf
movq 0x174cfb(%rip), %rax    # 0x1a6f80
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x174d0d(%rip), %rax    # 0x1a6fa0
imull $0x3, 0x604(%rbx), %esi
shlq $0x2, %rsi
movq (%rsp), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *(%rax)
pushq $0x3
popq %rdi
movl $0x1406, %esi           # imm = 0x1406
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x27990
movl (%r15), %esi
testl %esi, %esi
je 0x32305
movq 0x174cb3(%rip), %rax    # 0x1a6f80
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x174cc5(%rip), %rax    # 0x1a6fa0
imull $0x3, 0x604(%rbx), %esi
shlq $0x2, %rsi
movq 0x40(%rsp), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *(%rax)
movl $0x1406, %edi           # imm = 0x1406
xorl %esi, %esi
xorl %edx, %edx
callq 0x280c0
movl (%r14), %esi
testl %esi, %esi
je 0x3234a
movq 0x174c6d(%rip), %rax    # 0x1a6f80
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x174c7f(%rip), %rax    # 0x1a6fa0
imull $0x6, 0x604(%rbx), %esi
movq 0x20(%rsp), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *(%rax)
pushq $0x3
popq %rdi
movl $0x1401, %esi           # imm = 0x1401
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x27960
leaq 0x20(%rsp), %rdi
callq 0x33796
leaq 0x40(%rsp), %rdi
callq 0x33778
movq %rsp, %rdi
callq 0x33778
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x33796
leaq 0x40(%rsp), %rdi
callq 0x33778
movq %rsp, %rdi
callq 0x33778
movq %rbx, %rdi
callq 0x28140
nop