// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0x6(%rsp), %rax
andw $0x0, (%rax)
xorl %eax, %eax
movq 0x1b6fe(%rip), %r15     # 0x20fa0
leaq 0x28(%rsp), %r12
leaq 0xf808(%rip), %r13      # 0x150b6
leaq 0xf74f(%rip), %r14      # 0x15004
cmpw $0x8, %ax
je 0x5bf4
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq %r15, %rdi
leaq 0xf746(%rip), %rsi      # 0x15024
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r15, %rdi
leaq 0xf757(%rip), %rsi      # 0x1504c
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r15, %rdi
leaq 0xf750(%rip), %rsi      # 0x1505c
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r15, %rdi
leaq 0xf751(%rip), %rsi      # 0x15074
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r15, %rdi
leaq 0xf74b(%rip), %rsi      # 0x15085
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r15, %rdi
leaq 0xf748(%rip), %rsi      # 0x15099
callq 0x5350
movq %rax, %rbp
movq %r12, %rdi
movq %rbx, %rsi
callq 0x13c26
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5310
movq %rax, %rdi
movq %r13, %rsi
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r12, %rdi
callq 0x51a0
movq %r15, %rdi
leaq 0xf725(%rip), %rsi      # 0x150b9
callq 0x5350
movq %rax, %rbp
movq %r12, %rdi
movq %rbx, %rsi
callq 0x13c14
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5310
movq %rax, %rdi
movq %r13, %rsi
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r12, %rdi
callq 0x51a0
movq %r15, %rdi
leaq 0xf702(%rip), %rsi      # 0x150d9
callq 0x5350
movq %rax, %rbp
movq %r12, %rdi
movq %rbx, %rsi
callq 0x13c38
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5310
movq %rax, %rdi
movq %r13, %rsi
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r12, %rdi
callq 0x51a0
movq %r15, %rdi
leaq 0xf6e0(%rip), %rsi      # 0x150fa
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
movq %r15, %rdi
leaq 0xf6c9(%rip), %rsi      # 0x15102
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq 0x1b583(%rip), %rdi     # 0x20fd0
leaq 0x6(%rsp), %rsi
callq 0x5510
movq %r15, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
movzwl 0x6(%rsp), %eax
decl %eax
cmpl $0x7, %eax
ja 0x5bba
movslq (%r14,%rax,4), %rax
addq %r14, %rax
leaq 0xf72f(%rip), %rsi      # 0x151b4
jmpq *%rax
xorl %eax, %eax
jmp 0x5abd
leaq 0xf68b(%rip), %rdi      # 0x1511d
callq 0x52e0
movq %r15, %rdi
leaq 0xf682(%rip), %rsi      # 0x15123
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %rbx, %rdi
callq 0x13c0c
jmp 0x5bd1
movb $0x1, %al
movzbl %al, %esi
movq %rbx, %rdi
callq 0x12d3c
jmp 0x5bd1
leaq 0xf649(%rip), %rdi      # 0x1511d
callq 0x52e0
movq %rbx, %rdi
callq 0x13bf8
jmp 0x5bd1
movq %r15, %rdi
leaq 0xf699(%rip), %rsi      # 0x15189
callq 0x5350
movq 0x1b4d4(%rip), %rdi     # 0x20fd0
leaq 0x8(%rsp), %rsi
callq 0x5450
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5490
movq %rbx, %rdi
leaq 0x48(%rsp), %rbp
movq %rbp, %rsi
callq 0x13b50
jmp 0x5bb0
movq %r15, %rdi
leaq 0xf604(%rip), %rsi      # 0x15138
callq 0x5350
movq 0x1b490(%rip), %rdi     # 0x20fd0
leaq 0x8(%rsp), %rsi
callq 0x5450
leaq 0x88(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5490
movq %rbx, %rdi
leaq 0x88(%rsp), %rbp
movq %rbp, %rsi
callq 0x13b9a
jmp 0x5bb0
movq %r15, %rdi
leaq 0xf5e4(%rip), %rsi      # 0x1515f
callq 0x5350
movq 0x1b449(%rip), %rdi     # 0x20fd0
leaq 0x8(%rsp), %rsi
callq 0x5450
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5490
movq %rbx, %rdi
leaq 0x68(%rsp), %rbp
movq %rbp, %rsi
callq 0x13af4
movq %rbp, %rdi
callq 0x51a0
jmp 0x5bd1
leaq 0xf5fe(%rip), %rsi      # 0x151bf
movq %r15, %rdi
callq 0x5350
movq %rax, %rdi
callq 0x51c0
movq %r15, %rdi
leaq 0xf5ef(%rip), %rsi      # 0x151ca
callq 0x5350
leaq 0x8(%rsp), %rdi
callq 0x51a0
movzwl 0x6(%rsp), %eax
jmp 0x58b5
movq 0x1b3a5(%rip), %rdi     # 0x20fa0
callq 0x51c0
leaq 0xf5c8(%rip), %rsi      # 0x151cf
movq %rax, %rdi
callq 0x5350
movq %rax, %rdi
callq 0x51c0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x5c5c
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x5c5c
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x5c5c
jmp 0x5c63
jmp 0x5c63
jmp 0x5c63
jmp 0x5c54
jmp 0x5c54
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x51a0
jmp 0x5c66
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x51a0
movq %rbx, %rdi
callq 0x55c0