// File: /workspace/github_cpp_makefile_star2_O3/pollow[P]MIPSClide/dis.cpp
// Function: main
int main(int argc, char *argv[]) {
    try {
        string filename, type, outputfile;
        ostream *out;
        argv++;
        argc--;
        if ( argc % 2 ) {
            throw invalid_argument("Invalid 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];
            }
            // -o (outputfilename) -f (filename)
            if ( arg_map.count('f') ) {
                filename = arg_map['f'];
            } else {
                throw invalid_argument("File should be specified with -f filename.");
            }
            if ( arg_map.count('o') ) {
                outputfile = arg_map['o'];
                out = new ofstream(outputfile, ios::out);
            } else {
                out = &cout;
            }
        }

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

        unsigned int a = 0;
        vector<unsigned int> inst;
        while(fin >> a) {
            inst.push_back(a);
        }
        Disassembler D(inst);
        D.reverse();
        D.print(*out);

    } 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 $0x308, %rsp            # imm = 0x308
leaq -0x88(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xa8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x68(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leal -0x1(%rdi), %eax
testb $0x1, %al
jne 0x8afe
leaq -0x328(%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 0x8aca
movq %rsi, %rbx
movl %eax, %eax
movq %rax, -0x58(%rbp)
xorl %r14d, %r14d
movq 0x8(%rbx,%r14,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x8a96
movq 0x10(%rbx,%r14,8), %r15
incq %rsi
leaq -0x330(%rbp), %rdi
callq 0x8c58
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 0x5460
addq $0x2, %r14
cmpq -0x58(%rbp), %r14
jb 0x8791
movq -0x320(%rbp), %rsi
testq %rsi, %rsi
leaq -0x328(%rbp), %rbx
je 0x8aca
movq %rbx, %rdi
movq %rdi, %rax
movq %rsi, %rcx
movb 0x20(%rsi), %dl
xorl %esi, %esi
cmpb $0x66, %dl
setl %sil
movq %rcx, %rdi
cmovlq %rax, %rdi
movq 0x10(%rcx,%rsi,8), %rsi
testq %rsi, %rsi
jne 0x87f9
cmpq %rbx, %rdi
je 0x8aca
cmpb $0x66, %dl
cmovlq %rax, %rcx
cmpb $0x66, 0x20(%rcx)
jg 0x8aca
leaq -0x120(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x330(%rbp), %rdi
callq 0x8cc0
leaq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
movq -0x320(%rbp), %rsi
movq 0x2273f(%rip), %r15     # 0x2afa8
testq %rsi, %rsi
je 0x88e6
movq %rbx, %rdi
movq %rdi, %rax
movq %rsi, %rcx
movb 0x20(%rsi), %dl
xorl %esi, %esi
cmpb $0x6f, %dl
setl %sil
movq %rcx, %rdi
cmovlq %rax, %rdi
movq 0x10(%rcx,%rsi,8), %rsi
testq %rsi, %rsi
jne 0x8871
cmpq %rbx, %rdi
je 0x88e6
cmpb $0x6f, %dl
cmovlq %rax, %rcx
cmpb $0x6f, 0x20(%rcx)
jg 0x88e6
leaq -0x120(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x330(%rbp), %rdi
callq 0x8cc0
leaq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
movl $0x200, %edi            # imm = 0x200
callq 0x5310
movq %rax, %r15
leaq -0x78(%rbp), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x55f0
leaq -0x330(%rbp), %rdi
callq 0x8d68
leaq -0x330(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movl $0x8, %edx
callq 0x54d0
movq -0x330(%rbp), %rax
movq -0x18(%rax), %rcx
andl $-0x4b, -0x318(%rbp,%rcx)
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x330, %rdi           # imm = 0xFCD0
movl $0x4, 0x1c(%rdi)
movl 0x20(%rdi), %esi
callq 0x5500
leaq -0x2c(%rbp), %rbx
movl $0x0, (%rbx)
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %r14
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
leaq -0x330(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5550
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x899e
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x8991
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x48(%rbp)
jmp 0x895f
movq %r14, %rdi
movq %rbx, %rdx
callq 0x9244
jmp 0x895f
leaq -0x118(%rbp), %rdi
movl $0x0, -0x8(%rdi)
leaq -0x50(%rbp), %rsi
callq 0x8dfc
xorps %xmm0, %xmm0
leaq -0xe0(%rbp), %rax
movups %xmm0, -0x20(%rax)
xorl %ecx, %ecx
movq %rcx, -0x10(%rax)
movl $0x0, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq -0x120(%rbp), %rdi
callq 0x9360
leaq -0x120(%rbp), %rdi
movq %r15, %rsi
callq 0x9bc4
leaq -0x100(%rbp), %rbx
leaq -0xe8(%rbp), %r14
movq %r14, %rdi
callq 0x8ef2
movq %rbx, %rdi
callq 0x8e9a
movq -0x30(%r14), %rdi
testq %rdi, %rdi
je 0x8a26
callq 0x52d0
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x8a34
callq 0x52d0
leaq -0x330(%rbp), %rdi
callq 0x5080
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x8a52
callq 0x52d0
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x8a6a
callq 0x52d0
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x8a82
callq 0x52d0
xorl %eax, %eax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x1856d(%rip), %rsi     # 0x21017
movq %rax, %rdi
callq 0x55d0
movq 0x22517(%rip), %rsi     # 0x2afd0
movq 0x224f8(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5510
jmp 0x8b30
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x18557(%rip), %rsi     # 0x21035
movq %rax, %rdi
callq 0x55d0
movq 0x224e3(%rip), %rsi     # 0x2afd0
movq 0x224c4(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5510
jmp 0x8b30
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x184f2(%rip), %rsi     # 0x21004
movq %rax, %rdi
callq 0x55d0
movq 0x224af(%rip), %rsi     # 0x2afd0
movq 0x22490(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5510
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x52d0
jmp 0x8bba
jmp 0x8bb4
jmp 0x8b5e
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x5260
jmp 0x8bc6
jmp 0x8b92
movq %rdx, %r14
movq %rax, %rbx
jmp 0x8ba6
movq %rdx, %r14
movq %rax, %rbx
jmp 0x8bc6
movq %rdx, %r14
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x8d28
jmp 0x8b98
jmp 0x8bb4
jmp 0x8b82
jmp 0x8bb4
jmp 0x8bb4
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x5260
jmp 0x8bba
movq %rdx, %r14
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x8ba6
callq 0x52d0
leaq -0x330(%rbp), %rdi
callq 0x5080
jmp 0x8bc6
movq %rdx, %r14
movq %rax, %rbx
leaq -0x330(%rbp), %rdi
callq 0x8d68
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x8bd8
callq 0x52d0
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x8bf0
callq 0x52d0
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x8c08
callq 0x52d0
cmpl $0x1, %r14d
jne 0x8c48
movq %rbx, %rdi
callq 0x5130
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x223ca(%rip), %rdi     # 0x2aff0
movq %rax, %rsi
callq 0x5300
movq %rax, %rdi
callq 0x5170
callq 0x54c0
jmp 0x8a82
movq %rax, %rbx
callq 0x54c0
movq %rbx, %rdi
callq 0x5560
movq %rax, %rdi
callq 0x8d5a