// File: /workspace/github_cpp_makefile_star2_O2/BrianEnigma[P]cryptoslam/src/cryptoslam.cpp
// Function: handleKey(char, _win_st*, _win_st*, _win_st*, Cryptogram*)
void handleKey(char key, 
               WINDOW *menu, 
               WINDOW *message, 
               WINDOW *alphabet, 
               Cryptogram *cr)
{
    char key1, key2;
    switch(key)
    {
        case 's':
        case 'S':
            wclear(menu);
            mvwprintw(menu, 0, 0, "Cyphertext letter to set? ");
            wrefresh(menu);
            key1 = getch();
            wclear(menu);
            mvwprintw(menu, 0, 0, "Set letter \"%c\" to which plaintext letter (spacebar to unset)? ", 
                      key1);
            wrefresh(menu);
            key2 = getch();
            cr->set(key1, key2);
            cr->calcPlaintext();
            break;
        case 'u':
        case 'U':
            wclear(menu);
            mvwprintw(menu, 0, 0, "Cyphertext letter to unset? ");
            wrefresh(menu);
            key1 = getch();
            cr->unset(key1);
            cr->calcPlaintext();
            break;
        case 'r':
        case 'R':
            for (char c = 'A'; c <= 'Z'; c++)
                cr->unset(c);
            cr->calcPlaintext();
            break;
        case 't':
        case 'T':
            toolsMenu(menu, message, alphabet, cr);
            break;
        case 'f':
        case 'F':
            fileMenu(menu, cr);
            break;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rsi, %r14
leal -0x52(%rdi), %eax
cmpl $0x3, %eax
jbe 0x3c45
leal -0x72(%rdi), %eax
cmpl $0x3, %eax
ja 0x3c73
leaq 0x73c(%rip), %rcx       # 0x4378
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x71c(%rip), %rcx       # 0x4368
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x41, %bpl
cmpb $0x5b, %bpl
je 0x3d66
movsbl %bpl, %esi
movq %rbx, %rdi
callq 0x28c0
incb %bpl
jmp 0x3c58
cmpl $0x46, %edi
je 0x3c81
cmpl $0x66, %edi
jne 0x3d78
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3692
movq %r14, %rdi
movq %rdx, %rsi
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3a20
movq %r14, %rdi
callq 0x21c0
leaq 0x89f(%rip), %rcx       # 0x455c
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x2200
movq 0x3306(%rip), %rax      # 0x6fe0
movq (%rax), %rdi
callq 0x20c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x28c0
jmp 0x3d66
movq %r14, %rdi
callq 0x21c0
leaq 0x803(%rip), %rcx       # 0x4501
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x2200
movq 0x32c5(%rip), %r15      # 0x6fe0
movq (%r15), %rdi
callq 0x20c0
movl %eax, %ebp
movq %r14, %rdi
callq 0x21c0
leaq 0x7e8(%rip), %rcx       # 0x451c
movsbl %bpl, %ebp
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x2200
movq (%r15), %rdi
callq 0x20c0
movsbl %al, %edx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2872
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x252c
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq