// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlcsg/qcsg.cpp
// Function: WriteBSP(char const*)
void WriteBSP(const char* const name)
{
    char path[_MAX_PATH];

#ifdef ZHLT_DEFAULTEXTENSION_FIX
	safe_snprintf(path, _MAX_PATH, "%s.bsp", name);
#else
    safe_strncpy(path, name, _MAX_PATH);
    DefaultExtension(path, ".bsp");
#endif

    SetModelNumbers();
#ifdef HLCSG_COPYMODELKEYVALUE
	ReuseModel();
#endif
    SetLightStyles();

    if (!g_onlyents)
        WriteMiptex();
#ifdef HLCSG_ONLYENTS_NOWADCHANGE
	if (g_onlyents)
	{
		LoadWadValue ();
	}
#endif

    UnparseEntities();
    ConvertHintToEmpty(); // this is ridiculous. --vluzacn
#ifdef HLCSG_CHART_FIX
    if (g_chart)
        PrintBSPFileSizes();
#endif
    WriteBSPFile(path);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1828, %rsp           # imm = 0x1828
movq %rdi, %rcx
leaq 0x77c7(%rip), %rdx      # 0x1da37
leaq 0x820(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
xorl %eax, %eax
callq 0x8b7f
leaq 0x20091c9(%rip), %rax   # 0x201f454
cmpl $0x2, (%rax)
jl 0x162f9
leaq 0x20091c9(%rip), %rbx   # 0x201f460
addq $0x28, %rbx
movl $0x1, %ebp
movl $0x1, %r13d
leaq 0x650d(%rip), %r14      # 0x1c7ba
leaq 0x20(%rsp), %r15
leaq 0x9c97(%rip), %r12      # 0x1ff50
cmpl $0x0, 0x1c(%rbx)
je 0x162e3
movl $0xa, %esi
movq %r15, %rdi
movq %r14, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x8b7f
incl %ebp
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x75d4
incq %r13
leaq 0x2009167(%rip), %rax   # 0x201f454
movslq (%rax), %rax
addq $0x28, %rbx
cmpq %rax, %r13
jl 0x162b9
callq 0x15f39
leaq 0x200914f(%rip), %rax   # 0x201f454
cmpl $0x2, (%rax)
jl 0x16538
movl $0x1, %ebp
leaq 0x62f0(%rip), %r12      # 0x1c60a
leaq 0x63ad(%rip), %r14      # 0x1c6ce
leaq 0xaa19(%rip), %r15      # 0x20d41
movq $0x0, 0x8(%rsp)
leaq (,%rbp,4), %r13
addq %rbp, %r13
shlq $0x3, %r13
addq 0x11c91(%rip), %r13     # 0x27fd8
movq %r13, %rdi
movq %r12, %rsi
callq 0x7599
movl $0x5, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x4410
testl %eax, %eax
je 0x163ab
movq %r13, %rdi
leaq 0xa9d9(%rip), %rsi      # 0x20d49
callq 0x7599
movq %rax, %rdi
callq 0x4500
addl $0x3, %eax
cmpl $0x3, %eax
ja 0x163ab
leaq 0xa2d4(%rip), %rcx      # 0x20660
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r13, %rdi
leaq 0xa9aa(%rip), %rsi      # 0x20d49
leaq 0x8229(%rip), %rdx      # 0x1e5cf
callq 0x75d4
movq %r13, %rdi
leaq 0x63a3(%rip), %rsi      # 0x1c758
callq 0x7599
movq %rax, %rbx
movq %r13, %rdi
movq %r15, %rsi
callq 0x7599
cmpb $0x0, (%rax)
je 0x163f7
movq %r13, %rdi
movq %r15, %rsi
callq 0x7599
movq %rax, %rbx
movq %rax, %rdi
leaq 0x97d7(%rip), %rsi      # 0x1fbbc
callq 0x4340
testl %eax, %eax
leaq 0x78c6(%rip), %rax      # 0x1dcb9
cmoveq %rax, %rbx
movq 0x8(%rsp), %r15
cmpb $0x0, (%rbx)
je 0x1643d
testl %r15d, %r15d
jle 0x16449
movl %r15d, %r15d
leaq 0x20(%rsp), %r12
xorl %r14d, %r14d
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4450
testl %eax, %eax
je 0x1642f
incq %r14
addq $0x40, %r12
cmpq %r14, %r15
jne 0x16411
movl %r15d, %r14d
leaq 0x61d4(%rip), %r12      # 0x1c60a
movq 0x8(%rsp), %r15
jmp 0x1644c
leaq 0xa8fd(%rip), %r15      # 0x20d41
jmp 0x16522
xorl %r14d, %r14d
cmpl %r15d, %r14d
jne 0x16489
xorl %edi, %edi
cmpl $0x20, %r15d
setl %dil
movl $0xf, %esi
callq 0xaa4d
movl %r14d, %eax
shlq $0x6, %rax
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
movl $0x40, %edx
movq %rbx, %rsi
callq 0x8c21
incl %r15d
movq %r15, 0x8(%rsp)
leaq 0xa8b1(%rip), %r15      # 0x20d41
addl $0x20, %r14d
movl $0xa, %esi
leaq 0x16(%rsp), %rbx
movq %rbx, %rdi
leaq 0x9f34(%rip), %rdx      # 0x203dc
movl %r14d, %ecx
xorl %eax, %eax
callq 0x8b7f
movq %r13, %rdi
leaq 0xa88d(%rip), %rsi      # 0x20d49
movq %rbx, %rdx
callq 0x75d4
leaq 0x6203(%rip), %r14      # 0x1c6ce
jmp 0x16522
movl $0xffffffe0, %ecx       # imm = 0xFFFFFFE0
movq 0x8(%rsp), %r12
subl %r12d, %ecx
jmp 0x164e6
movq 0x8(%rsp), %r12
leal 0x20(%r12), %ecx
movl $0xa, %esi
leaq 0x16(%rsp), %rbx
movq %rbx, %rdi
leaq 0x9ee2(%rip), %rdx      # 0x203dc
xorl %eax, %eax
callq 0x8b7f
movq %r13, %rdi
leaq 0xa83e(%rip), %rsi      # 0x20d49
movq %rbx, %rdx
callq 0x75d4
incl %r12d
movq %r12, 0x8(%rsp)
leaq 0x60e8(%rip), %r12      # 0x1c60a
incq %rbp
leaq 0x2008f28(%rip), %rax   # 0x201f454
movslq (%rax), %rax
cmpq %rax, %rbp
jl 0x16331
cmpb $0x0, 0x61b70fa(%rip)   # 0x61cd639
jne 0x16546
callq 0x1a10f
cmpb $0x1, 0x61b70ec(%rip)   # 0x61cd639
jne 0x16554
callq 0x16114
callq 0x792a
movl $0x58, %eax
leaq 0x30b707b(%rip), %rcx   # 0x30cd5e0
cmpl $-0x10, (%rcx,%rax)
jne 0x16572
movl $0xffffffff, (%rcx,%rax) # imm = 0xFFFFFFFF
addq $0x140, %rax            # imm = 0x140
cmpq $0xa00058, %rax         # imm = 0xA00058
jne 0x16565
cmpb $0x1, 0x61b70b3(%rip)   # 0x61cd63a
jne 0x1658e
callq 0x6656
leaq 0x820(%rsp), %rdi
callq 0x58a6
addq $0x1828, %rsp           # imm = 0x1828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq