// File: /workspace/github_cpp_makefile_star2_O2/pollow[P]MIPSClide/ass.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];
            }
            // -t (coe|plain) -o (outputfilename) -f (filename)
            if ( arg_map.count('t') ) {
                type = arg_map['t'];
            } else {
                type = "plain";
            }
            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.exceptions(fin.failbit);

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

        Assembler A(content);
        A.split();
        A.trim();
        A.format();
        A.calc_label();
        A.parse();
        A.print(type, *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 $0x378, %rsp            # imm = 0x378
leaq -0xa0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x80(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
decl %edi
testb $0x1, %dil
jne 0x85d2
movq %rsi, %rbx
leaq -0x390(%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 -0x398(%rbp), %r14
cmpq %r12, %r13
jge 0x82fe
movq 0x8(%rbx,%r13,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x85a0
movq 0x10(%rbx,%r13,8), %r15
incq %rsi
movq %r14, %rdi
callq 0x877e
movq %rax, %rdi
movq %r15, %rsi
callq 0x55f0
addq $0x2, %r13
jmp 0x82ca
leaq -0x188(%rbp), %rsi
movb $0x74, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x87d0
testq %rax, %rax
je 0x833d
leaq -0x188(%rbp), %rsi
movb $0x74, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x87f4
leaq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x51d0
jmp 0x834d
leaq 0x14cf1(%rip), %rsi     # 0x1d035
leaq -0x50(%rbp), %rdi
callq 0x55f0
leaq -0x188(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x87d0
testq %rax, %rax
je 0x8604
leaq -0x188(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x87f4
leaq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x51d0
leaq -0x188(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x87d0
testq %rax, %rax
je 0x83f3
leaq -0x188(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x87f4
leaq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x51d0
movl $0x200, %edi            # imm = 0x200
callq 0x5320
leaq -0x90(%rbp), %rsi
pushq $0x10
popq %rdx
movq %rax, -0x30(%rbp)
movq %rax, %rdi
callq 0x5600
jmp 0x83fe
movq 0x22bae(%rip), %rax     # 0x2afa8
movq %rax, -0x30(%rbp)
leaq -0x398(%rbp), %rdi
callq 0x8918
leaq -0x398(%rbp), %rbx
leaq -0xb0(%rbp), %rsi
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x54f0
movq -0x398(%rbp), %rax
addq -0x18(%rax), %rbx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x50d0
leaq -0xe0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x60(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %edx, %edx
movb %dl, (%rax)
movb %dl, (%rcx)
leaq -0x398(%rbp), %rbx
leaq -0xf0(%rbp), %r14
leaq 0x150a0(%rip), %r12     # 0x1d511
leaq -0x188(%rbp), %r13
leaq -0x70(%rbp), %r15
movq -0x398(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x378(%rbp,%rax)
jne 0x84bf
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5070
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x8845
movq %r15, %rdi
movq %r13, %rsi
callq 0x5610
movq %r13, %rdi
callq 0x5170
jmp 0x847c
leaq -0x188(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x887e
leaq -0x188(%rbp), %rdi
callq 0xb59c
leaq -0x188(%rbp), %rdi
callq 0xb418
leaq -0x188(%rbp), %rdi
callq 0xb686
leaq -0x188(%rbp), %rdi
callq 0xb286
leaq -0x188(%rbp), %rdi
callq 0x9b1c
leaq -0xd0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5410
leaq -0x188(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xb94c
leaq -0xd0(%rbp), %rdi
callq 0x5170
leaq -0x188(%rbp), %rdi
callq 0x88ce
leaq -0x70(%rbp), %rdi
callq 0x5170
leaq -0xf0(%rbp), %rdi
callq 0x5170
leaq -0x398(%rbp), %rdi
callq 0x5080
leaq -0x90(%rbp), %rdi
callq 0x5170
leaq -0x50(%rbp), %rdi
callq 0x5170
leaq -0xb0(%rbp), %rdi
callq 0x5170
xorl %eax, %eax
addq $0x378, %rsp            # imm = 0x378
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x51a0
movq %rax, %r15
leaq 0x14a65(%rip), %rsi     # 0x1d017
movq %rax, %rdi
callq 0x55d0
movq 0x22a0f(%rip), %rsi     # 0x2afd0
movq 0x229f0(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5520
jmp 0x8634
pushq $0x10
popq %rdi
callq 0x51a0
movq %rax, %r15
leaq 0x14a20(%rip), %rsi     # 0x1d004
movq %rax, %rdi
callq 0x55d0
movq 0x229dd(%rip), %rsi     # 0x2afd0
movq 0x229be(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5520
jmp 0x8634
pushq $0x10
popq %rdi
callq 0x51a0
movq %rax, %r15
leaq 0x14a25(%rip), %rsi     # 0x1d03b
movq %rax, %rdi
callq 0x55d0
movq 0x229ab(%rip), %rsi     # 0x2afd0
movq 0x2298c(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5520
jmp 0x86ac
jmp 0x867d
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x5270
jmp 0x870d
movq %rdx, %rbx
movq %rax, %r14
movq -0x30(%rbp), %rdi
callq 0x52f0
jmp 0x8701
movq %rdx, %rbx
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
callq 0x5170
jmp 0x869c
jmp 0x86d2
movq %rdx, %rbx
movq %rax, %r14
jmp 0x86ed
movq %rdx, %rbx
movq %rax, %r14
jmp 0x870d
jmp 0x86fb
jmp 0x86fb
jmp 0x86fb
jmp 0x86fb
jmp 0x86fb
jmp 0x86fb
jmp 0x86fb
movq %rdx, %rbx
movq %rax, %r14
leaq -0x188(%rbp), %rdi
callq 0x88ce
jmp 0x86d8
jmp 0x86fb
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x5270
jmp 0x8701
movq %rdx, %rbx
movq %rax, %r14
leaq -0x188(%rbp), %rdi
callq 0x5170
jmp 0x86d8
jmp 0x86d2
movq %rdx, %rbx
movq %rax, %r14
leaq -0x70(%rbp), %rdi
callq 0x5170
leaq -0xf0(%rbp), %rdi
callq 0x5170
leaq -0x398(%rbp), %rdi
callq 0x5080
jmp 0x870d
movq %rdx, %rbx
movq %rax, %r14
leaq -0x398(%rbp), %rdi
callq 0x8918
leaq -0x90(%rbp), %rdi
callq 0x5170
leaq -0x50(%rbp), %rdi
callq 0x5170
leaq -0xb0(%rbp), %rdi
callq 0x5170
cmpl $0x1, %ebx
jne 0x876d
movq %r14, %rdi
callq 0x5130
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x228a5(%rip), %rdi     # 0x2aff0
movq %rax, %rsi
callq 0x5310
movq %rax, %rdi
callq 0x5190
callq 0x54e0
jmp 0x858c
movq %rax, %r14
callq 0x54e0
movq %r14, %rdi
callq 0x5570
movq %rax, %rdi
callq 0x8909
nop