// File: tomfunkhouser[P]gaps/pkgs/GSV/GSVScan.cpp
// Function: gaps::GSVScan::Draw(gaps::RNFlags) const
void GSVScan::
Draw(RNFlags flags) const
{
  if (flags & GSV_DRAW_POINTS_WITH_LASER_INDEX_COLOR) {
    // Draw points  colored by laser index
    const int ncolors = 3;
    GLfloat color[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
    int laser_index = (Laser()) ? Laser()->RunIndex() : 0;
    RNLoadRgb(color[laser_index % ncolors]);
    for (int i = 0; i < NScanlines(); i++) {
      GSVScanline *scanline = Scanline(i);
      scanline->Draw(flags);
    }
  }
  else if (flags & GSV_DRAW_MESHES_WITHOUT_COLOR) {
    glEnable(GL_CULL_FACE);
    static GSVMesh *last_mesh = NULL;
    static const GSVScan *last_scan = NULL;
    if (this != last_scan) {
      if (last_mesh) delete last_mesh;
      last_mesh = Mesh();
      last_scan = this;
    }
    if (last_mesh) last_mesh->Draw();
    glDisable(GL_CULL_FACE);
  }
  else {
    // Draw scanlines
    for (int i = 0; i < NScanlines(); i++) {
      GSVScanline *scanline = Scanline(i);
      scanline->Draw(flags);
    }
  }
}

// Assembly:
subq $0x98, %rsp
movq %rsi, 0x90(%rsp)
movq %rdi, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x38fe0
andq $0x1, %rax
cmpq $0x0, %rax
je 0x55d26
movl $0x3, 0x84(%rsp)
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
movl $0x24, %edx
callq 0x295e0
movq 0x20(%rsp), %rdi
movss 0x2104cc(%rip), %xmm0   # 0x266114
movss %xmm0, 0x60(%rsp)
movss 0x2104be(%rip), %xmm0   # 0x266114
movss %xmm0, 0x70(%rsp)
movss 0x2104b0(%rip), %xmm0   # 0x266114
movss %xmm0, 0x80(%rsp)
callq 0x54260
cmpq $0x0, %rax
je 0x55c90
movq 0x20(%rsp), %rdi
callq 0x54260
movq %rax, %rdi
callq 0x44c00
movl %eax, 0x1c(%rsp)
jmp 0x55c98
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
jmp 0x55c98
movl 0x1c(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movslq %edx, %rax
leaq 0x60(%rsp), %rdi
imulq $0xc, %rax, %rax
addq %rax, %rdi
callq 0x56760
movl $0x0, 0x58(%rsp)
movq 0x20(%rsp), %rdi
movl 0x58(%rsp), %eax
movl %eax, 0x18(%rsp)
callq 0x3a0d0
movl %eax, %ecx
movl 0x18(%rsp), %eax
cmpl %ecx, %eax
jge 0x55d21
movq 0x20(%rsp), %rdi
movl 0x58(%rsp), %esi
callq 0x3a0f0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
movq 0x90(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rsi
movq (%rdi), %rax
callq *0x10(%rax)
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x55cc8
jmp 0x55e4d
leaq 0x90(%rsp), %rdi
callq 0x38fe0
andq $0x10000, %rax          # imm = 0x10000
cmpq $0x0, %rax
je 0x55de8
movl $0xb44, %edi            # imm = 0xB44
callq 0x29a50
movq 0x20(%rsp), %rax
cmpq 0x2a9537(%rip), %rax    # 0x2ff290
je 0x55da4
cmpq $0x0, 0x2a9525(%rip)    # 0x2ff288
je 0x55d84
movq 0x2a951c(%rip), %rax    # 0x2ff288
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x55d82
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x55d84
movq 0x20(%rsp), %rdi
callq 0x55300
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x2a94eb(%rip)    # 0x2ff288
movq %rax, 0x2a94ec(%rip)    # 0x2ff290
cmpq $0x0, 0x2a94dc(%rip)    # 0x2ff288
je 0x55ddc
movq 0x2a94d3(%rip), %rax    # 0x2ff288
movq %rax, 0x8(%rsp)
leaq 0x40(%rsp), %rdi
movl $0x772, %esi            # imm = 0x772
callq 0x38e50
movq 0x8(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq (%rdi), %rax
callq *0x120(%rax)
movl $0xb44, %edi            # imm = 0xB44
callq 0x2a130
jmp 0x55e4b
movl $0x0, 0x3c(%rsp)
movq 0x20(%rsp), %rdi
movl 0x3c(%rsp), %eax
movl %eax, 0x4(%rsp)
callq 0x3a0d0
movl %eax, %ecx
movl 0x4(%rsp), %eax
cmpl %ecx, %eax
jge 0x55e49
movq 0x20(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0x3a0f0
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movq 0x90(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rsi
movq (%rdi), %rax
callq *0x10(%rax)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x55df0
jmp 0x55e4b
jmp 0x55e4d
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)