// File: /workspace/github_cpp_makefile_star2_O3/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 0x7cde(%rip), %rdx      # 0x1da27
leaq 0x820(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
xorl %eax, %eax
callq 0x8a47
leaq 0x20096e0(%rip), %rax   # 0x201f444
movl (%rax), %eax
cmpl $0x2, %eax
jl 0x15dd6
leaq 0x20096de(%rip), %rbx   # 0x201f450
addq $0x28, %rbx
movl $0x1, %ebp
movl $0x1, %r13d
leaq 0x6a2a(%rip), %r14      # 0x1c7b2
leaq 0x20(%rsp), %r15
leaq 0xa1dc(%rip), %r12      # 0x1ff70
cmpl $0x0, 0x1c(%rbx)
je 0x15dc7
movl $0xa, %esi
movq %r15, %rdi
movq %r14, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x8a47
incl %ebp
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x757d
leaq 0x200967f(%rip), %rax   # 0x201f444
movl (%rax), %eax
incq %r13
movslq %eax, %rcx
addq $0x28, %rbx
cmpq %rcx, %r13
jl 0x15d94
callq 0x15a0b
leaq 0x2009662(%rip), %rax   # 0x201f444
cmpl $0x2, (%rax)
jl 0x1601f
movl $0x1, %ebp
leaq 0x2009659(%rip), %r15   # 0x201f450
leaq 0x68c8(%rip), %r14      # 0x1c6c6
leaq 0xaf61(%rip), %r12      # 0x20d66
movq $0x0, 0x8(%rsp)
leaq (,%rbp,4), %r13
addq %rbp, %r13
shlq $0x3, %r13
addq %r15, %r13
movq %r13, %rdi
leaq 0x67d8(%rip), %rsi      # 0x1c602
callq 0x7542
movl $0x5, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x4400
testl %eax, %eax
je 0x15e88
movq %r13, %rdi
leaq 0xaf21(%rip), %rsi      # 0x20d6e
callq 0x7542
movq %rax, %rdi
callq 0x44f0
addl $0x3, %eax
cmpl $0x3, %eax
ja 0x15e88
leaq 0xa817(%rip), %rcx      # 0x20680
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r13, %rdi
leaq 0xaef2(%rip), %rsi      # 0x20d6e
leaq 0x873c(%rip), %rdx      # 0x1e5bf
callq 0x757d
movq %r13, %rdi
leaq 0x68be(%rip), %rsi      # 0x1c750
callq 0x7542
movq %rax, %rbx
movq %r13, %rdi
movq %r12, %rsi
callq 0x7542
cmpb $0x0, (%rax)
je 0x15ed4
movq %r13, %rdi
movq %r12, %rsi
callq 0x7542
movq %rax, %rbx
movq %rax, %rdi
leaq 0x9cea(%rip), %rsi      # 0x1fbac
callq 0x4330
testl %eax, %eax
leaq 0x7dd9(%rip), %rax      # 0x1dca9
cmoveq %rax, %rbx
movq 0x8(%rsp), %r12
cmpb $0x0, (%rbx)
je 0x16002
testl %r12d, %r12d
jle 0x15f14
movl %r12d, %r15d
leaq 0x20(%rsp), %r12
xorl %r14d, %r14d
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4440
testl %eax, %eax
je 0x15f72
incq %r14
addq $0x40, %r12
cmpq %r14, %r15
jne 0x15ef2
movq 0x8(%rsp), %r12
jmp 0x15f86
xorl %r14d, %r14d
jmp 0x15f7e
movl $0xffffffe0, %ecx       # imm = 0xFFFFFFE0
movq 0x8(%rsp), %r15
subl %r15d, %ecx
jmp 0x15f31
movq 0x8(%rsp), %r15
leal 0x20(%r15), %ecx
movl $0xa, %esi
leaq 0x16(%rsp), %rbx
movq %rbx, %rdi
leaq 0xa4b7(%rip), %rdx      # 0x203fc
xorl %eax, %eax
callq 0x8a47
movq %r13, %rdi
leaq 0xae18(%rip), %rsi      # 0x20d6e
movq %rbx, %rdx
callq 0x757d
incl %r15d
movq %r15, 0x8(%rsp)
leaq 0x20094e3(%rip), %r15   # 0x201f450
jmp 0x16009
leaq 0x20094d7(%rip), %r15   # 0x201f450
movq 0x8(%rsp), %r12
cmpl %r12d, %r14d
jne 0x15fc7
movl %r12d, %r15d
xorl %edi, %edi
cmpl $0x20, %r12d
setl %dil
movl $0xf, %esi
callq 0xa91d
shlq $0x6, %r15
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
movl $0x40, %edx
movq %rbx, %rsi
callq 0x8ae9
movl %r12d, %r14d
leal 0x1(%r12), %eax
movq %rax, 0x8(%rsp)
leaq 0x2009489(%rip), %r15   # 0x201f450
addl $0x20, %r14d
movl $0xa, %esi
leaq 0x16(%rsp), %rbx
movq %rbx, %rdi
leaq 0xa41d(%rip), %rdx      # 0x203fc
movl %r14d, %ecx
xorl %eax, %eax
callq 0x8a47
movq %r13, %rdi
leaq 0xad7b(%rip), %rsi      # 0x20d6e
movq %rbx, %rdx
callq 0x757d
leaq 0x66c4(%rip), %r14      # 0x1c6c6
leaq 0xad5d(%rip), %r12      # 0x20d66
incq %rbp
leaq 0x2009431(%rip), %rax   # 0x201f444
movslq (%rax), %rax
cmpq %rax, %rbp
jl 0x15e0e
movb 0x61b7604(%rip), %al    # 0x61cd629
testb %al, %al
jne 0x16034
callq 0x19b76
movb 0x61b75f5(%rip), %al    # 0x61cd629
testb $0x1, %al
je 0x1603d
callq 0x15bec
callq 0x7840
movl $0x58, %eax
leaq 0x30b7582(%rip), %rcx   # 0x30cd5d0
cmpl $-0x10, (%rcx,%rax)
jne 0x1605b
movl $0xffffffff, (%rcx,%rax) # imm = 0xFFFFFFFF
addq $0x140, %rax            # imm = 0x140
cmpq $0xa00058, %rax         # imm = 0xA00058
jne 0x1604e
cmpb $0x1, 0x61b75ba(%rip)   # 0x61cd62a
jne 0x16077
callq 0x65d1
leaq 0x820(%rsp), %rdi
callq 0x5888
addq $0x1828, %rsp           # imm = 0x1828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq