// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
leaq 0x6(%rsp), %rax
movw $0x0, (%rax)
leaq 0x38(%rsp), %rbp
movq 0x1d5aa(%rip), %rbx     # 0x22fb0
leaq 0x28(%rsp), %r12
leaq 0x136a4(%rip), %r13     # 0x190b6
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movl $0x27, %edx
movq %rbx, %rdi
leaq 0x135eb(%rip), %rsi     # 0x19024
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movl $0xf, %edx
movq %rbx, %rdi
leaq 0x135d8(%rip), %rsi     # 0x1904c
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movl $0x17, %edx
movq %rbx, %rdi
leaq 0x135ad(%rip), %rsi     # 0x1905c
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movl $0x10, %edx
movq %rbx, %rdi
leaq 0x1358a(%rip), %rsi     # 0x19074
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movl $0x13, %edx
movq %rbx, %rdi
leaq 0x13560(%rip), %rsi     # 0x19085
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movl $0x1c, %edx
movq %rbx, %rdi
leaq 0x13539(%rip), %rsi     # 0x19099
callq 0x53d0
movq %r12, %rdi
movq %r14, %rsi
callq 0x17526
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x53d0
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x53d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5bcb
callq 0x5330
movl $0x1f, %edx
movq %rbx, %rdi
leaq 0x134df(%rip), %rsi     # 0x190b9
callq 0x53d0
movq %r12, %rdi
movq %r14, %rsi
callq 0x17514
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x53d0
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x53d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5c45
callq 0x5330
movl $0x20, %edx
movq %rbx, %rdi
leaq 0x13485(%rip), %rsi     # 0x190d9
callq 0x53d0
movq %r12, %rdi
movq %r14, %rsi
callq 0x17538
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x53d0
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x53d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5cbf
callq 0x5330
movl $0x7, %edx
movq %rbx, %rdi
leaq 0x1342c(%rip), %rsi     # 0x190fa
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movl $0x1a, %edx
movq %rbx, %rdi
leaq 0x133cf(%rip), %rsi     # 0x19102
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movq 0x1d272(%rip), %rdi     # 0x22fd8
leaq 0x6(%rsp), %rsi
callq 0x5500
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %r15, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movzwl 0x6(%rsp), %eax
decl %eax
cmpl $0x7, %eax
ja 0x5fa7
leaq 0x1322c(%rip), %rcx     # 0x19004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x133ce(%rip), %rsi     # 0x191b4
jmpq *%rax
xorl %eax, %eax
jmp 0x5e42
leaq 0x1332a(%rip), %rdi     # 0x1911d
callq 0x52e0
movl $0x14, %edx
movq %rbx, %rdi
leaq 0x1331c(%rip), %rsi     # 0x19123
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movq %r14, %rdi
callq 0x1750c
jmp 0x5fe2
movb $0x1, %al
movzbl %al, %esi
movq %r14, %rdi
callq 0x15842
jmp 0x5fe2
leaq 0x132c4(%rip), %rdi     # 0x1911d
callq 0x52e0
movq %r14, %rdi
callq 0x174f8
jmp 0x5fe2
movl $0x2a, %edx
movq %rbx, %rdi
leaq 0x1330f(%rip), %rsi     # 0x19189
callq 0x53d0
movq 0x1d152(%rip), %rdi     # 0x22fd8
leaq 0x8(%rsp), %rsi
callq 0x5440
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x63c2
movq %r14, %rdi
leaq 0x48(%rsp), %rsi
callq 0x17406
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
jmp 0x5f9b
movl $0x26, %edx
movq %rbx, %rdi
leaq 0x1325c(%rip), %rsi     # 0x19138
callq 0x53d0
movq 0x1d0f0(%rip), %rdi     # 0x22fd8
leaq 0x8(%rsp), %rsi
callq 0x5440
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x63c2
movq %r14, %rdi
leaq 0x88(%rsp), %rsi
callq 0x17470
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
jmp 0x5f9b
movl $0x29, %edx
movq %rbx, %rdi
leaq 0x13212(%rip), %rsi     # 0x1915f
callq 0x53d0
movq 0x1d07f(%rip), %rdi     # 0x22fd8
leaq 0x8(%rsp), %rsi
callq 0x5440
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x63c2
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x1737e
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x5fe2
callq 0x5330
jmp 0x5fe2
leaq 0x13211(%rip), %rsi     # 0x191bf
movl $0xa, %edx
movq %rbx, %rdi
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movl $0x4, %edx
movq %rbx, %rdi
leaq 0x131d9(%rip), %rsi     # 0x191ca
callq 0x53d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x600a
callq 0x5330
cmpw $0x8, 0x6(%rsp)
jne 0x5a12
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
movq %rax, %rbx
leaq 0x13188(%rip), %rsi     # 0x191cf
movl $0x8, %edx
movq %rax, %rdi
callq 0x53d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5340
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5270
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
jmp 0x60be
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
jmp 0x60be
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
jne 0x60dc
jmp 0x60e6
jmp 0x60e3
jmp 0x60e3
jmp 0x60e3
jmp 0x60cf
jmp 0x60cf
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x60e6
callq 0x5330
jmp 0x60e6
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x60fa
callq 0x5330
movq %rbx, %rdi
callq 0x55c0