// File: /workspace/github_cpp_makefile_star2_O3/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 -0x60(%rbp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq -0x40(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xc0(%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 0x8ce3
leaq -0x390(%rbp), %r12
movl $0x0, (%r12)
xorl %eax, %eax
movq %rax, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
movq %rax, 0x20(%r12)
cmpl $0x2, %edi
jl 0x8823
movq %rsi, %rbx
xorl %r14d, %r14d
movq 0x8(%rbx,%r14,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x8c7b
movq 0x10(%rbx,%r14,8), %r15
incq %rsi
leaq -0x398(%rbp), %rdi
callq 0x8ec0
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 0x8782
movq -0x388(%rbp), %rsi
testq %rsi, %rsi
leaq -0x60(%rbp), %r15
leaq -0x390(%rbp), %r12
je 0x8823
movq %r12, %rdi
movq %rdi, %rax
movq %rsi, %rcx
movb 0x20(%rsi), %dl
xorl %esi, %esi
cmpb $0x74, %dl
setl %sil
movq %rcx, %rdi
cmovlq %rax, %rdi
movq 0x10(%rcx,%rsi,8), %rsi
testq %rsi, %rsi
jne 0x87ea
cmpq %r12, %rdi
je 0x8823
cmpb $0x74, %dl
cmovlq %rax, %rcx
cmpb $0x74, 0x20(%rcx)
jle 0x8c54
leaq -0x50(%rbp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x18803(%rip), %rcx     # 0x21035
movl $0x5, %r8d
xorl %esi, %esi
callq 0x5460
movq -0x388(%rbp), %rsi
testq %rsi, %rsi
je 0x8caf
movq %r12, %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 0x8852
cmpq %r12, %rdi
je 0x8caf
cmpb $0x66, %dl
cmovlq %rax, %rcx
cmpb $0x66, 0x20(%rcx)
jg 0x8caf
leaq -0x168(%rbp), %rsi
movb $0x66, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x8f28
leaq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
movq -0x388(%rbp), %rsi
movq 0x226e9(%rip), %r14     # 0x2afa8
testq %rsi, %rsi
je 0x8942
movq %r12, %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 0x88c7
cmpq %r12, %rdi
je 0x8942
cmpb $0x6f, %dl
cmovlq %rax, %rcx
cmpb $0x6f, 0x20(%rcx)
jg 0x8942
leaq -0x168(%rbp), %rsi
movb $0x6f, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x8f28
leaq -0xd0(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
movl $0x200, %edi            # imm = 0x200
callq 0x5310
movq %rax, %r14
leaq -0xd0(%rbp), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x55f0
leaq -0x398(%rbp), %rdi
callq 0x8fea
leaq -0x398(%rbp), %rdi
leaq -0x70(%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 -0xa0(%rbp), %r12
movq %r12, -0x10(%r12)
xorl %edx, %edx
movq %rdx, -0x8(%r12)
movb %dl, (%r12)
leaq -0x80(%rbp), %r13
movq %r13, -0x10(%r13)
movq %rdx, -0x8(%r13)
movb %dl, (%r13)
movq -0x398(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x378(%rbp,%rax)
movq %r13, %rsi
jne 0x8ab6
movq %r14, -0x30(%rbp)
leaq (%rax,%rbp), %rdi
addq $-0x398, %rdi           # imm = 0xFC68
leaq -0x398(%rbp), %r14
leaq -0xb0(%rbp), %r15
leaq -0x168(%rbp), %r12
leaq 0x18b21(%rip), %r13     # 0x21517
leaq -0x90(%rbp), %rbx
movl $0xa, %esi
callq 0x52f0
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x5590
leaq -0x158(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x9190
movq %r12, %rdi
movq %r13, %rsi
callq 0x55e0
movq -0x168(%rbp), %rsi
movq -0x160(%rbp), %rdx
movq %rbx, %rdi
callq 0x50c0
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x8a75
callq 0x52d0
movq -0x398(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x398, %rdi           # imm = 0xFC68
testb $0x2, 0x20(%rdi)
je 0x89fd
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
leaq -0x60(%rbp), %r15
leaq -0xa0(%rbp), %r12
leaq -0x80(%rbp), %r13
movq -0x30(%rbp), %r14
leaq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
movq %rax, (%rdi)
addq %rsi, %rdx
callq 0x9190
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 0xcf22
leaq -0x168(%rbp), %rdi
callq 0xcd34
leaq -0x168(%rbp), %rdi
callq 0xd046
leaq -0x168(%rbp), %rdi
callq 0xcb22
leaq -0x168(%rbp), %rdi
callq 0xa5a0
leaq -0x178(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x188(%rbp), %rdi
callq 0x9190
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rsi
movq %r14, %rdx
callq 0xd41e
movq -0x188(%rbp), %rdi
cmpq %rbx, %rdi
je 0x8b8a
callq 0x52d0
leaq -0x148(%rbp), %rbx
leaq -0x100(%rbp), %r14
movq %r14, %rdi
callq 0x9126
movq -0x18(%r14), %rdi
testq %rdi, %rdi
je 0x8bae
callq 0x52d0
leaq -0x130(%rbp), %r14
movq %r14, %rdi
callq 0x907e
movq %rbx, %rdi
callq 0x90ce
movq -0x38(%r14), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x8bda
callq 0x52d0
movq -0x90(%rbp), %rdi
cmpq %r13, %rdi
je 0x8beb
callq 0x52d0
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x8bfc
callq 0x52d0
leaq -0x398(%rbp), %rdi
callq 0x5080
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x8c20
callq 0x52d0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x8c32
callq 0x52d0
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0x8c40
callq 0x52d0
xorl %eax, %eax
addq $0x378, %rsp            # imm = 0x378
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x168(%rbp), %rsi
movb $0x74, (%rsi)
leaq -0x398(%rbp), %rdi
callq 0x8f28
leaq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x51b0
jmp 0x883f
movl $0x10, %edi
callq 0x5180
movq %rax, %rbx
leaq 0x18388(%rip), %rsi     # 0x21017
movq %rax, %rdi
callq 0x55d0
movq 0x22332(%rip), %rsi     # 0x2afd0
movq 0x22313(%rip), %rdx     # 0x2afb8
movq %rbx, %rdi
callq 0x5510
jmp 0x8d1b
movl $0x10, %edi
callq 0x5180
movq %rax, %rbx
leaq 0x18378(%rip), %rsi     # 0x2103b
movq %rax, %rdi
callq 0x55d0
movq 0x222fe(%rip), %rsi     # 0x2afd0
movq 0x222df(%rip), %rdx     # 0x2afb8
movq %rbx, %rdi
callq 0x5510
jmp 0x8d1b
movq %r15, %r12
movl $0x10, %edi
callq 0x5180
movq %rax, %rbx
leaq 0x1830a(%rip), %rsi     # 0x21004
movq %rax, %rdi
callq 0x55d0
movq 0x222c7(%rip), %rsi     # 0x2afd0
movq 0x222a8(%rip), %rdx     # 0x2afb8
movq %rbx, %rdi
movq %r12, %rbx
callq 0x5510
jmp 0x8e21
movq %r14, %rdi
movq %rdx, %r14
movq %rax, %r15
callq 0x52d0
jmp 0x8e27
jmp 0x8e21
movq %rdx, %r14
movq %rax, %r15
jmp 0x8e37
movq %rdx, %r14
movq %rax, %r15
movq %rbx, %rdi
callq 0x5260
movq %r12, %rbx
jmp 0x8e37
movq %rdx, %r14
movq %rax, %r15
movq -0x188(%rbp), %rdi
cmpq %rbx, %rdi
je 0x8d9c
callq 0x52d0
jmp 0x8d9c
jmp 0x8de0
movq %rdx, %r14
movq %rax, %r15
jmp 0x8e13
movq %rdx, %r14
movq %rax, %r15
jmp 0x8e33
jmp 0x8dac
jmp 0x8e21
jmp 0x8e21
movq %rdx, %r14
movq %rax, %r15
leaq -0x168(%rbp), %rdi
callq 0x8f90
jmp 0x8de6
jmp 0x8e21
movq %rdx, %r14
movq %rax, %r15
movq %rbx, %rdi
callq 0x5260
jmp 0x8e27
jmp 0x8de0
jmp 0x8dc0
movq %rdx, %r14
movq %rax, %r15
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x8de6
callq 0x52d0
jmp 0x8de6
movq %rdx, %r14
movq %rax, %r15
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x8dfb
callq 0x52d0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x8e13
callq 0x52d0
leaq -0x398(%rbp), %rdi
callq 0x5080
jmp 0x8e33
movq %rdx, %r14
movq %rax, %r15
leaq -0x398(%rbp), %rdi
callq 0x8fea
leaq -0x60(%rbp), %rbx
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x8e4f
callq 0x52d0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x8e61
callq 0x52d0
movq -0x70(%rbp), %rdi
cmpq %rbx, %rdi
je 0x8e6f
callq 0x52d0
cmpl $0x1, %r14d
jne 0x8eaf
movq %r15, %rdi
callq 0x5130
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x22163(%rip), %rdi     # 0x2aff0
movq %rax, %rsi
callq 0x5300
movq %rax, %rdi
callq 0x5170
callq 0x54c0
jmp 0x8c40
movq %rax, %r15
callq 0x54c0
movq %r15, %rdi
callq 0x5560
movq %rax, %rdi
callq 0x8fdc
nop