// File: /workspace/github_cpp_makefile_star2_O2/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 0x713a(%rip), %rdx      # 0x1a997
leaq 0x820(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
xorl %eax, %eax
callq 0x78cb
leaq 0x2009be8(%rip), %rax   # 0x201d460
leaq 0x28(%rax), %r14
leaq 0x2009bd1(%rip), %rax   # 0x201d454
movl (%rax), %eax
pushq $0x1
popq %rbp
pushq $0x1
popq %rbx
pushq $0xa
popq %r12
leaq 0x960a(%rip), %r13      # 0x1cea0
movslq %eax, %rcx
cmpq %rcx, %rbx
jge 0x138e2
cmpl $0x0, 0x1c(%r14)
je 0x138d9
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
leaq 0x5e63(%rip), %rdx      # 0x1971a
movl %ebp, %ecx
xorl %eax, %eax
callq 0x78cb
incl %ebp
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x69e6
leaq 0x2009b7d(%rip), %rax   # 0x201d454
movl (%rax), %eax
incq %rbx
addq $0x28, %r14
jmp 0x13896
callq 0x1352b
pushq $0x1
popq %r13
leaq 0x5c78(%rip), %r14      # 0x1956a
leaq 0x5d35(%rip), %rbp      # 0x1962e
leaq 0xa356(%rip), %r12      # 0x1dc56
movq $0x0, (%rsp)
leaq 0x2009b45(%rip), %rax   # 0x201d454
movslq (%rax), %rax
cmpq %rax, %r13
jge 0x13b0d
imulq $0x28, %r13, %r15
addq 0x126b2(%rip), %r15     # 0x25fd8
movq %r15, %rdi
movq %r14, %rsi
callq 0x69ab
movq %rax, %rdi
movq %rbp, %rsi
pushq $0x5
popq %rdx
callq 0x4420
testl %eax, %eax
je 0x13988
movq %r15, %rdi
leaq 0xa311(%rip), %rsi      # 0x1dc5e
callq 0x69ab
movq %rax, %rdi
callq 0x4520
addl $0x3, %eax
cmpl $0x3, %eax
ja 0x13988
leaq 0x9c47(%rip), %rcx      # 0x1d5b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
leaq 0xa2e2(%rip), %rsi      # 0x1dc5e
leaq 0x7bac(%rip), %rdx      # 0x1b52f
callq 0x69e6
movq %r15, %rdi
leaq 0x5d26(%rip), %rsi      # 0x196b8
callq 0x69ab
movq %r12, %rbx
movq %rax, %r12
movq %r15, %rdi
movq %rbx, %rsi
callq 0x69ab
cmpb $0x0, (%rax)
je 0x139d7
movq %r15, %rdi
movq %rbx, %rsi
callq 0x69ab
movq %rax, %r12
movq %rax, %rdi
leaq 0x9157(%rip), %rsi      # 0x1cb1c
callq 0x4350
testl %eax, %eax
leaq 0x7246(%rip), %rax      # 0x1ac19
cmoveq %rax, %r12
movq (%rsp), %rax
cmpb $0x0, (%r12)
je 0x13a17
testl %eax, %eax
movl $0x0, %r14d
cmovgl %eax, %r14d
leaq 0x20(%rsp), %rbx
xorl %ebp, %ebp
movq %r13, 0x8(%rsp)
cmpq %rbp, %r14
je 0x13a26
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4480
testl %eax, %eax
je 0x13a23
incq %rbp
addq $0x40, %rbx
jmp 0x139fa
leaq 0xa238(%rip), %r12      # 0x1dc56
jmp 0x13b05
movl %ebp, %r14d
movq (%rsp), %r13
cmpl %r13d, %r14d
leaq 0x5bfa(%rip), %rbp      # 0x1962e
jne 0x13a69
xorl %edi, %edi
cmpl $0x20, %r13d
setl %dil
pushq $0xf
popq %rsi
callq 0x9517
movl %r13d, %eax
shlq $0x6, %rax
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
movq %r12, %rsi
pushq $0x40
popq %rdx
callq 0x796d
incl %r13d
movq %r13, (%rsp)
leaq 0xa1e6(%rip), %r12      # 0x1dc56
movq 0x8(%rsp), %r13
addl $0x20, %r14d
leaq 0x16(%rsp), %rbx
movq %rbx, %rdi
pushq $0xa
popq %rsi
leaq 0x98a1(%rip), %rdx      # 0x1d32c
movl %r14d, %ecx
xorl %eax, %eax
callq 0x78cb
movq %r15, %rdi
leaq 0xa1bf(%rip), %rsi      # 0x1dc5e
movq %rbx, %rdx
callq 0x69e6
leaq 0x5abc(%rip), %r14      # 0x1956a
jmp 0x13b05
pushq $-0x20
popq %rcx
movq %r13, 0x8(%rsp)
movq (%rsp), %r13
subl %r13d, %ecx
jmp 0x13ace
movq %r13, 0x8(%rsp)
movq (%rsp), %r13
leal 0x20(%r13), %ecx
leaq 0x16(%rsp), %rbx
movq %rbx, %rdi
pushq $0xa
popq %rsi
leaq 0x984c(%rip), %rdx      # 0x1d32c
xorl %eax, %eax
callq 0x78cb
movq %r15, %rdi
leaq 0xa16d(%rip), %rsi      # 0x1dc5e
movq %rbx, %rdx
callq 0x69e6
incl %r13d
movq %r13, (%rsp)
movq 0x8(%rsp), %r13
incq %r13
jmp 0x13908
movb 0x61b7b26(%rip), %al    # 0x61cb639
testb %al, %al
jne 0x13b22
callq 0x1744f
movb 0x61b7b17(%rip), %al    # 0x61cb639
testb $0x1, %al
je 0x13b2b
callq 0x13706
callq 0x6c60
pushq $0x58
popq %rax
leaq 0x30b7aa6(%rip), %rcx   # 0x30cb5e0
cmpq $0xa00058, %rax         # imm = 0xA00058
je 0x13b54
cmpl $-0x10, (%rcx,%rax)
jne 0x13b4c
orl $-0x1, (%rcx,%rax)
addq $0x140, %rax            # imm = 0x140
jmp 0x13b3a
cmpb $0x1, 0x61b7adf(%rip)   # 0x61cb63a
jne 0x13b62
callq 0x5ef9
leaq 0x820(%rsp), %rdi
callq 0x5381
addq $0x1828, %rsp           # imm = 0x1828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq