// File: /workspace/github_cpp_makefile_star2_O3/rofl0r[P]ascc/cs_compiler.cpp
// Function: ccCompileText(char const*, char const*)
ccScript* ccCompileText(const char *texo, const char *scriptName) {
    int t;
    ccCompiledScript *cctemp = new ccCompiledScript();
    cctemp->init();

    sym.reset();
    preproc_startup(&predefinedMacros);

    if (scriptName == NULL)
        scriptName = "Main script";

    ccError = 0;
    ccErrorLine = 0;

    for (t=0;t<numheaders;t++) {
        if (defaultHeaderNames[t] != NULL)
            ccCurScriptName = defaultHeaderNames[t];
        else
            ccCurScriptName = "Internal header file";

        cctemp->start_new_section(ccCurScriptName);
        cc_compile(defaultheaders[t],cctemp);
        if (ccError) break;
    }

    if (!ccError) {
        ccCurScriptName = scriptName;
        cctemp->start_new_section(ccCurScriptName);
        cc_compile(texo,cctemp);
    }
    preproc_shutdown();

    if (ccError) {
        cctemp->shutdown();
        delete cctemp;
        return NULL;
    }

    for (t=0; (size_t)t<sym.entries.size();t++) {
        int stype = sym.get_type(t);
        // blank out the name for imports that are not used, to save space
        // in the output file
        if (((sym.entries[t].flags & SFLG_IMPORTED)!=0) && ((sym.entries[t].flags & SFLG_ACCESSED)==0)) {

            if ((stype == SYM_FUNCTION) || (stype == SYM_GLOBALVAR)) {
                // unused func/variable
                cctemp->imports[sym.entries[t].soffs][0] = 0;
            }
            else if (sym.entries[t].flags & SFLG_PROPERTY) {
                // unused property -- get rid of the getter and setter
                int propGet = sym.entries[t].get_propget();
                int propSet = sym.entries[t].get_propset();
                if (propGet >= 0)
                    cctemp->imports[propGet][0] = 0;
                if (propSet >= 0)
                    cctemp->imports[propSet][0] = 0;
            }
        }

        if ((sym.get_type(t) != SYM_GLOBALVAR) &&
            (sym.get_type(t) != SYM_LOCALVAR)) continue;

        if (sym.entries[t].flags & SFLG_IMPORTED) continue;
        if (ccGetOption(SCOPT_SHOWWARNINGS)==0) ;
        else if ((sym.entries[t].flags & SFLG_ACCESSED)==0) {
            printf("warning: variable '%s' is never used\n",sym.get_friendly_name(t).c_str());
        }
    }

    if (ccGetOption(SCOPT_EXPORTALL)) {
        // export all functions
        for (t=0;t<cctemp->numfunctions;t++) {
            if (cctemp->add_new_export(cctemp->functions[t],EXPORT_FUNCTION,
                cctemp->funccodeoffs[t], cctemp->funcnumparams[t]) == -1) {
                    cctemp->shutdown();
                    return NULL;
            }

        }
    }

    cctemp->free_extra();
    return cctemp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
movl $0x8d58, %edi           # imm = 0x8D58
callq 0x3310
movq %rax, %rbx
movq %rax, %rdi
callq 0x13552
movq %rbx, %rdi
callq 0x135a0
leaq 0xed7a(%rip), %r14      # 0x256e0
movq %r14, %rdi
callq 0x110fa
leaq 0xef7b(%rip), %rdi      # 0x258f0
callq 0x1786f
testq %r13, %r13
leaq 0x6739(%rip), %rax      # 0x1d0bd
cmovneq %r13, %rax
movq %rax, 0x8(%rsp)
leaq 0xed2c(%rip), %r13      # 0x256c0
xorl %eax, %eax
movl %eax, (%r13)
leaq 0xed23(%rip), %rcx      # 0x256c4
movl %eax, (%rcx)
cmpl %eax, 0x14d0f(%rip)     # 0x2b6b8
jle 0x16a02
xorl %ebp, %ebp
leaq 0x6715(%rip), %r15      # 0x1d0c9
leaq 0xe9a5(%rip), %r12      # 0x25360
movq 0xef26(%rip), %rax      # 0x258e8
movq (%rax,%rbp,8), %rsi
testq %rsi, %rsi
cmoveq %r15, %rsi
movq %rsi, (%r12)
movq %rbx, %rdi
callq 0x13c66
movq 0xef00(%rip), %rax      # 0x258e0
movq (%rax,%rbp,8), %rdi
movq %rbx, %rsi
callq 0xf814
cmpl $0x0, (%r13)
jne 0x16a26
incq %rbp
movslq 0x14cbb(%rip), %rax     # 0x2b6b8
cmpq %rax, %rbp
jl 0x169bb
leaq 0xe957(%rip), %rax      # 0x25360
movq 0x8(%rsp), %rsi
movq %rsi, (%rax)
movq %rbx, %rdi
callq 0x13c66
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xf814
callq 0x17896
cmpl $0x0, (%r13)
je 0x16a4a
movq %rbx, %rdi
callq 0x13630
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ebx, %ebx
jmp 0x16beb
movq 0x30(%r14), %rax
cmpq 0x28(%r14), %rax
je 0x16b91
movabsq $0x2e8ba2e8ba2e8ba3, %r15 # imm = 0x2E8BA2E8BA2E8BA3
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0x1106e
movq 0x28(%r14), %rdi
movq 0x28(%rdi,%r12), %rcx
movl %ecx, %edx
andl $0xc, %edx
cmpl $0x4, %edx
jne 0x16aa7
cmpl $0x4, %eax
je 0x16a94
cmpl $0x1, %eax
jne 0x16b51
movslq 0x34(%rdi,%r12), %rax
shlq $0x3, %rax
addq 0x50(%rbx), %rax
movq (%rax), %rax
movb $0x0, (%rax)
movq %r14, %rdi
movl %r13d, %esi
callq 0x1106e
cmpl $0x1, %eax
je 0x16ac7
movq %r14, %rdi
movl %r13d, %esi
callq 0x1106e
cmpl $0x2, %eax
jne 0x16b2c
movq 0x28(%r14), %rax
testb $0x4, 0x28(%rax,%r12)
jne 0x16b2c
movl $0x2, %edi
callq 0x13f2c
testl %eax, %eax
je 0x16b2c
movq 0x28(%r14), %rax
testb $0x8, 0x28(%rax,%r12)
jne 0x16b2c
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x11e2c
movq 0x18(%rsp), %rsi
leaq 0x65d5(%rip), %rdi      # 0x1d0de
xorl %eax, %eax
callq 0x3080
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x16b2c
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3320
incq %r13
movq 0x30(%r14), %rax
subq 0x28(%r14), %rax
sarq $0x4, %rax
imulq %r15, %rax
addq $0xb0, %r12
cmpq %r13, %rax
ja 0x16a68
jmp 0x16b91
btl $0x9, %ecx
jae 0x16aa7
addq %r12, %rdi
callq 0x110d0
movl %eax, %ebp
movq 0x28(%r14), %rdi
addq %r12, %rdi
callq 0x110e6
testl %ebp, %ebp
js 0x16b82
movq 0x50(%rbx), %rcx
movl %ebp, %edx
movq (%rcx,%rdx,8), %rcx
movb $0x0, (%rcx)
testl %eax, %eax
js 0x16aa7
movl %eax, %eax
jmp 0x16a99
movl $0x1, %edi
callq 0x13f2c
testl %eax, %eax
je 0x16be3
cmpq $0x0, 0x8d38(%rbx)
jle 0x16be3
xorl %r14d, %r14d
movq 0x98(%rbx,%r14,8), %rsi
movq 0x3f18(%rbx,%r14,8), %rcx
movswl 0x7d98(%rbx,%r14,2), %r8d
movq %rbx, %rdi
movl $0x1, %edx
callq 0x13ae8
cmpl $-0x1, %eax
je 0x16bfd
incq %r14
cmpq %r14, 0x8d38(%rbx)
jg 0x16bac
movq %rbx, %rdi
callq 0x13d88
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x13630
jmp 0x16a43
movq %rax, %r14
movl $0x8d58, %esi           # imm = 0x8D58
movq %rbx, %rdi
callq 0x3320
movq %r14, %rdi
callq 0x3560
nop