// File: Cicko[P]Ram-Machine/main.cpp
// Function: menu(RamMachine*)
void menu (RamMachine * machine) {

  unsigned short option = 0;

  while (option != 8) {
    string fileName;

    cout << "============= RAM MACHINE =============" << endl;
    cout << "1. Run program." << endl;
    cout << "2. Run program (trace)." << endl;
    cout << "3. Show program." << endl;
    cout << "4. Show input tape." << endl;
    cout << "5. Change program. (actual: " << machine->getProgramFileName () << ") " << endl;
    cout << "6. Change input tape. (actual: " << machine->getInputFileName () << ") "  << endl;
    cout << "7. Change output tape. (actual: " << machine->getOutputFileName () << ") " << endl;
    cout << "8. Exit" << endl << endl;

    cout << "Select one option {1-6} : " << endl;
    cin >> option;
    cout << endl << endl;

    switch (option) {
      case 1:
        machine->runProgram (false);
        break;
      case 2:
        machine->runProgram (true);
        break;
      case 3:
        system ("clear");
        machine->showProgram ();
        break;
      case 4:
        system ("clear");
        cout << "Input tape content: " << endl;
        machine->showInputTape ();
        break;
      case 5:
        cout << "Select name for the new program file: " ;
        cin >> fileName;
        machine->resetProgram (fileName);
        break;
      case 6:
        cout << "Select name for the new input tape file: " ;
        cin >> fileName;
        machine->resetInTape (fileName);
        break;
      case 7:
        cout << "Select name for the new output tape file: ";
        cin >> fileName;
        machine->resetOutTape (fileName);
        break;
      case 8:
        cout << "Saliendo.." << endl;
        break;
      default:
        cout << "No conozco" << endl;
    }
    cout << "\n\n\n\n";
  }

  cout << endl << "Adios!! " << endl;

}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1c0(%rsp)
movw $0x0, 0x1be(%rsp)
movzwl 0x1be(%rsp), %eax
cmpl $0x8, %eax
je 0x7286
leaq 0x198(%rsp), %rdi
callq 0x6620
movq 0x4941a(%rip), %rdi     # 0x4ff98
leaq 0x3349f(%rip), %rsi     # 0x3a024
callq 0x6430
movq %rax, 0xc0(%rsp)
jmp 0x6b94
movq 0xc0(%rsp), %rdi
movq 0x493cd(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6baa
movq 0x493e7(%rip), %rdi     # 0x4ff98
leaq 0x33494(%rip), %rsi     # 0x3a04c
callq 0x6430
movq %rax, 0xb8(%rsp)
jmp 0x6bc7
movq 0xb8(%rsp), %rdi
movq 0x4939a(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6bdd
movq 0x493b4(%rip), %rdi     # 0x4ff98
leaq 0x33471(%rip), %rsi     # 0x3a05c
callq 0x6430
movq %rax, 0xb0(%rsp)
jmp 0x6bfa
movq 0xb0(%rsp), %rdi
movq 0x49367(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6c10
movq 0x49381(%rip), %rdi     # 0x4ff98
leaq 0x33456(%rip), %rsi     # 0x3a074
callq 0x6430
movq %rax, 0xa8(%rsp)
jmp 0x6c2d
movq 0xa8(%rsp), %rdi
movq 0x49334(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6c43
movq 0x4934e(%rip), %rdi     # 0x4ff98
leaq 0x33434(%rip), %rsi     # 0x3a085
callq 0x6430
movq %rax, 0xa0(%rsp)
jmp 0x6c60
movq 0xa0(%rsp), %rdi
movq 0x49301(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6c76
movq 0x4931b(%rip), %rdi     # 0x4ff98
leaq 0x33415(%rip), %rsi     # 0x3a099
callq 0x6430
movq %rax, 0x98(%rsp)
jmp 0x6c93
movq 0x1c0(%rsp), %rsi
leaq 0x168(%rsp), %rdi
callq 0x37330
jmp 0x6caa
movq 0x98(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x63e0
movq %rax, 0x90(%rsp)
jmp 0x6cc9
movq 0x90(%rsp), %rdi
leaq 0x333de(%rip), %rsi     # 0x3a0b6
callq 0x6430
movq %rax, 0x88(%rsp)
jmp 0x6ce7
movq 0x88(%rsp), %rdi
movq 0x4927a(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6cfd
leaq 0x168(%rsp), %rdi
callq 0x62a0
movq 0x49287(%rip), %rdi     # 0x4ff98
leaq 0x333a1(%rip), %rsi     # 0x3a0b9
callq 0x6430
movq %rax, 0x80(%rsp)
jmp 0x6d27
movq 0x1c0(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x37300
jmp 0x6d3e
movq 0x80(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x63e0
movq %rax, 0x78(%rsp)
jmp 0x6d5a
movq 0x78(%rsp), %rdi
leaq 0x33350(%rip), %rsi     # 0x3a0b6
callq 0x6430
movq %rax, 0x70(%rsp)
jmp 0x6d72
movq 0x70(%rsp), %rdi
movq 0x491f2(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6d85
leaq 0x148(%rsp), %rdi
callq 0x62a0
movq 0x491ff(%rip), %rdi     # 0x4ff98
leaq 0x33339(%rip), %rsi     # 0x3a0d9
callq 0x6430
movq %rax, 0x68(%rsp)
jmp 0x6dac
movq 0x1c0(%rsp), %rsi
leaq 0x128(%rsp), %rdi
callq 0x37360
jmp 0x6dc3
movq 0x68(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x63e0
movq %rax, 0x60(%rsp)
jmp 0x6ddc
movq 0x60(%rsp), %rdi
leaq 0x332ce(%rip), %rsi     # 0x3a0b6
callq 0x6430
movq %rax, 0x58(%rsp)
jmp 0x6df4
movq 0x58(%rsp), %rdi
movq 0x49170(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6e07
leaq 0x128(%rsp), %rdi
callq 0x62a0
movq 0x4917d(%rip), %rdi     # 0x4ff98
leaq 0x332d8(%rip), %rsi     # 0x3a0fa
callq 0x6430
movq %rax, 0x50(%rsp)
jmp 0x6e2e
movq 0x50(%rsp), %rdi
movq 0x49136(%rip), %rsi     # 0x4ff70
callq 0x6480
movq %rax, 0x48(%rsp)
jmp 0x6e46
movq 0x48(%rsp), %rdi
movq 0x4911e(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6e59
movq 0x49138(%rip), %rdi     # 0x4ff98
leaq 0x3329b(%rip), %rsi     # 0x3a102
callq 0x6430
movq %rax, 0x40(%rsp)
jmp 0x6e73
movq 0x40(%rsp), %rdi
movq 0x490f1(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6e86
movq 0x49143(%rip), %rdi     # 0x4ffd0
leaq 0x1be(%rsp), %rsi
callq 0x6240
jmp 0x6e9c
movq 0x490f5(%rip), %rdi     # 0x4ff98
movq 0x490c6(%rip), %rsi     # 0x4ff70
callq 0x6480
movq %rax, 0x38(%rsp)
jmp 0x6eb6
movq 0x38(%rsp), %rdi
movq 0x490ae(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x6ec9
movzwl 0x1be(%rsp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x30(%rsp)
subl $0x7, %eax
ja 0x7223
movq 0x30(%rsp), %rax
leaq 0x33115(%rip), %rcx     # 0x3a004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
jmp 0x7277
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
leaq 0x168(%rsp), %rdi
callq 0x62a0
jmp 0x7277
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x62a0
jmp 0x7277
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x62a0
jmp 0x7277
movq 0x1c0(%rsp), %rdi
xorl %esi, %esi
callq 0x34e20
jmp 0x6f94
jmp 0x7250
movq 0x1c0(%rsp), %rdi
movl $0x1, %esi
callq 0x34e20
jmp 0x6fad
jmp 0x7250
leaq 0x33164(%rip), %rdi     # 0x3a11d
callq 0x63a0
jmp 0x6fc0
movq 0x1c0(%rsp), %rdi
callq 0x372a0
jmp 0x6fcf
jmp 0x7250
leaq 0x33142(%rip), %rdi     # 0x3a11d
callq 0x63a0
jmp 0x6fe2
movq 0x48faf(%rip), %rdi     # 0x4ff98
leaq 0x33133(%rip), %rsi     # 0x3a123
callq 0x6430
movq %rax, 0x28(%rsp)
jmp 0x6ffc
movq 0x28(%rsp), %rdi
movq 0x48f68(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x700f
movq 0x1c0(%rsp), %rdi
callq 0x372e0
jmp 0x701e
jmp 0x7250
movq 0x48f6e(%rip), %rdi     # 0x4ff98
leaq 0x33107(%rip), %rsi     # 0x3a138
callq 0x6430
jmp 0x7038
movq 0x48f91(%rip), %rdi     # 0x4ffd0
leaq 0x198(%rsp), %rsi
callq 0x6590
jmp 0x704e
movq 0x1c0(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x61b0
jmp 0x7072
movq 0x20(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x37210
jmp 0x7086
leaq 0x108(%rsp), %rdi
callq 0x62a0
jmp 0x7250
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x62a0
jmp 0x7277
movq 0x48ed3(%rip), %rdi     # 0x4ff98
leaq 0x33093(%rip), %rsi     # 0x3a15f
callq 0x6430
jmp 0x70d3
movq 0x48ef6(%rip), %rdi     # 0x4ffd0
leaq 0x198(%rsp), %rsi
callq 0x6590
jmp 0x70e9
movq 0x1c0(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x61b0
jmp 0x710d
movq 0x18(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x37110
jmp 0x7121
leaq 0xe8(%rsp), %rdi
callq 0x62a0
jmp 0x7250
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x62a0
jmp 0x7277
movq 0x48e38(%rip), %rdi     # 0x4ff98
leaq 0x33022(%rip), %rsi     # 0x3a189
callq 0x6430
jmp 0x716e
movq 0x48e5b(%rip), %rdi     # 0x4ffd0
leaq 0x198(%rsp), %rsi
callq 0x6590
jmp 0x7184
movq 0x1c0(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x61b0
jmp 0x71a8
movq 0x10(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x371a0
jmp 0x71bc
leaq 0xc8(%rsp), %rdi
callq 0x62a0
jmp 0x7250
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x190(%rsp)
movl %eax, 0x18c(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x62a0
jmp 0x7277
movq 0x48d9d(%rip), %rdi     # 0x4ff98
leaq 0x32fb2(%rip), %rsi     # 0x3a1b4
callq 0x6430
movq %rax, 0x8(%rsp)
jmp 0x720e
movq 0x8(%rsp), %rdi
movq 0x48d56(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x7221
jmp 0x7250
movq 0x48d6e(%rip), %rdi     # 0x4ff98
leaq 0x32f8e(%rip), %rsi     # 0x3a1bf
callq 0x6430
movq %rax, (%rsp)
jmp 0x723c
movq (%rsp), %rdi
movq 0x48d29(%rip), %rsi     # 0x4ff70
callq 0x6480
jmp 0x724e
jmp 0x7250
movq 0x48d41(%rip), %rdi     # 0x4ff98
leaq 0x32f6c(%rip), %rsi     # 0x3a1ca
callq 0x6430
jmp 0x7265
leaq 0x198(%rsp), %rdi
callq 0x62a0
jmp 0x6b59
leaq 0x198(%rsp), %rdi
callq 0x62a0
jmp 0x72bf
movq 0x48d0b(%rip), %rdi     # 0x4ff98
movq 0x48cdc(%rip), %rsi     # 0x4ff70
callq 0x6480
movq %rax, %rdi
leaq 0x32f2c(%rip), %rsi     # 0x3a1cf
callq 0x6430
movq %rax, %rdi
movq 0x48cbe(%rip), %rsi     # 0x4ff70
callq 0x6480
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq 0x190(%rsp), %rdi
callq 0x67b0
nopl (%rax)