// File: /workspace/github_cpp_makefile_star2_O2/brashi[P]PetFera/src/./main.cpp
// Function: menu()
void menu() {
    shared_ptr<Petshop> petshop = make_shared<Petshop>();
    unique_ptr<MapeadorMenu> mapeador = make_unique<MapeadorMenu>();
    bool executando = true;
    string opcao;
    
    BancoDados banco(petshop);
    banco.lerDados();
    pausar();
    while(executando) {
        limparTela();
        imprimirMenu();

        getline(cin, opcao);
        limparTela();
        
        #ifdef DEBUG
            if(toupper(opcao[0]) == 'T')
                banco.lerDadosTestes();
        #endif
        if(toupper(opcao[0]) == 'N' && !std::filesystem::is_empty("dados/")) {
            cout << "Tem certeza? TUDO será apagado" << endl;
            cout << "S - para SIM: ";
            getline(cin, opcao);

            if(toupper(opcao[0]) == 'S')
                banco.excluirArquivos();
            else
                cout << "Operação cancelada..." << endl;
        } else {
            try {
                executando = mapeador->escolhas[toupper(opcao[0])](petshop);
            } catch (const std::bad_function_call&) {
                cout << "Informe uma opção válida para realizar uma ação" << endl;
            } catch (const std::invalid_argument&) {
                cout << "Um valor numérico era esperado e não condiz com o introduzido." << endl;
            } catch (char const* msg) {
                cout << "Erro: " << msg << endl << "Verifique os dados informados e tente novamente." << endl;
            } catch (const string msg) {
                cout << "Erro: " << msg << endl << "Verifique os dados informados e tente novamente." << endl;
            } catch (...) {
                cout << "Algo de errado ocorreu, verifique os dados informados e tente novamente." << endl;
            }
        }

        pausar();
    }
    
    banco.salvarDados();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
leaq 0x8(%rsp), %rdi
callq 0xa069
movq %rsp, %rdi
callq 0xa084
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x48(%rsp), %rbx
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x81e6
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x5a0c
leaq 0x50(%rsp), %rdi
callq 0x8466
leaq 0x80(%rsp), %rdi
callq 0x6960
callq 0x9b80
movq 0x1c38e(%rip), %r14     # 0x25fe0
leaq 0x18(%rsp), %r15
leaq 0x58(%rsp), %r13
leaq 0x38(%rsp), %rbp
callq 0x9b74
callq 0x98fc
movq %r14, %rdi
movq %r15, %rsi
callq 0x5060
callq 0x9b74
movq 0x18(%rsp), %rax
movsbl (%rax), %ebx
movl %ebx, %edi
callq 0x5460
cmpl $0x4e, %eax
jne 0x9cbf
movq %r13, %rdi
leaq 0xd38a(%rip), %rsi      # 0x17023
pushq $0x2
popq %rdx
callq 0x9ffe
movq %r13, %rdi
callq 0x5470
movl %eax, %ebx
movq %r13, %rdi
callq 0x7d36
testb %bl, %bl
je 0x9d12
movq 0x18(%rsp), %rax
movsbl (%rax), %ebx
movq (%rsp), %r12
movl %ebx, %edi
callq 0x5460
movb %al, 0x58(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xa0c2
movq %rax, %rbx
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x81e6
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xa110
movl %eax, %ebx
leaq 0x40(%rsp), %rdi
callq 0x8466
callq 0x9b80
testb %bl, %bl
jne 0x9c61
jmp 0x9f04
movq 0x1c2af(%rip), %rdi     # 0x25fc8
leaq 0xde51(%rip), %rsi      # 0x17b71
callq 0x5270
movq %rax, %rdi
callq 0x5160
movq 0x1c294(%rip), %rdi     # 0x25fc8
leaq 0xde56(%rip), %rsi      # 0x17b91
callq 0x5270
movq %r14, %rdi
movq %r15, %rsi
callq 0x5060
movq 0x18(%rsp), %rax
movsbl (%rax), %edi
callq 0x5460
cmpl $0x53, %eax
jne 0x9d6e
movb $0x1, %bl
leaq 0x80(%rsp), %rdi
callq 0x7a2a
jmp 0x9d00
movq 0x1c253(%rip), %rdi     # 0x25fc8
leaq 0xde24(%rip), %rsi      # 0x17ba0
callq 0x5270
movb $0x1, %bl
movq %rax, %rdi
callq 0x5160
jmp 0x9d00
movq %rdx, %rbx
movq %rax, %r12
leaq 0x40(%rsp), %rdi
callq 0x8466
jmp 0x9da8
movq %rdx, %rbx
movq %rax, %r12
cmpl $0x5, %ebx
jne 0x9ddc
movq %r12, %rdi
callq 0x5120
movq 0x1c20c(%rip), %rdi     # 0x25fc8
leaq 0xdeb0(%rip), %rsi      # 0x17c73
callq 0x5270
movq %rax, %rdi
callq 0x5160
movb $0x1, %bl
callq 0x53f0
jmp 0x9d00
cmpl $0x4, %ebx
jne 0x9e10
movq %r12, %rdi
callq 0x5120
movq 0x1c1d8(%rip), %rdi     # 0x25fc8
leaq 0xde3b(%rip), %rsi      # 0x17c32
callq 0x5270
movq %rax, %rdi
callq 0x5160
movb $0x1, %bl
callq 0x53f0
jmp 0x9d00
cmpl $0x3, %ebx
jne 0x9e64
movq %r12, %rdi
callq 0x5120
movq %rax, %rbx
movq 0x1c1a1(%rip), %rdi     # 0x25fc8
leaq 0xd219(%rip), %rsi      # 0x17047
callq 0x5270
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5270
movq %rax, %rdi
callq 0x5160
movq %rax, %rdi
leaq 0xddb1(%rip), %rsi      # 0x17c01
callq 0x5270
movq %rax, %rdi
callq 0x5160
callq 0x53f0
jmp 0x9ece
cmpl $0x2, %ebx
jne 0x9ed5
movq %r12, %rdi
callq 0x5300
movq %r13, %rdi
movq %rax, %rsi
callq 0x5340
movq %r12, %rdi
callq 0x5120
movq 0x1c13d(%rip), %rdi     # 0x25fc8
leaq 0xd1b5(%rip), %rsi      # 0x17047
callq 0x5270
movq %rax, %rdi
movq %r13, %rsi
callq 0x5260
movq %rax, %rdi
callq 0x5160
movq %rax, %rdi
leaq 0xdd4d(%rip), %rsi      # 0x17c01
callq 0x5270
movq %rax, %rdi
callq 0x5160
movq %r13, %rdi
callq 0x54c8
callq 0x53f0
movb $0x1, %bl
jmp 0x9d00
movq %r12, %rdi
callq 0x5120
movq 0x1c0e4(%rip), %rdi     # 0x25fc8
leaq 0xdccd(%rip), %rsi      # 0x17bb8
callq 0x5270
movq %rax, %rdi
callq 0x5160
movb $0x1, %bl
callq 0x53f0
jmp 0x9d00
leaq 0x80(%rsp), %rdi
callq 0x5d4a
leaq 0x80(%rsp), %rdi
callq 0xa124
leaq 0x18(%rsp), %rdi
callq 0x54c8
movq %rsp, %rdi
callq 0xa166
leaq 0x10(%rsp), %rdi
callq 0x8466
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
callq 0x53f0
jmp 0x9fc2
jmp 0x9fbf
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x54c8
callq 0x53f0
jmp 0x9fc2
jmp 0x9f90
movq %rax, %rbx
callq 0x53f0
jmp 0x9fc2
jmp 0x9fbf
movq %rax, %rbx
callq 0x53f0
jmp 0x9fc2
jmp 0x9fbf
movq %rax, %rbx
callq 0x53f0
jmp 0x9fc2
movq %rax, %rdi
callq 0x821a
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x8466
jmp 0x9fcf
movq %rax, %rbx
jmp 0x9fe1
jmp 0x9fbf
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x7d36
jmp 0x9fc2
jmp 0x9fbf
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xa124
leaq 0x18(%rsp), %rdi
callq 0x54c8
movq %rsp, %rdi
callq 0xa166
leaq 0x10(%rsp), %rdi
callq 0x8466
movq %rbx, %rdi
callq 0x5430