// File: /workspace/github_cpp_makefile_star2_O1/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 0x33f4c
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rsi
movaps %xmm0, (%rsi)
xorl %eax, %eax
movq %rax, 0x10(%rsi)
leaq 0x40(%rsp), %rdx
movq %rax, 0x10(%rdx)
movaps %xmm0, (%rdx)
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
movaps %xmm0, (%rcx)
movq (%rdi), %rax
callq *0x348(%rax)
movq 0x28(%rsp), %rax
subq 0x20(%rsp), %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
shrq %rdx
movl %edx, 0x604(%rbx)
testl %edx, %edx
je 0x33f08
leaq 0x5f8(%rbx), %r12
cmpl $0x0, 0x5f8(%rbx)
jne 0x33de6
movq 0x18b134(%rip), %rax    # 0x1bef10
movl $0x1, %edi
movq %r12, %rsi
callq *(%rax)
leaq 0x5fc(%rbx), %r15
cmpl $0x0, 0x5fc(%rbx)
jne 0x33e07
movq 0x18b113(%rip), %rax    # 0x1bef10
movl $0x1, %edi
movq %r15, %rsi
callq *(%rax)
leaq 0x600(%rbx), %r14
cmpl $0x0, 0x600(%rbx)
jne 0x33e28
movq 0x18b0f2(%rip), %rax    # 0x1bef10
movl $0x1, %edi
movq %r14, %rsi
callq *(%rax)
movl (%r12), %esi
testl %esi, %esi
je 0x33e76
movq 0x18b141(%rip), %rax    # 0x1bef78
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x18b153(%rip), %rax    # 0x1bef98
movl 0x604(%rbx), %ecx
leal (%rcx,%rcx,2), %esi
shlq $0x2, %rsi
movq 0x20(%rsp), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *(%rax)
movl $0x3, %edi
movl $0x1406, %esi           # imm = 0x1406
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x27980
movl (%r15), %esi
testl %esi, %esi
je 0x33ebe
movq 0x18b0f4(%rip), %rax    # 0x1bef78
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x18b106(%rip), %rax    # 0x1bef98
movl 0x604(%rbx), %ecx
leal (%rcx,%rcx,2), %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 0x280b0
movl (%r14), %esi
testl %esi, %esi
je 0x33f08
movq 0x18b0ac(%rip), %rax    # 0x1bef78
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x18b0be(%rip), %rax    # 0x1bef98
movl 0x604(%rbx), %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,2), %esi
movq (%rsp), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq *(%rax)
movl $0x3, %edi
movl $0x1401, %esi           # imm = 0x1401
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x27950
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x33f1e
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x27930
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x33f35
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x27930
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x33f4c
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x27930
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x33f71
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x27930
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x283b0
movq %rbx, %rdi
callq 0x28130
nop