// File: /workspace/github_cpp_makefile_star2_O2/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 0x32f0
movq %rax, %rbx
movq %rax, %rdi
callq 0x11f02
movq %rbx, %rdi
callq 0x11f28
leaq 0x107e9(%rip), %r14     # 0x256f0
movq %r14, %rdi
callq 0xfee0
leaq 0x109ea(%rip), %rdi     # 0x25900
callq 0x15d6d
testq %r13, %r13
leaq 0x61a9(%rip), %rax      # 0x1b0ce
cmovneq %r13, %rax
movq %rax, 0x8(%rsp)
leaq 0x1079b(%rip), %r13     # 0x256d0
andl $0x0, (%r13)
leaq 0x10793(%rip), %rax     # 0x256d4
andl $0x0, (%rax)
xorl %ebp, %ebp
leaq 0x618d(%rip), %r12      # 0x1b0da
leaq 0x1040c(%rip), %r15     # 0x25360
movslq 0x1676d(%rip), %rax     # 0x2b6c8
cmpq %rax, %rbp
jge 0x14f9c
movq 0x10991(%rip), %rax     # 0x258f8
movq (%rax,%rbp,8), %rsi
testq %rsi, %rsi
cmoveq %r12, %rsi
movq %rsi, (%r15)
movq %rbx, %rdi
callq 0x1255a
movq 0x1096c(%rip), %rax     # 0x258f0
movq (%rax,%rbp,8), %rdi
movq %rbx, %rsi
callq 0xe75e
incq %rbp
cmpl $0x0, (%r13)
je 0x14f54
jmp 0x14fb9
movq 0x8(%rsp), %rsi
movq %rsi, (%r15)
movq %rbx, %rdi
callq 0x1255a
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xe75e
callq 0x15d94
cmpl $0x0, (%r13)
je 0x14fdd
movq %rbx, %rdi
callq 0x11f86
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ebx, %ebx
jmp 0x1516e
movl $0xb0, %r15d
pushq $0x2
popq %r12
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0x30(%r14), %rax
subq 0x28(%r14), %rax
cqto
idivq %r15
cmpq %r13, %rax
jbe 0x15113
movq %r14, %rdi
movl %r13d, %esi
callq 0xfe60
movq 0x28(%r14), %rdi
movq 0x28(%rdi,%rbp), %rcx
movl %ecx, %edx
andl $0xc, %edx
cmpl $0x4, %edx
jne 0x15041
cmpl $0x4, %eax
je 0x1502e
cmpl $0x1, %eax
jne 0x150c4
movslq 0x34(%rdi,%rbp), %rax
shlq $0x3, %rax
addq 0x50(%rbx), %rax
movq (%rax), %rax
movb $0x0, (%rax)
movq %r14, %rdi
movl %r13d, %esi
callq 0xfe60
cmpl $0x1, %eax
je 0x15061
movq %r14, %rdi
movl %r13d, %esi
callq 0xfe60
cmpl $0x2, %eax
jne 0x150b5
movq 0x28(%r14), %rax
testb $0x4, 0x28(%rax,%rbp)
jne 0x150b5
movl %r12d, %edi
callq 0x127df
testl %eax, %eax
je 0x150b5
movq 0x28(%r14), %rax
testb $0x8, 0x28(%rax,%rbp)
jne 0x150b5
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x10864
movq 0x18(%rsp), %rsi
leaq 0x604d(%rip), %rdi      # 0x1b0ef
xorl %eax, %eax
callq 0x3070
movq %r12, %rdi
pushq $0x2
popq %r12
callq 0x31a0
incq %r13
addq $0xb0, %rbp
jmp 0x14fec
btl $0x9, %ecx
jae 0x15041
movl %r12d, %r15d
addq %rbp, %rdi
callq 0xfeba
movl %eax, %r12d
movq 0x28(%r14), %rdi
addq %rbp, %rdi
callq 0xfece
testl %r12d, %r12d
js 0x150fb
movq 0x50(%rbx), %rcx
movl %r12d, %edx
movq (%rcx,%rdx,8), %rcx
movb $0x0, (%rcx)
testl %eax, %eax
movl %r15d, %r12d
movl $0xb0, %r15d
js 0x15041
movl %eax, %eax
jmp 0x15033
pushq $0x1
popq %rdi
callq 0x127df
testl %eax, %eax
je 0x15166
xorl %r14d, %r14d
pushq $0x1
popq %rbp
cmpq %r14, 0x8d38(%rbx)
jle 0x15166
movq 0x98(%rbx,%r14,8), %rsi
movq 0x3f18(%rbx,%r14,8), %rcx
movswl 0x7d98(%rbx,%r14,2), %r8d
movq %rbx, %rdi
movl %ebp, %edx
callq 0x123d2
incq %r14
cmpl $-0x1, %eax
jne 0x15125
movq %rbx, %rdi
callq 0x11f86
jmp 0x14fd6
movq %rbx, %rdi
callq 0x1267c
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0x8d58, %esi           # imm = 0x8D58
movq %rbx, %rdi
callq 0x3300
movq %r14, %rdi
callq 0x3560