// File: fondoger[P]C0-Compiler/src/mips.cpp
// Function: MIPS(std::ostream&)
static void MIPS(std::ostream &ss)
{
    static std::string prev_op = "";
    static std::string prev_code = "";
    std::stringstream indent_blanks;
    for (int i = 0; i < indent_num; i++) {
        mipscode_stream << ' ';
    }
    std::ostringstream oss;
    oss << ss.rdbuf();
    std::string mips_code = oss.str();
    mipscode_stream << mips_code << std::endl;
    bool should_omit = false;
    if (mips_code.substr(0, 2) == "lw") {
        if (prev_op == "sw" && mips_code.substr(2) == prev_code.substr(2)) {
            should_omit = true;
        } else {
            prev_op = "lw";
            prev_code = mips_code;
        }
    } else if (mips_code.substr(0, 2) == "sw") {
        if (prev_op == "lw" && mips_code.substr(2) == prev_code.substr(2)) {
            should_omit = true;
        } else {
            prev_op = "sw";
            prev_code = mips_code;
        }
    } else {
        prev_op = "";
    }
    if (!should_omit) {
        for (int i = 0; i < indent_num; i++) {
            opt_mipscode_stream << ' ';
        }
        opt_mipscode_stream << mips_code << std::endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
cmpb $0x0, 0x2157a(%rip)     # 0x4a800
jne 0x292f4
leaq 0x21571(%rip), %rdi     # 0x4a800
callq 0x3580
cmpl $0x0, %eax
je 0x292f4
leaq -0x9(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x3570
movq -0x438(%rbp), %rdx
leaq 0x21529(%rip), %rdi     # 0x4a7e0
leaq 0xcd37(%rip), %rsi      # 0x35ff5
callq 0x3440
jmp 0x292c5
leaq -0x9(%rbp), %rdi
callq 0x3370
movq 0x1bcdb(%rip), %rdi     # 0x44fb0
leaq 0x21504(%rip), %rsi     # 0x4a7e0
leaq 0x1c015(%rip), %rdx     # 0x452f8
callq 0x32b0
leaq 0x21511(%rip), %rdi     # 0x4a800
callq 0x3220
cmpb $0x0, 0x2152d(%rip)     # 0x4a828
jne 0x29369
leaq 0x21524(%rip), %rdi     # 0x4a828
callq 0x3580
cmpl $0x0, %eax
je 0x29369
leaq -0x1d(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0x3570
movq -0x440(%rbp), %rdx
leaq 0x214dc(%rip), %rdi     # 0x4a808
leaq 0xccc2(%rip), %rsi      # 0x35ff5
callq 0x3440
jmp 0x2933a
leaq -0x1d(%rbp), %rdi
callq 0x3370
movq 0x1bc66(%rip), %rdi     # 0x44fb0
leaq 0x214b7(%rip), %rsi     # 0x4a808
leaq 0x1bfa0(%rip), %rdx     # 0x452f8
callq 0x32b0
leaq 0x214c4(%rip), %rdi     # 0x4a828
callq 0x3220
leaq -0x1a8(%rbp), %rdi
callq 0x3270
movl $0x0, -0x1ac(%rbp)
movl -0x1ac(%rbp), %eax
cmpl 0x214a5(%rip), %eax     # 0x4a830
jge 0x29414
leaq 0x1f088(%rip), %rdi     # 0x48420
movl $0x20, %esi
callq 0x33b0
jmp 0x293a4
jmp 0x293a6
movl -0x1ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ac(%rbp)
jmp 0x2937f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x9(%rbp), %rdi
callq 0x3370
leaq 0x2142d(%rip), %rdi     # 0x4a800
callq 0x3210
jmp 0x29926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x1d(%rbp), %rdi
callq 0x3370
leaq 0x2142f(%rip), %rdi     # 0x4a828
callq 0x3210
jmp 0x29926
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x2991a
leaq -0x328(%rbp), %rdi
callq 0x3420
jmp 0x29422
movq -0x8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3160
movq %rax, -0x448(%rbp)
jmp 0x2943e
movq -0x448(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0x30a0
jmp 0x29453
leaq -0x348(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x3320
jmp 0x29468
leaq 0x1efb1(%rip), %rdi     # 0x48420
leaq -0x348(%rbp), %rsi
callq 0x32c0
movq %rax, -0x450(%rbp)
jmp 0x29484
movq -0x450(%rbp), %rdi
movq 0x1bb16(%rip), %rsi     # 0x44fa8
callq 0x3360
jmp 0x29499
movb $0x0, -0x349(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x370(%rbp), %rdi
leaq -0x348(%rbp), %rsi
movl $0x2, %ecx
callq 0x3340
jmp 0x294be
leaq 0xcaed(%rip), %rsi      # 0x35fb2
leaq -0x370(%rbp), %rdi
callq 0x2d280
movb %al, -0x451(%rbp)
jmp 0x294d9
leaq -0x370(%rbp), %rdi
callq 0x35e8
movb -0x451(%rbp), %al
testb $0x1, %al
jne 0x294f4
jmp 0x29685
movb $0x0, -0x391(%rbp)
movb $0x0, -0x3b9(%rbp)
leaq 0x212d7(%rip), %rdi     # 0x4a7e0
leaq 0xcaa5(%rip), %rsi      # 0x35fb5
callq 0x2d280
movb %al, -0x452(%rbp)
jmp 0x2951d
movb -0x452(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x453(%rbp)
jne 0x29532
jmp 0x2959b
leaq -0x390(%rbp), %rdi
leaq -0x348(%rbp), %rsi
movl $0x2, %edx
movq $-0x1, %rcx
callq 0x3340
jmp 0x29553
movb $0x1, -0x391(%rbp)
leaq 0x212a7(%rip), %rsi     # 0x4a808
leaq -0x3b8(%rbp), %rdi
movl $0x2, %edx
movq $-0x1, %rcx
callq 0x3340
jmp 0x2957b
movb $0x1, -0x3b9(%rbp)
leaq -0x390(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x25880
movb %al, -0x453(%rbp)
movb -0x453(%rbp), %al
movb %al, -0x454(%rbp)
testb $0x1, -0x3b9(%rbp)
jne 0x295b2
jmp 0x295be
leaq -0x3b8(%rbp), %rdi
callq 0x35e8
testb $0x1, -0x391(%rbp)
jne 0x295c9
jmp 0x295d5
leaq -0x390(%rbp), %rdi
callq 0x35e8
movb -0x454(%rbp), %al
testb $0x1, %al
jne 0x295e1
jmp 0x29654
movb $0x1, -0x349(%rbp)
jmp 0x29680
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x2990e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x29902
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x35e8
jmp 0x29902
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
testb $0x1, -0x391(%rbp)
jne 0x29643
jmp 0x2964f
leaq -0x390(%rbp), %rdi
callq 0x35e8
jmp 0x29902
leaq 0x21185(%rip), %rdi     # 0x4a7e0
leaq 0xc950(%rip), %rsi      # 0x35fb2
callq 0x3430
jmp 0x29669
leaq 0x21198(%rip), %rdi     # 0x4a808
leaq -0x348(%rbp), %rsi
callq 0x3040
jmp 0x2967e
jmp 0x29680
jmp 0x2985b
xorl %eax, %eax
movl %eax, %edx
leaq -0x3e0(%rbp), %rdi
leaq -0x348(%rbp), %rsi
movl $0x2, %ecx
callq 0x3340
jmp 0x296a3
leaq 0xc90b(%rip), %rsi      # 0x35fb5
leaq -0x3e0(%rbp), %rdi
callq 0x2d280
movb %al, -0x455(%rbp)
jmp 0x296be
leaq -0x3e0(%rbp), %rdi
callq 0x35e8
movb -0x455(%rbp), %al
testb $0x1, %al
jne 0x296d9
jmp 0x29842
movb $0x0, -0x401(%rbp)
movb $0x0, -0x429(%rbp)
leaq 0x210f2(%rip), %rdi     # 0x4a7e0
leaq 0xc8bd(%rip), %rsi      # 0x35fb2
callq 0x2d280
movb %al, -0x456(%rbp)
jmp 0x29702
movb -0x456(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x457(%rbp)
jne 0x29717
jmp 0x29780
leaq -0x400(%rbp), %rdi
leaq -0x348(%rbp), %rsi
movl $0x2, %edx
movq $-0x1, %rcx
callq 0x3340
jmp 0x29738
movb $0x1, -0x401(%rbp)
leaq 0x210c2(%rip), %rsi     # 0x4a808
leaq -0x428(%rbp), %rdi
movl $0x2, %edx
movq $-0x1, %rcx
callq 0x3340
jmp 0x29760
movb $0x1, -0x429(%rbp)
leaq -0x400(%rbp), %rdi
leaq -0x428(%rbp), %rsi
callq 0x25880
movb %al, -0x457(%rbp)
movb -0x457(%rbp), %al
movb %al, -0x458(%rbp)
testb $0x1, -0x429(%rbp)
jne 0x29797
jmp 0x297a3
leaq -0x428(%rbp), %rdi
callq 0x35e8
testb $0x1, -0x401(%rbp)
jne 0x297ae
jmp 0x297ba
leaq -0x400(%rbp), %rdi
callq 0x35e8
movb -0x458(%rbp), %al
testb $0x1, %al
jne 0x297c6
jmp 0x29814
movb $0x1, -0x349(%rbp)
jmp 0x29840
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x3e0(%rbp), %rdi
callq 0x35e8
jmp 0x29902
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
testb $0x1, -0x401(%rbp)
jne 0x29803
jmp 0x2980f
leaq -0x400(%rbp), %rdi
callq 0x35e8
jmp 0x29902
leaq 0x20fc5(%rip), %rdi     # 0x4a7e0
leaq 0xc793(%rip), %rsi      # 0x35fb5
callq 0x3430
jmp 0x29829
leaq 0x20fd8(%rip), %rdi     # 0x4a808
leaq -0x348(%rbp), %rsi
callq 0x3040
jmp 0x2983e
jmp 0x29840
jmp 0x29859
leaq 0x20f97(%rip), %rdi     # 0x4a7e0
leaq 0xc7a5(%rip), %rsi      # 0x35ff5
callq 0x3430
jmp 0x29857
jmp 0x29859
jmp 0x2985b
testb $0x1, -0x349(%rbp)
jne 0x298d5
movl $0x0, -0x430(%rbp)
movl -0x430(%rbp), %eax
cmpl 0x20fb6(%rip), %eax     # 0x4a830
jge 0x298a2
leaq 0x1edbd(%rip), %rdi     # 0x48640
movl $0x20, %esi
callq 0x33b0
jmp 0x2988f
jmp 0x29891
movl -0x430(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x430(%rbp)
jmp 0x2986e
leaq 0x1ed97(%rip), %rdi     # 0x48640
leaq -0x348(%rbp), %rsi
callq 0x32c0
movq %rax, -0x460(%rbp)
jmp 0x298be
movq -0x460(%rbp), %rdi
movq 0x1b6dc(%rip), %rsi     # 0x44fa8
callq 0x3360
jmp 0x298d3
jmp 0x298d5
leaq -0x348(%rbp), %rdi
callq 0x35e8
leaq -0x328(%rbp), %rdi
callq 0x30c0
leaq -0x1a8(%rbp), %rdi
callq 0x35f0
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
leaq -0x348(%rbp), %rdi
callq 0x35e8
leaq -0x328(%rbp), %rdi
callq 0x30c0
leaq -0x1a8(%rbp), %rdi
callq 0x35f0
movq -0x18(%rbp), %rdi
callq 0x3560
nop