// File: /workspace/github_cpp_makefile_star2_O1/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 -0xc0(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x40(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xa0(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leal -0x1(%rdi), %eax
movl %eax, -0x30(%rbp)
testb $0x1, %al
jne 0x8c7c
leaq -0x390(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
cmpl $0x2, %edi
jl 0x87c8
movq %rsi, %rbx
xorl %r14d, %r14d
movq 0x8(%rbx,%r14,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x8c48
movq 0x10(%rbx,%r14,8), %r15
incq %rsi
leaq -0x398(%rbp), %rdi
callq 0x8e7e
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
cmpl %r14d, -0x30(%rbp)
jg 0x877a
movq -0x388(%rbp), %rcx
leaq -0x390(%rbp), %rbx
movq %rbx, %rax
testq %rcx, %rcx
je 0x87f8
movq %rbx, %rax
xorl %edx, %edx
cmpb $0x74, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x87e1
movq %rbx, %rcx
cmpq %rbx, %rax
je 0x880b
cmpb $0x75, 0x20(%rax)
cmovgeq %rbx, %rax
movq %rax, %rcx
cmpq %rbx, %rcx
je 0x8834
leaq -0x168(%rbp), %rsi
movb $0x74, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x8ee6
leaq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
jmp 0x8850
leaq -0x50(%rbp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x187f2(%rip), %rcx     # 0x21035
movl $0x5, %r8d
xorl %esi, %esi
callq 0x5460
movq -0x388(%rbp), %rcx
movq %rbx, %rax
testq %rcx, %rcx
je 0x8879
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 0x8862
movq %rbx, %rcx
cmpq %rbx, %rax
je 0x888c
cmpb $0x67, 0x20(%rax)
cmovgeq %rbx, %rax
movq %rax, %rcx
cmpq %rbx, %rcx
je 0x8cb0
leaq -0x168(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x8ee6
leaq -0xd0(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
movq -0x388(%rbp), %rcx
movq %rbx, %rax
testq %rcx, %rcx
je 0x88e3
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 0x88cc
movq %rbx, %rcx
cmpq %rbx, %rax
je 0x88f6
cmpb $0x70, 0x20(%rax)
cmovgeq %rbx, %rax
movq %rax, %rcx
cmpq %rbx, %rcx
je 0x8944
leaq -0x168(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x8ee6
leaq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
movl $0x200, %edi            # imm = 0x200
callq 0x5310
leaq -0xb0(%rbp), %rsi
movq %rax, -0x30(%rbp)
movq %rax, %rdi
movl $0x10, %edx
callq 0x55f0
jmp 0x894f
movq 0x2265d(%rip), %rax     # 0x2afa8
movq %rax, -0x30(%rbp)
leaq -0x398(%rbp), %rdi
callq 0x8fa8
leaq -0x398(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x8, %edx
callq 0x54d0
movq -0x398(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x398, %rdi           # imm = 0xFC68
movl $0x4, 0x1c(%rdi)
movl 0x20(%rdi), %esi
callq 0x5500
leaq -0x80(%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)
movq -0x398(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x378(%rbp,%rax)
jne 0x8a92
leaq (%rax,%rbp), %rdi
addq $-0x398, %rdi           # imm = 0xFC68
leaq -0x398(%rbp), %rbx
leaq -0x90(%rbp), %r14
leaq -0x168(%rbp), %r12
leaq 0x18b21(%rip), %r13     # 0x21517
leaq -0x70(%rbp), %r15
movl $0xa, %esi
callq 0x52f0
movsbl %al, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5590
leaq -0x158(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x913a
movq %r12, %rdi
movq %r13, %rsi
callq 0x55e0
movq -0x168(%rbp), %rsi
movq -0x160(%rbp), %rdx
movq %r15, %rdi
callq 0x50c0
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x8a72
callq 0x52d0
movq -0x398(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x398, %rdi           # imm = 0xFC68
testb $0x2, 0x20(%rdi)
je 0x89fa
leaq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
movq %rax, (%rdi)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
callq 0x913a
leaq -0xf8(%rbp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x50(%rax)
movups %xmm0, -0x40(%rax)
movups %xmm0, -0x30(%rax)
movups %xmm0, -0x20(%rax)
movq %rcx, -0x10(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq -0x168(%rbp), %rdi
callq 0xce70
leaq -0x168(%rbp), %rdi
callq 0xcc82
leaq -0x168(%rbp), %rdi
callq 0xcf90
leaq -0x168(%rbp), %rdi
callq 0xca70
leaq -0x168(%rbp), %rdi
callq 0xa59c
leaq -0x178(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x188(%rbp), %rdi
callq 0x913a
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xd36e
movq -0x188(%rbp), %rdi
cmpq %r15, %rdi
je 0x8b6f
callq 0x52d0
leaq -0x148(%rbp), %rbx
leaq -0x100(%rbp), %r14
movq %r14, %rdi
callq 0x90d0
movq -0x18(%r14), %rdi
testq %rdi, %rdi
je 0x8b93
callq 0x52d0
leaq -0x130(%rbp), %r14
movq %r14, %rdi
callq 0x903c
movq %rbx, %rdi
callq 0x9082
movq -0x38(%r14), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x8bbf
callq 0x52d0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x8bd1
callq 0x52d0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x8be6
callq 0x52d0
leaq -0x398(%rbp), %rdi
callq 0x5080
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x8c0a
callq 0x52d0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x8c1c
callq 0x52d0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x8c34
callq 0x52d0
xorl %eax, %eax
addq $0x378, %rsp            # imm = 0x378
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x183bb(%rip), %rsi     # 0x21017
movq %rax, %rdi
callq 0x55d0
movq 0x22365(%rip), %rsi     # 0x2afd0
movq 0x22346(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5510
jmp 0x8ce2
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x18374(%rip), %rsi     # 0x21004
movq %rax, %rdi
callq 0x55d0
movq 0x22331(%rip), %rsi     # 0x2afd0
movq 0x22312(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5510
jmp 0x8ce2
movl $0x10, %edi
callq 0x5180
movq %rax, %r15
leaq 0x18377(%rip), %rsi     # 0x2103b
movq %rax, %rdi
callq 0x55d0
movq 0x222fd(%rip), %rsi     # 0x2afd0
movq 0x222de(%rip), %rdx     # 0x2afb8
movq %r15, %rdi
callq 0x5510
jmp 0x8d6b
jmp 0x8d36
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x5260
jmp 0x8dec
movq %rdx, %rbx
movq %rax, %r14
movq -0x30(%rbp), %rdi
callq 0x52d0
jmp 0x8de0
movq %rdx, %rbx
movq %rax, %r14
movq -0x188(%rbp), %rdi
cmpq %r15, %rdi
je 0x8d5b
callq 0x52d0
jmp 0x8d5b
jmp 0x8d9f
movq %rdx, %rbx
movq %rax, %r14
jmp 0x8dcc
movq %rdx, %rbx
movq %rax, %r14
jmp 0x8dec
jmp 0x8dda
jmp 0x8dda
jmp 0x8dda
jmp 0x8dda
movq %rdx, %rbx
movq %rax, %r14
leaq -0x168(%rbp), %rdi
callq 0x8f4e
jmp 0x8da5
jmp 0x8dda
movq %rdx, %rbx
movq %rax, %r14
movq %r15, %rdi
callq 0x5260
jmp 0x8de0
jmp 0x8d9f
jmp 0x8d7f
movq %rdx, %rbx
movq %rax, %r14
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x8da5
callq 0x52d0
jmp 0x8da5
movq %rdx, %rbx
movq %rax, %r14
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x8db7
callq 0x52d0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x8dcc
callq 0x52d0
leaq -0x398(%rbp), %rdi
callq 0x5080
jmp 0x8dec
movq %rdx, %rbx
movq %rax, %r14
leaq -0x398(%rbp), %rdi
callq 0x8fa8
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x8e04
callq 0x52d0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x8e16
callq 0x52d0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x8e2e
callq 0x52d0
cmpl $0x1, %ebx
jne 0x8e6d
movq %r14, %rdi
callq 0x5130
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x221a5(%rip), %rdi     # 0x2aff0
movq %rax, %rsi
callq 0x5300
movq %rax, %rdi
callq 0x5170
callq 0x54c0
jmp 0x8c34
movq %rax, %r14
callq 0x54c0
movq %r14, %rdi
callq 0x5560
movq %rax, %rdi
callq 0x8f9a
nop