// File: /workspace/github_cpp_makefile_star2_O1/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 0x8aca
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 0x87eb
movq %rsi, %rbx
cltq
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 0x8c5c
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
jl 0x879d
movq -0x320(%rbp), %rcx
leaq -0x328(%rbp), %rbx
movq %rbx, %rax
testq %rcx, %rcx
je 0x881b
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 0x8804
movq %rbx, %rcx
cmpq %rbx, %rax
je 0x882e
cmpb $0x67, 0x20(%rax)
cmovgeq %rbx, %rax
movq %rax, %rcx
cmpq %rbx, %rcx
je 0x8afe
leaq -0x120(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x330(%rbp), %rdi
callq 0x8cc4
leaq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
movq -0x320(%rbp), %rcx
movq %rbx, %rax
testq %rcx, %rcx
je 0x8885
movq %rbx, %rax
xorl %edx, %edx
cmpb $0x6f, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x886e
movq %rbx, %rcx
cmpq %rbx, %rax
je 0x8898
cmpb $0x70, 0x20(%rax)
cmovgeq %rbx, %rax
movq %rax, %rcx
cmpq %rbx, %rcx
je 0x88df
leaq -0x120(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x330(%rbp), %rdi
callq 0x8cc4
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
jmp 0x88e6
movq 0x226c2(%rip), %r15     # 0x2afa8
leaq -0x330(%rbp), %rdi
callq 0x8d6c
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 0x924a
jmp 0x895f
leaq -0x118(%rbp), %rdi
movl $0x0, -0x8(%rdi)
leaq -0x50(%rbp), %rsi
callq 0x8e00
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 0x9364
leaq -0x120(%rbp), %rdi
movq %r15, %rsi
callq 0x9c0c
leaq -0x100(%rbp), %rbx
leaq -0xe8(%rbp), %r14
movq %r14, %rdi
callq 0x8eec
movq %rbx, %rdi
callq 0x8e9e
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 0x18526(%rip), %rsi     # 0x21004
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 0x18523(%rip), %rsi     # 0x21035
movq %rax, %rdi
callq 0x55d0
movq 0x224af(%rip), %rsi     # 0x2afd0
movq 0x22490(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5510
jmp 0x8b85
jmp 0x8b61
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x5260
jmp 0x8bc9
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x52d0
jmp 0x8b9b
jmp 0x8ba9
movq %rdx, %r14
movq %rax, %rbx
jmp 0x8bbd
movq %rdx, %r14
movq %rax, %rbx
jmp 0x8bc9
jmp 0x8b95
jmp 0x8b95
movq %rdx, %r14
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x8d2c
jmp 0x8baf
jmp 0x8b95
jmp 0x8b95
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x5260
jmp 0x8b9b
movq %rdx, %r14
movq %rax, %rbx
leaq -0x330(%rbp), %rdi
callq 0x8d6c
jmp 0x8bc9
movq %rdx, %r14
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x8bbd
callq 0x52d0
leaq -0x330(%rbp), %rdi
callq 0x5080
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x8bdb
callq 0x52d0
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x8bf3
callq 0x52d0
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x8c0b
callq 0x52d0
cmpl $0x1, %r14d
jne 0x8c4b
movq %rbx, %rdi
callq 0x5130
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x223c7(%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 0x8d5e
nop