// File: /workspace/github_cpp_makefile_star2_O1/pollow[P]MIPSClide/sim.cpp
// Function: main
int main(int argc, char **argv) {
    try {
        string filename, mode;
        argv++;
        argc--;
        if ( argc % 2 ) {
            throw invalid_argument("Lack of Arguments!");
        } else {
            map<char, string> arg_map;
            for (int i = 0; i < argc; i+=2) {
                if (argv[i][0] != '-') {
                    throw invalid_argument("Option should start with '-'!");
                }
                arg_map[argv[i][1]] = argv[i+1];
            }
            // -m (run|debug) -f (filename)
            if ( arg_map.count('m') ) {
                mode = arg_map['m'];
            } else {
                throw invalid_argument("Mode should be specified with -m (run|debug).");
            }
            if ( arg_map.count('f') ) {
                filename = arg_map['f'];
            } else {
                throw invalid_argument("File should be specified with -f filename.");
            }
        }

        fstream fin(filename, ios::in);
        fin.exceptions(fin.failbit);

        string ins, content;
        while(!fin.eof()) {
            getline(fin, ins);
            content += ins + "\n";
        }

        Simulator sim(content);
        sim.init();

        if ( mode == "run" ) {
            sim.run();
        } else if ( mode == "debug" ) {
            sim.debug();
        } else {
            throw invalid_argument("Mode should be specified with -m (run|debug).");
        }
    } catch (exception &err) {
        cerr << err.what() << endl;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
leaq -0xa0(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x60(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leal -0x1(%rdi), %eax
testb $0x1, %al
jne 0x8ff1
leaq -0x428(%rbp), %rdx
movl $0x0, (%rdx)
xorl %ecx, %ecx
movq %rcx, 0x8(%rdx)
movq %rdx, 0x10(%rdx)
movq %rdx, 0x18(%rdx)
movq %rcx, 0x20(%rdx)
cmpl $0x2, %edi
jl 0x8c6a
movq %rsi, %rbx
cltq
movq %rax, -0x30(%rbp)
xorl %r14d, %r14d
movq 0x8(%rbx,%r14,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x8fba
movq 0x10(%rbx,%r14,8), %r15
incq %rsi
leaq -0x430(%rbp), %rdi
callq 0x920a
movq %rax, %r12
movq 0x8(%rax), %r13
movq %r15, %rdi
callq 0x5150
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x5470
addq $0x2, %r14
cmpq -0x30(%rbp), %r14
jl 0x8c1c
movq -0x420(%rbp), %rcx
leaq -0x428(%rbp), %rbx
movq %rbx, %rax
testq %rcx, %rcx
je 0x8c9a
movq %rbx, %rax
xorl %edx, %edx
cmpb $0x6d, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x8c83
movq %rbx, %rcx
cmpq %rbx, %rax
je 0x8cad
cmpb $0x6e, 0x20(%rax)
cmovgeq %rbx, %rax
movq %rax, %rcx
cmpq %rbx, %rcx
je 0x9028
leaq -0x220(%rbp), %rsi
movb $0x6d, (%rsi)
leaq -0x430(%rbp), %rdi
callq 0x9272
leaq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
movq -0x420(%rbp), %rcx
movq %rbx, %rax
testq %rcx, %rcx
je 0x8d01
movq %rbx, %rax
xorl %edx, %edx
cmpb $0x66, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x8cea
movq %rbx, %rcx
cmpq %rbx, %rax
je 0x8d14
cmpb $0x67, 0x20(%rax)
cmovgeq %rbx, %rax
movq %rax, %rcx
cmpq %rbx, %rcx
je 0x9046
leaq -0x220(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x430(%rbp), %rdi
callq 0x9272
leaq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
leaq -0x430(%rbp), %rdi
callq 0x9ae0
leaq -0x430(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movl $0x8, %edx
callq 0x54e0
movq -0x430(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x430, %rdi           # imm = 0xFBD0
movl $0x4, 0x1c(%rdi)
movl 0x20(%rdi), %esi
callq 0x5510
leaq -0x40(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x80(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq -0x430(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x410(%rbp,%rax)
jne 0x8e7f
leaq (%rax,%rbp), %rdi
addq $-0x430, %rdi           # imm = 0xFBD0
leaq -0x430(%rbp), %rbx
leaq -0x50(%rbp), %r14
leaq -0x220(%rbp), %r15
leaq 0x1a7d5(%rip), %r12     # 0x235bb
leaq -0x90(%rbp), %r13
movl $0xa, %esi
callq 0x52f0
movsbl %al, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x55a0
leaq -0x210(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x9c8e
movq %r15, %rdi
movq %r12, %rsi
callq 0x55f0
movq -0x220(%rbp), %rsi
movq -0x218(%rbp), %rdx
movq %r13, %rdi
callq 0x50c0
movq -0x220(%rbp), %rdi
leaq -0x210(%rbp), %rax
cmpq %rax, %rdi
je 0x8e5f
callq 0x52d0
movq -0x430(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x430, %rdi           # imm = 0xFBD0
testb $0x2, 0x20(%rdi)
je 0x8ded
leaq -0x220(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x92da
leaq -0x220(%rbp), %rdi
callq 0xb064
leaq 0x1a1e9(%rip), %rsi     # 0x2308e
leaq -0x70(%rbp), %rdi
callq 0x50b0
testl %eax, %eax
je 0x8ed8
leaq 0x1a1d9(%rip), %rsi     # 0x23092
leaq -0x70(%rbp), %rdi
callq 0x50b0
testl %eax, %eax
jne 0x9078
leaq -0x220(%rbp), %rdi
callq 0xacd2
jmp 0x8ee4
leaq -0x220(%rbp), %rdi
callq 0xa558
leaq -0xe0(%rbp), %rdi
callq 0xa14a
leaq -0x180(%rbp), %rdi
callq 0x9bf4
leaq -0x1b8(%rbp), %rbx
movq %rbx, %rdi
callq 0xa1fa
movq -0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x8f19
callq 0x52d0
leaq -0x1e8(%rbp), %rdi
callq 0xa1b4
leaq -0x200(%rbp), %rbx
movq %rbx, %rdi
callq 0x9bf4
movq -0x20(%rbx), %rdi
leaq -0x210(%rbp), %rax
cmpq %rax, %rdi
je 0x8f49
callq 0x52d0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x8f5e
callq 0x52d0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x8f70
callq 0x52d0
leaq -0x430(%rbp), %rdi
callq 0x5080
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x8f8e
callq 0x52d0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x8fa6
callq 0x52d0
xorl %eax, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x1a049(%rip), %rsi     # 0x23017
movq %rax, %rdi
callq 0x55e0
movq 0x24fe3(%rip), %rsi     # 0x2dfc0
movq 0x24fc4(%rip), %rdx     # 0x2dfa8
movq %r15, %rdi
callq 0x5520
jmp 0x90aa
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x19fff(%rip), %rsi     # 0x23004
movq %rax, %rdi
callq 0x55e0
movq 0x24fac(%rip), %rsi     # 0x2dfc0
movq 0x24f8d(%rip), %rdx     # 0x2dfa8
movq %r15, %rdi
callq 0x5520
jmp 0x90aa
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x19ff9(%rip), %rsi     # 0x23035
movq %rax, %rdi
callq 0x55e0
jmp 0x9062
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x1a009(%rip), %rsi     # 0x23063
movq %rax, %rdi
callq 0x55e0
movq 0x24f57(%rip), %rsi     # 0x2dfc0
movq 0x24f38(%rip), %rdx     # 0x2dfa8
movq %r15, %rdi
callq 0x5520
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x19fa9(%rip), %rsi     # 0x23035
movq %rax, %rdi
callq 0x55e0
movq 0x24f25(%rip), %rsi     # 0x2dfc0
movq 0x24f06(%rip), %rdx     # 0x2dfa8
movq %r15, %rdi
callq 0x5520
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x5260
jmp 0x9100
jmp 0x9110
jmp 0x9110
jmp 0x90e0
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x5260
jmp 0x9191
jmp 0x9144
movq %rdx, %rbx
movq %rax, %r14
jmp 0x9171
movq %rdx, %rbx
movq %rax, %r14
jmp 0x9191
jmp 0x917f
jmp 0x917f
jmp 0x917f
movq %rdx, %rbx
movq %rax, %r14
leaq -0x220(%rbp), %rdi
callq 0x9a6e
jmp 0x914a
jmp 0x917f
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x5260
jmp 0x9185
jmp 0x9144
jmp 0x9124
movq %rdx, %rbx
movq %rax, %r14
movq -0x220(%rbp), %rdi
leaq -0x210(%rbp), %rax
cmpq %rax, %rdi
je 0x914a
callq 0x52d0
jmp 0x914a
movq %rdx, %rbx
movq %rax, %r14
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x915f
callq 0x52d0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x9171
callq 0x52d0
leaq -0x430(%rbp), %rdi
callq 0x5080
jmp 0x9191
movq %rdx, %rbx
movq %rax, %r14
leaq -0x430(%rbp), %rdi
callq 0x9ae0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x91a3
callq 0x52d0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x91bb
callq 0x52d0
cmpl $0x1, %ebx
jne 0x91fa
movq %r14, %rdi
callq 0x5130
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x24e10(%rip), %rdi     # 0x2dfe8
movq %rax, %rsi
callq 0x5300
movq %rax, %rdi
callq 0x5170
callq 0x54d0
jmp 0x8fa6
movq %rax, %r14
callq 0x54d0
movq %r14, %rdi
callq 0x5570
movq %rax, %rdi
callq 0x9ad2