// File: /workspace/github_cpp_makefile_star2_O2/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 -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0xa0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x60(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
decl %edi
testb $0x1, %dil
jne 0x84d2
movq %rsi, %rbx
leaq -0x320(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movslq %edi, %r12
xorl %r13d, %r13d
leaq -0x328(%rbp), %r14
cmpq %r12, %r13
jge 0x82ee
movq 0x8(%rbx,%r13,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x84a0
movq 0x10(%rbx,%r13,8), %r15
incq %rsi
movq %r14, %rdi
callq 0x863e
movq %rax, %rdi
movq %r15, %rsi
callq 0x55e0
addq $0x2, %r13
jmp 0x82ba
leaq -0x118(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x328(%rbp), %rdi
callq 0x8690
testq %rax, %rax
je 0x8504
leaq -0x118(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x328(%rbp), %rdi
callq 0x86b4
leaq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x51c0
leaq -0x118(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x328(%rbp), %rdi
callq 0x8690
testq %rax, %rax
je 0x838d
leaq -0x118(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x328(%rbp), %rdi
callq 0x86b4
leaq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x51c0
movl $0x200, %edi            # imm = 0x200
callq 0x5310
movq %rax, %r15
leaq -0x70(%rbp), %rsi
pushq $0x10
popq %rdx
movq %rax, %rdi
callq 0x55f0
jmp 0x8394
movq 0x21c14(%rip), %r15     # 0x29fa8
leaq -0x328(%rbp), %rdi
callq 0x87aa
leaq -0x328(%rbp), %rbx
leaq -0x90(%rbp), %rsi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x54e0
movq -0x328(%rbp), %rax
movq -0x18(%rax), %rcx
andl $-0x4b, -0x310(%rbp,%rcx)
addq -0x18(%rax), %rbx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x50c0
leaq -0x2c(%rbp), %rbx
andl $0x0, (%rbx)
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq -0x328(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5540
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x841f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8706
jmp 0x83f9
leaq -0x118(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x872c
leaq -0x118(%rbp), %rdi
callq 0x8eb8
leaq -0x118(%rbp), %rdi
movq %r15, %rsi
callq 0x92a0
leaq -0x118(%rbp), %rdi
callq 0x876e
leaq -0x50(%rbp), %rdi
callq 0x887a
leaq -0x328(%rbp), %rdi
callq 0x5070
leaq -0x70(%rbp), %rdi
callq 0x5160
leaq -0xb0(%rbp), %rdi
callq 0x5160
leaq -0x90(%rbp), %rdi
callq 0x5160
xorl %eax, %eax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x5190
movq %rax, %r15
leaq 0x13b65(%rip), %rsi     # 0x1c017
movq %rax, %rdi
callq 0x55c0
movq 0x21b0f(%rip), %rsi     # 0x29fd0
movq 0x21af0(%rip), %rdx     # 0x29fb8
movq %r15, %rdi
callq 0x5510
jmp 0x8534
pushq $0x10
popq %rdi
callq 0x5190
movq %rax, %r15
leaq 0x13b20(%rip), %rsi     # 0x1c004
movq %rax, %rdi
callq 0x55c0
movq 0x21add(%rip), %rsi     # 0x29fd0
movq 0x21abe(%rip), %rdx     # 0x29fb8
movq %r15, %rdi
callq 0x5510
jmp 0x8534
pushq $0x10
popq %rdi
callq 0x5190
movq %rax, %r15
leaq 0x13b1f(%rip), %rsi     # 0x1c035
movq %rax, %rdi
callq 0x55c0
movq 0x21aab(%rip), %rsi     # 0x29fd0
movq 0x21a8c(%rip), %rdx     # 0x29fb8
movq %r15, %rdi
callq 0x5510
jmp 0x858d
jmp 0x8565
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x5260
jmp 0x85cc
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x52e0
jmp 0x85a3
jmp 0x85b1
movq %rdx, %r14
movq %rax, %rbx
jmp 0x85c0
movq %rdx, %r14
movq %rax, %rbx
jmp 0x85cc
jmp 0x859d
jmp 0x859d
jmp 0x859d
jmp 0x859d
movq %rdx, %r14
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x876e
jmp 0x85b7
jmp 0x859d
jmp 0x859d
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0x5260
jmp 0x85a3
movq %rdx, %r14
movq %rax, %rbx
leaq -0x328(%rbp), %rdi
callq 0x87aa
jmp 0x85cc
movq %rdx, %r14
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x887a
leaq -0x328(%rbp), %rdi
callq 0x5070
leaq -0x70(%rbp), %rdi
callq 0x5160
leaq -0xb0(%rbp), %rdi
callq 0x5160
leaq -0x90(%rbp), %rdi
callq 0x5160
cmpl $0x1, %r14d
jne 0x862d
movq %rbx, %rdi
callq 0x5120
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x219e5(%rip), %rdi     # 0x29ff0
movq %rax, %rsi
callq 0x5300
movq %rax, %rdi
callq 0x5180
callq 0x54d0
jmp 0x848c
movq %rax, %rbx
callq 0x54d0
movq %rbx, %rdi
callq 0x5560
movq %rax, %rdi
callq 0x879b
nop