// File: /workspace/github_c_makefile_star2_O2/vlenhart[P]q3bsp/q3bsp.cpp
// Function: Quake3BSP::Quake3BSP(StringRef const&, StringRef const&)
Quake3BSP::Quake3BSP(const StringRef &fname,
                     const StringRef &code)
{
  mMesh = 0;

  mOk = false;
  mName     = fname;
  mCodeName = code;

  mUsePng = true; // hg 

  String ifoo = fname;
  String str = ifoo+".bsp";

  // hg prefix for light map files 
  const char * del = strrchr(fname,'\\');
  if (del) mLmPrefix = (del+1); // use file name part only
  else mLmPrefix=fname.Get();

  Fload data(str);

  void *mem = data.GetData();
  int   len = data.GetLen();
  if ( mem )
  {

    mOk = mHeader.SetHeader(mem);

    if ( mOk )
    {
      ReadFaces(mem);
      ReadElements(mem);
      ReadVertices(mem);
      ReadLightmaps(mem);
      ReadShaders(mem);
      BuildVertexBuffers();

	  ReadPlanes(mem);
	  ReadLeaves(mem);
	  ReadLeafSurfaces(mem);

	  ReadNodes(mem);
	  // brushes 
	  ReadEntities(mem);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x94ba(%rip), %r13      # 0x10bb2
movq %r13, 0x8(%rdi)
movq %r13, 0x10(%rdi)
leaq 0x128(%rdi), %r14
xorps %xmm0, %xmm0
movups %xmm0, 0xa8(%rdi)
movups %xmm0, 0xb8(%rdi)
movups %xmm0, 0xc8(%rdi)
movups %xmm0, 0xd8(%rdi)
movups %xmm0, 0xe8(%rdi)
movups %xmm0, 0xf8(%rdi)
movups %xmm0, 0x108(%rdi)
andq $0x0, 0x118(%rdi)
movl $0xc0, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2150
movq %r13, 0x1f0(%rbx)
andq $0x0, 0x120(%rbx)
movb $0x0, (%rbx)
movq (%r15), %rax
movq %rax, 0x8(%rbx)
movq (%r12), %rax
movq %rax, 0x10(%rbx)
movb $0x1, 0x1e8(%rbx)
leaq -0xc8(%rbp), %rdi
movq %r15, %rsi
callq 0x94c4
leaq 0x9478(%rip), %rdx      # 0x10c08
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x5b47
movq (%r15), %r15
pushq $0x5c
popq %rsi
movq %r15, %rdi
callq 0x2260
testq %rax, %rax
je 0x77ca
incq %rax
leaq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x94e4
jmp 0x77d9
leaq -0x88(%rbp), %rdi
movq %r15, %rsi
callq 0x94e4
movq -0x88(%rbp), %rax
movq %rax, 0x1f0(%rbx)
leaq -0x88(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x6bac
movq -0x80(%rbp), %r15
testq %r15, %r15
je 0x788f
leaq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0x79d4
movb %al, (%rbx)
testb %al, %al
je 0x788f
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7a18
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7b0c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7bfc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7d5e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7f04
movq %rbx, %rdi
callq 0x7fea
movq %rbx, %rdi
movq %r15, %rsi
callq 0x80a6
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8116
movq %rbx, %rdi
movq %r15, %rsi
callq 0x81be
movq %rbx, %rdi
movq %r15, %rsi
callq 0x822c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x829c
leaq -0x88(%rbp), %rdi
callq 0x6c92
leaq -0xa8(%rbp), %rdi
callq 0x2120
leaq -0xc8(%rbp), %rdi
callq 0x2120
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x78c9
jmp 0x78c9
movq %rax, -0x30(%rbp)
jmp 0x78eb
movq %rax, -0x30(%rbp)
jmp 0x78f7
movq %rax, -0x30(%rbp)
jmp 0x7903
movq %rax, -0x30(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x6c92
leaq -0xa8(%rbp), %rdi
callq 0x2120
leaq -0xc8(%rbp), %rdi
callq 0x2120
leaq 0xa8(%rbx), %rax
movq %rax, -0x60(%rbp)
leaq 0x1d0(%rbx), %rdi
leaq 0x1b8(%rbx), %r13
leaq 0x1a0(%rbx), %r15
leaq 0x188(%rbx), %r12
leaq 0x170(%rbx), %rax
movq %rax, -0x38(%rbp)
leaq 0x158(%rbx), %rax
movq %rax, -0x40(%rbp)
leaq 0x140(%rbx), %rax
movq %rax, -0x48(%rbp)
leaq 0xf0(%rbx), %rax
movq %rax, -0x50(%rbp)
leaq 0xd8(%rbx), %rax
movq %rax, -0x58(%rbp)
addq $0xc0, %rbx
callq 0x950a
movq %r13, %rdi
callq 0x9c30
movq %r15, %rdi
callq 0x9bf2
movq %r12, %rdi
callq 0x9bae
movq -0x38(%rbp), %rdi
callq 0x9b70
movq -0x40(%rbp), %rdi
callq 0x9b70
movq -0x48(%rbp), %rdi
callq 0x9b2c
movq %r14, %rdi
callq 0x9aee
movq -0x50(%rbp), %rdi
callq 0x99e8
movq -0x58(%rbp), %rdi
callq 0x9aaa
movq %rbx, %rdi
callq 0x9a66
movq -0x60(%rbp), %rdi
callq 0x9a22
movq -0x30(%rbp), %rdi
callq 0x23e0