// File: pollow[P]MIPSClide/simulator.cpp
// Function: Simulator::debug()
void Simulator::debug() {
    char c;
    int start, length;
    while (pc < statements.size()) {
        cout << statements[pc] << endl;
        c = getchar();
        cout << (int)c << endl;
        if ( c == 'n' ) {
            tick();
        } else if ( c == 's' ) {
            size_t tmp = pc + 1;
            while (pc != tmp) tick();
        } else if ( c == 'r' ) {
            for(auto i : reg_name) {
                cout << i.first << " : " << regs[i.second] << endl;
            }
        } else if ( c == 'm' ) {
            cin >> start >> length;
            for(int i = start; i < start+length; i++) {
                cout << i << ' ' << memory[i];
            }
        } else if ( c == 'e' ) {
            run();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq 0x98(%rdi), %rax
movq %rax, -0x80(%rbp)
addq $0x20, %rdi
callq 0x12e30
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jae 0x12309
movq -0x78(%rbp), %rax
movq %rax, %rdi
addq $0x20, %rdi
movq 0x98(%rax), %rsi
callq 0x12e50
movq %rax, %rsi
movq 0x5eec0(%rip), %rdi     # 0x70f90
callq 0x63f0
movq %rax, %rdi
movq 0x5ee81(%rip), %rsi     # 0x70f60
callq 0x64a0
callq 0x6620
movb %al, -0x9(%rbp)
movsbl -0x9(%rbp), %esi
movq 0x5ee99(%rip), %rdi     # 0x70f90
callq 0x6790
movq %rax, %rdi
movq 0x5ee5a(%rip), %rsi     # 0x70f60
callq 0x64a0
movsbl -0x9(%rbp), %eax
cmpl $0x6e, %eax
jne 0x12122
movq -0x78(%rbp), %rdi
callq 0x11290
jmp 0x12304
movsbl -0x9(%rbp), %eax
cmpl $0x73, %eax
jne 0x1215f
movq -0x78(%rbp), %rax
movq 0x98(%rax), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x78(%rbp), %rax
movq 0x98(%rax), %rax
cmpq -0x20(%rbp), %rax
je 0x1215a
movq -0x78(%rbp), %rdi
callq 0x11290
jmp 0x1213e
jmp 0x12302
movsbl -0x9(%rbp), %eax
cmpl $0x72, %eax
jne 0x1226f
leaq 0x5f73d(%rip), %rax     # 0x718b0
movq %rax, -0x28(%rbp)
leaq 0x5f732(%rip), %rdi     # 0x718b0
callq 0x12e70
movq %rax, -0x30(%rbp)
leaq 0x5f722(%rip), %rdi     # 0x718b0
callq 0x12ea0
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x12ed0
testb $0x1, %al
jne 0x121ad
jmp 0x1226a
leaq -0x30(%rbp), %rdi
callq 0x12f00
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x12f20
movq -0x90(%rbp), %rsi
movq 0x5edb9(%rip), %rdi     # 0x70f90
callq 0x63f0
movq %rax, -0x88(%rbp)
jmp 0x121e5
movq -0x88(%rbp), %rdi
leaq 0x3cf02(%rip), %rsi     # 0x4f0f5
callq 0x6450
movq %rax, -0x98(%rbp)
jmp 0x12201
movq -0x98(%rbp), %rdi
movq -0x78(%rbp), %rax
movl -0x40(%rbp), %ecx
movl 0xc0(%rax,%rcx,4), %esi
callq 0x6790
movq %rax, -0xa0(%rbp)
jmp 0x12224
movq -0xa0(%rbp), %rdi
movq 0x5ed2e(%rip), %rsi     # 0x70f60
callq 0x64a0
jmp 0x12239
leaq -0x60(%rbp), %rdi
callq 0x12f90
leaq -0x30(%rbp), %rdi
callq 0x12fb0
jmp 0x12197
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x12f90
jmp 0x12312
jmp 0x12300
movsbl -0x9(%rbp), %eax
cmpl $0x6d, %eax
jne 0x122ea
movq 0x5ed51(%rip), %rdi     # 0x70fd0
leaq -0x10(%rbp), %rsi
callq 0x62a0
movq %rax, %rdi
leaq -0x14(%rbp), %rsi
callq 0x62a0
movl -0x10(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl -0x10(%rbp), %ecx
addl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jge 0x122e8
movl -0x70(%rbp), %esi
movq 0x5ecdf(%rip), %rdi     # 0x70f90
callq 0x6790
movq %rax, %rdi
movl $0x20, %esi
callq 0x6530
movq %rax, %rdi
movq -0x78(%rbp), %rax
movq 0xb8(%rax), %rax
movslq -0x70(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x6790
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x1229a
jmp 0x122fe
movsbl -0x9(%rbp), %eax
cmpl $0x65, %eax
jne 0x122fc
movq -0x78(%rbp), %rdi
callq 0x110f0
jmp 0x122fe
jmp 0x12300
jmp 0x12302
jmp 0x12304
jmp 0x12087
addq $0xa0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x67c0
nopl (%rax,%rax)