// File: /workspace/github_cpp_makefile_star2_O3/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 0x33f0c
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 0x33ec8
leaq 0x5f8(%rbx), %r12
cmpl $0x0, 0x5f8(%rbx)
jne 0x33da6
movq 0x188174(%rip), %rax    # 0x1bbf10
movl $0x1, %edi
movq %r12, %rsi
callq *(%rax)
leaq 0x5fc(%rbx), %r15
cmpl $0x0, 0x5fc(%rbx)
jne 0x33dc7
movq 0x188153(%rip), %rax    # 0x1bbf10
movl $0x1, %edi
movq %r15, %rsi
callq *(%rax)
leaq 0x600(%rbx), %r14
cmpl $0x0, 0x600(%rbx)
jne 0x33de8
movq 0x188132(%rip), %rax    # 0x1bbf10
movl $0x1, %edi
movq %r14, %rsi
callq *(%rax)
movl (%r12), %esi
testl %esi, %esi
je 0x33e36
movq 0x188181(%rip), %rax    # 0x1bbf78
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x188193(%rip), %rax    # 0x1bbf98
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 0x33e7e
movq 0x188134(%rip), %rax    # 0x1bbf78
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x188146(%rip), %rax    # 0x1bbf98
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 0x280a0
movl (%r14), %esi
testl %esi, %esi
je 0x33ec8
movq 0x1880ec(%rip), %rax    # 0x1bbf78
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x1880fe(%rip), %rax    # 0x1bbf98
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 0x33ede
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x27930
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x33ef5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x27930
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x33f0c
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 0x33f31
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x27930
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x283a0
movq %rbx, %rdi
callq 0x28120
nop