// File: calgagi[P]cp_gen/main.cpp
// Function: main
int main(int argc, char** argv) {
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);

    char cwdBuf[10000];
    string cwd = "";
    if (getcwd(cwdBuf, sizeof(cwdBuf)) == NULL) {
        error("Could not get current working directory");
    } 
    else {
        cwd = cwdBuf;
    }

    // Parse CLI arguments
    vector<string> cliArgs;
    string filename = "";
    for (int i = 1; i < argc; i++) {
        cliArgs.push_back(argv[i]);
        if (cliArgs.back()[0] != '-') {
            // we've found our filename
            filename = cliArgs.back();
            cliArgs.pop_back();
        }
        else {
            // remove leading '-'
            cliArgs.back().erase(cliArgs.back().begin());
        }
    }

    if (filename == "") {
        error("Could not find filename");
    }

    string path = cwd + "/" + filename;
    fstream new_file;
    new_file.open(path, ios_base::out);
    if (!new_file.is_open()) {
        error("Could not open file for output");
    }

    output(new_file, filename, cliArgs);

    return 0;
}

// Assembly:
subq $0x2b18, %rsp           # imm = 0x2B18
movl $0x0, 0x2b14(%rsp)
movl %edi, 0x2b10(%rsp)
movq %rsi, 0x2b08(%rsp)
xorl %edi, %edi
movl %edi, 0x64(%rsp)
callq 0x3100
movl 0x64(%rsp), %eax
movq 0xb949(%rip), %rdi      # 0xffe0
movq (%rdi), %rcx
movq -0x18(%rcx), %rcx
addq %rcx, %rdi
movl %eax, %esi
callq 0x31d0
leaq 0x3cf(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x3430
movq 0x68(%rsp), %rdx
leaq 0x6ac4(%rip), %rsi      # 0xb18a
leaq 0x3d0(%rsp), %rdi
callq 0x4d50
jmp 0x46d5
leaq 0x3cf(%rsp), %rdi
callq 0x32e0
leaq 0x3f0(%rsp), %rdi
movl $0x2710, %esi           # imm = 0x2710
callq 0x3130
cmpq $0x0, %rax
jne 0x47c8
leaq 0x397(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x3430
movq 0x58(%rsp), %rdx
leaq 0x6a6f(%rip), %rsi      # 0xb18b
leaq 0x398(%rsp), %rdi
callq 0x4d50
jmp 0x472b
leaq 0x398(%rsp), %rdi
callq 0x3ae0
jmp 0x473a
leaq 0x398(%rsp), %rdi
callq 0x34a8
leaq 0x397(%rsp), %rdi
callq 0x32e0
jmp 0x47fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
leaq 0x3cf(%rsp), %rdi
callq 0x32e0
jmp 0x4d3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
jmp 0x47b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
leaq 0x398(%rsp), %rdi
callq 0x34a8
leaq 0x397(%rsp), %rdi
callq 0x32e0
jmp 0x4d31
leaq 0x3d0(%rsp), %rdi
leaq 0x3f0(%rsp), %rsi
callq 0x3370
jmp 0x47df
jmp 0x47fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
jmp 0x4d31
leaq 0x378(%rsp), %rdi
callq 0x53b0
leaq 0x357(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x3430
movq 0x50(%rsp), %rdx
leaq 0x6965(%rip), %rsi      # 0xb18a
leaq 0x358(%rsp), %rdi
callq 0x4d50
jmp 0x4834
leaq 0x357(%rsp), %rdi
callq 0x32e0
movl $0x1, 0x350(%rsp)
movl 0x350(%rsp), %eax
cmpl 0x2b10(%rsp), %eax
jge 0x4a43
movq 0x2b08(%rsp), %rax
movslq 0x350(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x40(%rsp)
leaq 0x32f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x3430
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x330(%rsp), %rdi
callq 0x4d50
jmp 0x48a4
leaq 0x378(%rsp), %rdi
leaq 0x330(%rsp), %rsi
callq 0x5890
jmp 0x48bb
leaq 0x330(%rsp), %rdi
callq 0x34a8
leaq 0x32f(%rsp), %rdi
callq 0x32e0
leaq 0x378(%rsp), %rdi
callq 0x58c0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3490
movq %rax, 0x38(%rsp)
jmp 0x48f5
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x49bf
leaq 0x378(%rsp), %rdi
callq 0x58c0
movq %rax, %rsi
leaq 0x358(%rsp), %rdi
callq 0x3040
jmp 0x4925
leaq 0x378(%rsp), %rdi
callq 0x5900
jmp 0x4a2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
leaq 0x357(%rsp), %rdi
callq 0x32e0
jmp 0x4d24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
jmp 0x4994
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
leaq 0x330(%rsp), %rdi
callq 0x34a8
leaq 0x32f(%rsp), %rdi
callq 0x32e0
jmp 0x4d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
jmp 0x4d17
leaq 0x378(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x58c0
movq 0x20(%rsp), %rdi
movq %rax, 0x28(%rsp)
callq 0x58c0
movq %rax, %rdi
callq 0x3210
movq %rax, 0x318(%rsp)
leaq 0x320(%rsp), %rdi
leaq 0x318(%rsp), %rsi
callq 0x5920
movq 0x28(%rsp), %rdi
movq 0x320(%rsp), %rsi
callq 0x3340
movq %rax, 0x30(%rsp)
jmp 0x4a1e
movq 0x30(%rsp), %rax
movq %rax, 0x310(%rsp)
jmp 0x4a2d
movl 0x350(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x350(%rsp)
jmp 0x484c
leaq 0x6740(%rip), %rsi      # 0xb18a
leaq 0x358(%rsp), %rdi
callq 0x5960
movb %al, 0x1f(%rsp)
jmp 0x4a5d
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x4a6a
jmp 0x4b0b
leaq 0x2ef(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x3430
movq 0x10(%rsp), %rdx
leaq 0x672b(%rip), %rsi      # 0xb1b3
leaq 0x2f0(%rsp), %rdi
callq 0x4d50
jmp 0x4a97
leaq 0x2f0(%rsp), %rdi
callq 0x3ae0
jmp 0x4aa6
leaq 0x2f0(%rsp), %rdi
callq 0x34a8
leaq 0x2ef(%rsp), %rdi
callq 0x32e0
jmp 0x4b0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
jmp 0x4af9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
leaq 0x2f0(%rsp), %rdi
callq 0x34a8
leaq 0x2ef(%rsp), %rdi
callq 0x32e0
jmp 0x4d17
leaq 0x6596(%rip), %rdx      # 0xb0a8
leaq 0x2a8(%rsp), %rdi
leaq 0x3d0(%rsp), %rsi
callq 0x59e0
jmp 0x4b29
leaq 0x2c8(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
leaq 0x358(%rsp), %rdx
callq 0x5990
jmp 0x4b48
leaq 0x2a8(%rsp), %rdi
callq 0x34a8
leaq 0x98(%rsp), %rdi
callq 0x3310
jmp 0x4b64
leaq 0x98(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
movl $0x10, %edx
callq 0x3380
jmp 0x4b80
leaq 0x98(%rsp), %rdi
callq 0x3410
movb %al, 0xf(%rsp)
jmp 0x4b93
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x4c83
jmp 0x4ba1
leaq 0x77(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x3430
movq (%rsp), %rdx
leaq 0x6611(%rip), %rsi      # 0xb1cb
leaq 0x78(%rsp), %rdi
callq 0x4d50
jmp 0x4bc6
leaq 0x78(%rsp), %rdi
callq 0x3ae0
jmp 0x4bd2
leaq 0x78(%rsp), %rdi
callq 0x34a8
leaq 0x77(%rsp), %rdi
callq 0x32e0
jmp 0x4c83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x34a8
jmp 0x4d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
jmp 0x4d0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
jmp 0x4cfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
jmp 0x4c77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x34a8
leaq 0x77(%rsp), %rdi
callq 0x32e0
jmp 0x4cfd
leaq 0x98(%rsp), %rdi
leaq 0x358(%rsp), %rsi
leaq 0x378(%rsp), %rdx
callq 0x4510
jmp 0x4ca2
movl $0x0, 0x2b14(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x3090
leaq 0x2c8(%rsp), %rdi
callq 0x34a8
leaq 0x358(%rsp), %rdi
callq 0x34a8
leaq 0x378(%rsp), %rdi
callq 0x50a0
leaq 0x3d0(%rsp), %rdi
callq 0x34a8
movl 0x2b14(%rsp), %eax
addq $0x2b18, %rsp           # imm = 0x2B18
retq
leaq 0x98(%rsp), %rdi
callq 0x3090
leaq 0x2c8(%rsp), %rdi
callq 0x34a8
leaq 0x358(%rsp), %rdi
callq 0x34a8
leaq 0x378(%rsp), %rdi
callq 0x50a0
leaq 0x3d0(%rsp), %rdi
callq 0x34a8
movq 0x3c0(%rsp), %rdi
callq 0x3420
nopl (%rax,%rax)