// File: /workspace/github_cpp_makefile_star2_O1/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 0x1d59a(%rip), %rbx     # 0x22fb0
leaq 0x28(%rsp), %r12
leaq 0x13694(%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 0x135db(%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 0x135c8(%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 0x1359d(%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 0x1357a(%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 0x13550(%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 0x13529(%rip), %rsi     # 0x19099
callq 0x53d0
movq %r12, %rdi
movq %r14, %rsi
callq 0x17502
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 0x5bdb
callq 0x5330
movl $0x1f, %edx
movq %rbx, %rdi
leaq 0x134cf(%rip), %rsi     # 0x190b9
callq 0x53d0
movq %r12, %rdi
movq %r14, %rsi
callq 0x174f0
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 0x5c55
callq 0x5330
movl $0x20, %edx
movq %rbx, %rdi
leaq 0x13475(%rip), %rsi     # 0x190d9
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 0x5ccf
callq 0x5330
movl $0x7, %edx
movq %rbx, %rdi
leaq 0x1341c(%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 0x133bf(%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 0x1d262(%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 0x5fb7
leaq 0x1321c(%rip), %rcx     # 0x19004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x133be(%rip), %rsi     # 0x191b4
jmpq *%rax
xorl %eax, %eax
jmp 0x5e52
leaq 0x1331a(%rip), %rdi     # 0x1911d
callq 0x52e0
movl $0x14, %edx
movq %rbx, %rdi
leaq 0x1330c(%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 0x174e8
jmp 0x5ff2
movb $0x1, %al
movzbl %al, %esi
movq %r14, %rdi
callq 0x15846
jmp 0x5ff2
leaq 0x132b4(%rip), %rdi     # 0x1911d
callq 0x52e0
movq %r14, %rdi
callq 0x174d4
jmp 0x5ff2
movl $0x2a, %edx
movq %rbx, %rdi
leaq 0x132ff(%rip), %rsi     # 0x19189
callq 0x53d0
movq 0x1d142(%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 0x63d2
movq %r14, %rdi
leaq 0x48(%rsp), %rsi
callq 0x173e2
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
jmp 0x5fab
movl $0x26, %edx
movq %rbx, %rdi
leaq 0x1324c(%rip), %rsi     # 0x19138
callq 0x53d0
movq 0x1d0e0(%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 0x63d2
movq %r14, %rdi
leaq 0x88(%rsp), %rsi
callq 0x1744c
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
jmp 0x5fab
movl $0x29, %edx
movq %rbx, %rdi
leaq 0x13202(%rip), %rsi     # 0x1915f
callq 0x53d0
movq 0x1d06f(%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 0x63d2
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x1735a
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x5ff2
callq 0x5330
jmp 0x5ff2
leaq 0x13201(%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 0x131c9(%rip), %rsi     # 0x191ca
callq 0x53d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x601a
callq 0x5330
cmpw $0x8, 0x6(%rsp)
jne 0x5a22
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 0x13178(%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 0x60ce
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
jmp 0x60ce
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
jne 0x60ec
jmp 0x60f6
jmp 0x60f3
jmp 0x60f3
jmp 0x60f3
jmp 0x60df
jmp 0x60df
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x60f6
callq 0x5330
jmp 0x60f6
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x610a
callq 0x5330
movq %rbx, %rdi
callq 0x55c0