// File: rofl0r[P]ascc/cc_script.cpp
// Function: ccScript::Write(FileWriteStream*)
void ccScript::Write(FileWriteStream *out) {
    int n;
    out->Write(scfilesig,4);
    out->WriteInt32(SCOM_VERSION);
    out->WriteInt32(globaldatasize);
    out->WriteInt32(codesize);
    out->WriteInt32(stringssize);
    if (globaldatasize > 0)
        out->WriteArray(globaldata,globaldatasize,1);
    if (codesize > 0)
        out->WriteArrayOfInt32(code,codesize);
    if (stringssize > 0)
        out->WriteArray(strings,stringssize,1);
    out->WriteInt32(numfixups);
    if (numfixups > 0) {
        out->WriteArray(fixuptypes,numfixups,1);
        out->WriteArrayOfInt32(fixups,numfixups);
    }
    out->WriteInt32(numimports);
    for (n=0;n<numimports;n++)
        out->WriteArray(imports[n],strlen(imports[n])+1,1);
    out->WriteInt32(numexports);
    for (n=0;n<numexports;n++) {
        out->WriteArray(exports[n],strlen(exports[n])+1,1);
        out->WriteInt32(export_addr[n]);
    }
    out->WriteInt32(numSections);
    for (n = 0; n < numSections; n++) {
        out->WriteArray(sectionNames[n], strlen(sectionNames[n]) + 1, 1);
        out->WriteInt32(sectionOffsets[n]);
    }
    out->WriteInt32(ENDFILESIG);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xcac5(%rip), %rsi      # 0x33f38
movl $0x4, %edx
callq 0x277b0
movq -0x10(%rbp), %rdi
movl $0x5a, %esi
callq 0x277f0
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x10(%rax), %esi
callq 0x277f0
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x20(%rax), %esi
callq 0x277f0
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x30(%rax), %esi
callq 0x277f0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x274df
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x8(%rax), %rsi
movslq 0x10(%rax), %rdx
movl $0x1, %ecx
callq 0x27820
movq -0x20(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jle 0x274fe
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x18(%rax), %rsi
movslq 0x20(%rax), %rdx
callq 0x27860
movq -0x20(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jle 0x27522
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x28(%rax), %rsi
movslq 0x30(%rax), %rdx
movl $0x1, %ecx
callq 0x27820
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x48(%rax), %esi
callq 0x277f0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jle 0x2756b
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x38(%rax), %rsi
movslq 0x48(%rax), %rdx
movl $0x1, %ecx
callq 0x27820
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x40(%rax), %rsi
movslq 0x48(%rax), %rdx
callq 0x27860
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x58(%rax), %esi
callq 0x277f0
movl $0x0, -0x14(%rbp)
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x58(%rcx), %eax
jge 0x275df
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x30(%rbp)
movq 0x50(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x28(%rbp)
movq 0x50(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x41d0
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
movl $0x1, %ecx
callq 0x27820
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x27582
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x70(%rax), %esi
callq 0x277f0
movl $0x0, -0x14(%rbp)
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x70(%rcx), %eax
jge 0x2766b
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x40(%rbp)
movq 0x60(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x38(%rbp)
movq 0x60(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x41d0
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
movl $0x1, %ecx
callq 0x27820
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x68(%rax), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x277f0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x275f6
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x88(%rax), %esi
callq 0x277f0
movl $0x0, -0x14(%rbp)
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x88(%rcx), %eax
jge 0x27700
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0x50(%rbp)
movq 0x78(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x48(%rbp)
movq 0x78(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x41d0
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
movl $0x1, %ecx
callq 0x27820
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x80(%rax), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x277f0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x27685
movq -0x10(%rbp), %rdi
movl $0xbeefcafe, %esi       # imm = 0xBEEFCAFE
callq 0x277f0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)