// File: tomfunkhouser[P]gaps/pkgs/GSV/GSVMesh.cpp
// Function: gaps::GSVMesh::Draw(int) const
void GSVMesh::
Draw(RNBoolean texture_coordinates) const
{
  if (texture_coordinates) {
    RNGrfxBegin(RN_GRFX_TRIANGLES);
    for (int i = 0; i < NFaces(); i++) {
      GSVMeshFace *face = Face(i);
      R3LoadNormal(FaceNormal(face));
      GSVMeshVertex *v0 = VertexOnFace(face, 0);
      int s0 = VertexScanlineIndex(v0);
      int t0 = (int) (180.0 * VertexLaserAngle(v0) / RN_PI + 0.5);
      R3LoadTextureCoords(s0, t0);
      R3LoadPoint(VertexPosition(v0));
      GSVMeshVertex *v1 = VertexOnFace(face, 1);
      int s1 = VertexScanlineIndex(v1);
      int t1 = (int) (180.0 * VertexLaserAngle(v1) / RN_PI + 0.5);
      R3LoadTextureCoords(s1, t1);
      R3LoadPoint(VertexPosition(v1));
      GSVMeshVertex *v2 = VertexOnFace(face, 2);
      int s2 = VertexScanlineIndex(v2);
      int t2 = (int) (180.0 * VertexLaserAngle(v2) / RN_PI + 0.5);
      R3LoadTextureCoords(s2, t2);
      R3LoadPoint(VertexPosition(v2));
    }
    RNGrfxEnd();
  }
  else {
    DrawFaces();
  }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movl %esi, 0x5c(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpl $0x0, 0x5c(%rsp)
je 0x5c2a9
movl $0x4, %edi
callq 0x38d90
movl $0x0, 0x58(%rsp)
movq 0x10(%rsp), %rdi
movl 0x58(%rsp), %eax
movl %eax, 0xc(%rsp)
callq 0x39030
movl %eax, %ecx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
jge 0x5c2a2
movq 0x10(%rsp), %rdi
movl 0x58(%rsp), %esi
callq 0x39050
movq 0x10(%rsp), %rdi
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rsi
callq 0x390e0
movq %rax, %rdi
callq 0x390c0
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rsi
xorl %edx, %edx
callq 0x5e1f0
movq 0x10(%rsp), %rdi
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rsi
callq 0x5a630
movq 0x10(%rsp), %rdi
movl %eax, 0x44(%rsp)
movq 0x48(%rsp), %rsi
callq 0x5a140
movaps %xmm0, %xmm1
movsd 0x20ac77(%rip), %xmm0   # 0x266da8
mulsd %xmm1, %xmm0
leaq 0x211e3c(%rip), %rax    # 0x26df78
divsd (%rax), %xmm0
movsd 0x209f08(%rip), %xmm1   # 0x266050
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x40(%rsp)
movl 0x44(%rsp), %edi
movl 0x40(%rsp), %esi
callq 0x39cc0
movq 0x10(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x391a0
movq %rax, %rdi
callq 0x38e20
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rsi
movl $0x1, %edx
callq 0x5e1f0
movq 0x10(%rsp), %rdi
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rsi
callq 0x5a630
movq 0x10(%rsp), %rdi
movl %eax, 0x34(%rsp)
movq 0x38(%rsp), %rsi
callq 0x5a140
movaps %xmm0, %xmm1
movsd 0x20abea(%rip), %xmm0   # 0x266da8
mulsd %xmm1, %xmm0
leaq 0x211daf(%rip), %rax    # 0x26df78
divsd (%rax), %xmm0
movsd 0x209e7b(%rip), %xmm1   # 0x266050
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x30(%rsp)
movl 0x34(%rsp), %edi
movl 0x30(%rsp), %esi
callq 0x39cc0
movq 0x10(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x391a0
movq %rax, %rdi
callq 0x38e20
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rsi
movl $0x2, %edx
callq 0x5e1f0
movq 0x10(%rsp), %rdi
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rsi
callq 0x5a630
movq 0x10(%rsp), %rdi
movl %eax, 0x24(%rsp)
movq 0x28(%rsp), %rsi
callq 0x5a140
movaps %xmm0, %xmm1
movsd 0x20ab5d(%rip), %xmm0   # 0x266da8
mulsd %xmm1, %xmm0
leaq 0x211d22(%rip), %rax    # 0x26df78
divsd (%rax), %xmm0
movsd 0x209dee(%rip), %xmm1   # 0x266050
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x20(%rsp)
movl 0x24(%rsp), %edi
movl 0x20(%rsp), %esi
callq 0x39cc0
movq 0x10(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x391a0
movq %rax, %rdi
callq 0x38e20
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x5c0a4
callq 0x38e40
jmp 0x5c2cb
leaq 0x18(%rsp), %rdi
movl $0x772, %esi            # imm = 0x772
callq 0x38e50
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq (%rdi), %rax
callq *0x138(%rax)
addq $0x68, %rsp
retq