// File: rofl0r[P]ascc/cc_script.cpp
// Function: ccScript::ccScript(ccScript const&)
ccScript::ccScript(const ccScript &src)
{
    globaldatasize = src.globaldatasize;
    if (globaldatasize > 0)
    {
        globaldata = (char*)malloc(globaldatasize);
        memcpy(globaldata, src.globaldata, globaldatasize);
    }
    else
    {
        globaldata = nullptr;
    }

    codesize = src.codesize;
    if (codesize > 0)
    {
        code = (int32_t*)malloc(codesize * sizeof(int32_t));
        memcpy(code, src.code, sizeof(int32_t) * codesize);
    }
    else
    {
        code = nullptr;
    }

    stringssize = src.stringssize;
    if (stringssize > 0)
    {
        strings = (char*)malloc(stringssize);
        memcpy(strings, src.strings, stringssize);
    }
    else
    {
        strings = nullptr;
    }

    numfixups = src.numfixups;
    if (numfixups > 0)
    {
        fixuptypes = (char*)malloc(numfixups);
        fixups = (int32_t*)malloc(numfixups * sizeof(int32_t));
        memcpy(fixuptypes, src.fixuptypes, numfixups);
        memcpy(fixups, src.fixups, numfixups * sizeof(int32_t));
    }
    else
    {
        fixups = nullptr;
        fixuptypes = nullptr;
    }

    importsCapacity = src.numimports;
    numimports = src.numimports;
    if (numimports > 0)
    {
        imports = (char**)malloc(sizeof(char*) * numimports);
        for (int i = 0; i < numimports; ++i)
            imports[i] = ags_strdup(src.imports[i]);
    }
    else
    {
        imports = nullptr;
    }

    exportsCapacity = src.numexports;
    numexports = src.numexports;
    if (numexports > 0)
    {
        exports = (char**)malloc(sizeof(char*) * numexports);
        export_addr = (int32_t*)malloc(sizeof(int32_t) * numexports);
        for (int i = 0; i < numexports; ++i)
        {
            exports[i] = ags_strdup(src.exports[i]);
            export_addr[i] = src.export_addr[i];
        }
    }
    else
    {
        exports = nullptr;
        export_addr = nullptr;
    }

    capacitySections = src.numSections;
    numSections = src.numSections;
    if (numSections > 0)
    {
        sectionNames = (char**)malloc(numSections * sizeof(char*));
        sectionOffsets = (int32_t*)malloc(numSections * sizeof(int32_t));
        for (int i = 0; i < numSections; ++i)
        {
            sectionNames[i] = ags_strdup(src.sectionNames[i]);
            sectionOffsets[i] = src.sectionOffsets[i];
        }
    }
    else
    {
        numSections = 0;
        sectionNames = nullptr;
        sectionOffsets = nullptr;
    }

    instances = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x1af89(%rip), %rcx     # 0x41d58
addq $0x10, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl %ecx, 0x10(%rax)
cmpl $0x0, 0x10(%rax)
jle 0x26e15
movq -0x28(%rbp), %rax
movslq 0x10(%rax), %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rsi
movslq 0x10(%rax), %rdx
callq 0x4300
jmp 0x26e21
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x20(%rcx), %ecx
movl %ecx, 0x20(%rax)
cmpl $0x0, 0x20(%rax)
jle 0x26e6c
movq -0x28(%rbp), %rax
movslq 0x20(%rax), %rdi
shlq $0x2, %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rsi
movslq 0x20(%rax), %rdx
shlq $0x2, %rdx
callq 0x4300
jmp 0x26e78
movq -0x28(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x30(%rcx), %ecx
movl %ecx, 0x30(%rax)
cmpl $0x0, 0x30(%rax)
jle 0x26ebb
movq -0x28(%rbp), %rax
movslq 0x30(%rax), %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rsi
movslq 0x30(%rax), %rdx
callq 0x4300
jmp 0x26ec7
movq -0x28(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x48(%rcx), %ecx
movl %ecx, 0x48(%rax)
cmpl $0x0, 0x48(%rax)
jle 0x26f3f
movq -0x28(%rbp), %rax
movslq 0x48(%rax), %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movslq 0x48(%rax), %rdi
shlq $0x2, %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x40(%rax)
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rcx
movq 0x38(%rcx), %rsi
movslq 0x48(%rax), %rdx
callq 0x4300
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rsi
movslq 0x48(%rax), %rdx
shlq $0x2, %rdx
callq 0x4300
jmp 0x26f53
movq -0x28(%rbp), %rax
movq $0x0, 0x40(%rax)
movq $0x0, 0x38(%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x58(%rcx), %ecx
movl %ecx, 0x4c(%rax)
movq -0x10(%rbp), %rcx
movl 0x58(%rcx), %ecx
movl %ecx, 0x58(%rax)
cmpl $0x0, 0x58(%rax)
jle 0x26fd5
movq -0x28(%rbp), %rax
movslq 0x58(%rax), %rdi
shlq $0x3, %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x50(%rax)
movl $0x0, -0x14(%rbp)
movq -0x28(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x58(%rcx), %eax
jge 0x26fd3
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x27a60
movq %rax, %rdx
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x26f94
jmp 0x26fe1
movq -0x28(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x70(%rcx), %ecx
movl %ecx, 0x5c(%rax)
movq -0x10(%rbp), %rcx
movl 0x70(%rcx), %ecx
movl %ecx, 0x70(%rax)
cmpl $0x0, 0x70(%rax)
jle 0x27099
movq -0x28(%rbp), %rax
movslq 0x70(%rax), %rdi
shlq $0x3, %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x60(%rax)
movslq 0x70(%rax), %rdi
shlq $0x2, %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x68(%rax)
movl $0x0, -0x18(%rbp)
movq -0x28(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x70(%rcx), %eax
jge 0x27097
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x27a60
movq %rax, %rsi
movq -0x28(%rbp), %rax
movq 0x60(%rax), %rcx
movslq -0x18(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq -0x10(%rbp), %rcx
movq 0x68(%rcx), %rcx
movslq -0x18(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movq 0x68(%rax), %rax
movslq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2703e
jmp 0x270ad
movq -0x28(%rbp), %rax
movq $0x0, 0x60(%rax)
movq $0x0, 0x68(%rax)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x88(%rcx), %ecx
movl %ecx, 0x8c(%rax)
movq -0x10(%rbp), %rcx
movl 0x88(%rcx), %ecx
movl %ecx, 0x88(%rax)
cmpl $0x0, 0x88(%rax)
jle 0x27186
movq -0x28(%rbp), %rax
movslq 0x88(%rax), %rdi
shlq $0x3, %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x78(%rax)
movslq 0x88(%rax), %rdi
shlq $0x2, %rdi
callq 0x44f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x80(%rax)
movl $0x0, -0x1c(%rbp)
movq -0x28(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x88(%rcx), %eax
jge 0x27184
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x27a60
movq %rax, %rsi
movq -0x28(%rbp), %rax
movq 0x78(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq -0x10(%rbp), %rcx
movq 0x80(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movq 0x80(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x27122
jmp 0x271a7
movq -0x28(%rbp), %rax
movl $0x0, 0x88(%rax)
movq $0x0, 0x78(%rax)
movq $0x0, 0x80(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x74(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)