// File: pollow[P]MIPSClide/assembler.cpp
// Function: Assembler::print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::ostream&)
void Assembler::print(string type, ostream &out) {

#ifdef DEBUG
    for(auto i = statements.begin(); i != statements.end(); i++) {
        cout << setfill('0') << setw(4) << i-statements.begin() << " : " << *i << endl;
    }
#endif

    if ( type == "coe" ) {
        out << "memory_initialization_radix=16;" << endl << "memory_initialization_vector=" << endl;
        for(auto i : machine_code) {
            out << setfill('0') << setw(8) << hex << i << ',' << endl;
        }
        out << "00000000;" << endl;
    } else if ( type == "plain" ) {
        for(auto i : machine_code) {
            out << setfill('0') << setw(8) << hex << i << endl;
        }
    } else {
        throw invalid_argument("Output type could only be 'coe' or 'plain'");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rsi, -0xb0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
addq $0x20, %rdi
callq 0xf7d0
movq %rax, -0x20(%rbp)
movq -0xa8(%rbp), %rdi
addq $0x20, %rdi
callq 0xf9c0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xf980
testb $0x1, %al
jne 0x14b70
jmp 0x14c38
movl $0x30, %edi
callq 0x165a0
movb %al, -0x29(%rbp)
movq 0x5641c(%rip), %rdi     # 0x6afa0
movzbl -0x29(%rbp), %esi
callq 0x6680
movq %rax, -0xc8(%rbp)
movl $0x4, %edi
callq 0x165c0
movq -0xc8(%rbp), %rdi
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %esi
callq 0x6500
movq -0xa8(%rbp), %rdi
movq %rax, -0xc0(%rbp)
addq $0x20, %rdi
callq 0xf7d0
movq %rax, -0x38(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x11100
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x67d0
movq %rax, %rdi
leaq 0x358be(%rip), %rsi     # 0x4a4af
callq 0x6430
movq %rax, -0xb8(%rbp)
leaq -0x20(%rbp), %rdi
callq 0xf9f0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x63e0
movq %rax, %rdi
movq 0x56351(%rip), %rsi     # 0x6af70
callq 0x6480
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0xfa10
movq %rax, -0x40(%rbp)
jmp 0x14b46
movq -0xb0(%rbp), %rdi
leaq 0x3586d(%rip), %rsi     # 0x4a4b3
callq 0x15570
testb $0x1, %al
jne 0x14c54
jmp 0x14d91
movq -0x18(%rbp), %rdi
leaq 0x35858(%rip), %rsi     # 0x4a4b7
callq 0x6430
movq %rax, %rdi
movq 0x56302(%rip), %rsi     # 0x6af70
callq 0x6480
movq %rax, %rdi
leaq 0x3585a(%rip), %rsi     # 0x4a4d7
callq 0x6430
movq %rax, %rdi
movq 0x562e4(%rip), %rsi     # 0x6af70
callq 0x6480
movq -0xa8(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0xe7f0
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0xe680
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x165e0
testb $0x1, %al
jne 0x14cd0
jmp 0x14d6d
leaq -0x50(%rbp), %rdi
callq 0x16620
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl $0x30, %edi
callq 0x165a0
movq -0xd8(%rbp), %rdi
movb %al, -0x5d(%rbp)
movzbl -0x5d(%rbp), %esi
callq 0x6680
movq %rax, -0xd0(%rbp)
movl $0x8, %edi
callq 0x165c0
movq -0xd0(%rbp), %rdi
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %esi
callq 0x6500
movq %rax, %rdi
leaq 0x190d(%rip), %rsi      # 0x16640
callq 0x6150
movq %rax, %rdi
movl -0x5c(%rbp), %esi
callq 0x65c0
movq %rax, %rdi
movl $0x2c, %esi
callq 0x6510
movq %rax, %rdi
movq 0x56216(%rip), %rsi     # 0x6af70
callq 0x6480
leaq -0x50(%rbp), %rdi
callq 0x16670
jmp 0x14cba
movq -0x18(%rbp), %rdi
leaq 0x3577d(%rip), %rsi     # 0x4a4f5
callq 0x6430
movq %rax, %rdi
movq 0x561e9(%rip), %rsi     # 0x6af70
callq 0x6480
jmp 0x14ef1
movq -0xb0(%rbp), %rdi
leaq 0x35760(%rip), %rsi     # 0x4a4ff
callq 0x15570
testb $0x1, %al
jne 0x14dad
jmp 0x14e90
movq -0xa8(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0xe7f0
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0xe680
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x165e0
testb $0x1, %al
jne 0x14dec
jmp 0x14e8e
leaq -0x78(%rbp), %rdi
callq 0x16620
movl (%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl $0x30, %edi
callq 0x165a0
movq -0xe8(%rbp), %rdi
movb %al, -0x85(%rbp)
movzbl -0x85(%rbp), %esi
callq 0x6680
movq %rax, -0xe0(%rbp)
movl $0x8, %edi
callq 0x165c0
movq -0xe0(%rbp), %rdi
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %esi
callq 0x6500
movq %rax, %rdi
leaq 0x17e2(%rip), %rsi      # 0x16640
callq 0x6150
movq %rax, %rdi
movl -0x84(%rbp), %esi
callq 0x65c0
movq %rax, %rdi
movq 0x560f5(%rip), %rsi     # 0x6af70
callq 0x6480
leaq -0x78(%rbp), %rdi
callq 0x16670
jmp 0x14dd6
jmp 0x14eef
movl $0x10, %edi
callq 0x6210
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
leaq 0x35657(%rip), %rsi     # 0x4a505
callq 0x6820
jmp 0x14eb5
movq -0xf0(%rbp), %rdi
movq 0x5610d(%rip), %rsi     # 0x6afd0
movq 0x560ee(%rip), %rdx     # 0x6afb8
callq 0x6730
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
callq 0x6350
jmp 0x14efa
jmp 0x14ef1
addq $0xf0, %rsp
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x6790
nopw %cs:(%rax,%rax)