// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, -0x40(%rbp)
movq %rsi, -0x48(%rbp)
movq 0x20(%rdi), %r13
movq %rdi, -0x38(%rbp)
cmpq 0x28(%rdi), %r13
je 0xd3a1
movq 0x1dcd0(%rip), %r12     # 0x2afa8
movq %r13, %r14
movq -0x38(%rbp), %rbx
movq (%r12), %rax
movq -0x18(%rax), %rax
leaq (%r12,%rax), %r15
cmpb $0x0, 0xe1(%r12,%rax)
jne 0xd312
movq %r15, %rdi
movl $0x20, %esi
callq 0x52f0
movb %al, 0xe0(%r15)
movb $0x1, 0xe1(%r15)
movb $0x30, 0xe0(%r15)
movq (%r12), %rax
movq -0x18(%rax), %rax
movq $0x4, 0x10(%r12,%rax)
movq %r14, %rsi
subq 0x20(%rbx), %rsi
sarq $0x5, %rsi
movq %r12, %rdi
callq 0x52e0
movq %rax, %r15
movl $0x3, %edx
movq %rax, %rdi
leaq 0x140eb(%rip), %rsi     # 0x2143b
callq 0x5390
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r15, %rdi
callq 0x5390
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x52f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5220
addq $0x20, %r13
addq $0x20, %r14
cmpq 0x28(%rbx), %r13
jne 0xd2df
leaq 0x14097(%rip), %rsi     # 0x2143f
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x50b0
testl %eax, %eax
je 0xd489
leaq 0x140c8(%rip), %rsi     # 0x2148b
movq %rbx, %rdi
callq 0x50b0
testl %eax, %eax
movq -0x40(%rbp), %rbx
jne 0xd61a
movq -0x38(%rbp), %rax
movq 0x50(%rax), %r12
movq 0x58(%rax), %r13
cmpq %r13, %r12
je 0xd60b
movl (%r12), %r14d
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %r15
cmpb $0x0, 0xe1(%rbx,%rax)
jne 0xd421
movq %r15, %rdi
movl $0x20, %esi
callq 0x52f0
movb %al, 0xe0(%r15)
movb $0x1, 0xe1(%r15)
movb $0x30, 0xe0(%r15)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq $0x8, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5210
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x52f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5220
addq $0x4, %r12
jmp 0xd3e3
leaq 0x13fb3(%rip), %rsi     # 0x21443
movl $0x1f, %edx
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0x5390
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x52f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5220
movq %rax, %r15
leaq 0x13f91(%rip), %rsi     # 0x21463
movl $0x1d, %edx
movq %rax, %rdi
callq 0x5390
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x52f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5220
movq -0x38(%rbp), %rax
movq 0x50(%rax), %r13
movq 0x58(%rax), %r14
cmpq %r14, %r13
je 0xd5d0
movl (%r13), %r15d
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %r12
cmpb $0x0, 0xe1(%rbx,%rax)
jne 0xd552
movq %r12, %rdi
movl $0x20, %esi
callq 0x52f0
movb %al, 0xe0(%r12)
movb $0x1, 0xe1(%r12)
movb $0x30, 0xe0(%r12)
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq $0x8, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5210
movb $0x2c, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x5390
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x52f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5220
addq $0x4, %r13
jmp 0xd512
leaq 0x13eaa(%rip), %rsi     # 0x21481
movl $0x9, %edx
movq %rbx, %rdi
callq 0x5390
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x52f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5220
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x5180
movq %rax, %rbx
leaq 0x13e63(%rip), %rsi     # 0x21491
movq %rax, %rdi
callq 0x55d0
movq 0x1d993(%rip), %rsi     # 0x2afd0
movq 0x1d974(%rip), %rdx     # 0x2afb8
movq %rbx, %rdi
callq 0x5510
movq %rax, %r14
movq %rbx, %rdi
callq 0x5260
movq %r14, %rdi
callq 0x5560
nop