// File: /workspace/github_cpp_makefile_star2_O2/BrianEnigma[P]cryptoslam/src/cryptoslam.cpp
// Function: toolsMenu(_win_st*, _win_st*, _win_st*, Cryptogram*)
void toolsMenu(WINDOW *menu, WINDOW *message, WINDOW *alphabet, Cryptogram *cr)
{
    char key;
    
    wclear(message);
    cr->paintStats(message);
    wrefresh(message);
    while (1)
    {
        wclear(menu);
        wcolor_set(menu, 1, NULL);
        wattron(menu, WA_REVERSE);
        mvwprintw(menu, 0, 0, "%s", TOOLSMENU);
        wattroff(menu, WA_REVERSE);
        wmove(menu, 0, strlen(TOOLSMENU));
        wrefresh(menu);

        noecho();
        key = getch();
        echo();
        switch(key)
        {
            case 'R':
            case 'r':
                cr->randomizeKeys();
                cr->calcPlaintext();
                return;
            case 'T':
            case 't':
                wclear(menu);
                wcolor_set(menu, 1, NULL);
                mvwprintw(menu, 0, 0, "Please wait, randomizing...");
                wmove(menu, 0, 27);
                wrefresh(menu);
                cr->randomizeMessage();
                cr->calcPlaintext();
                return;
            case 'G':
            case 'g':
                wclear(menu);
                wcolor_set(menu, 1, NULL);
                mvwprintw(menu, 0, 0, "Please wait, generating...");
                wmove(menu, 0, 27);
                wrefresh(menu);
                cr->newRandomMessage();
                cr->calcPlaintext();
                return;
            case '3':
                for (int i=0; i < 26; i++)
                    cr->set(i + 'A', ((i+13)%26) + 'A');
                cr->calcPlaintext();
                return;
            case 'C':
            case 'c':
                return;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x21c0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3232
movq %r15, %rdi
callq 0x2200
leaq 0xa3b(%rip), %r12       # 0x4491
pushq $0x38
popq %r13
movq 0x357f(%rip), %r15      # 0x6fe0
movq %r14, %rdi
callq 0x21c0
movq %r14, %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x22a0
movq %r14, %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x2100
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x855(%rip), %rcx       # 0x42e8
movq %r12, %r8
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x2270
movq %r14, %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x21e0
movq %r14, %rdi
callq 0x2200
callq 0x2210
movq (%r15), %rdi
callq 0x20c0
movl %eax, %ebp
callq 0x20a0
cmpb $0x74, %bpl
je 0x3bac
movsbl %bpl, %eax
cmpl $0x43, %eax
je 0x3c09
cmpl $0x47, %eax
je 0x3b59
cmpl $0x52, %eax
je 0x3ba2
cmpl $0x54, %eax
je 0x3bac
cmpl $0x63, %eax
je 0x3c09
cmpl $0x67, %eax
je 0x3b59
cmpl $0x72, %eax
je 0x3ba2
cmpl $0x33, %eax
jne 0x3a61
xorl %r14d, %r14d
cmpl $0x1a, %r14d
je 0x3bf3
leal 0x41(%r14), %eax
leal 0x134(%r14), %ecx
leal 0x4e(%r14), %edx
cmpl $0xd, %r14d
cmovael %ecx, %edx
movsbl %dl, %edx
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2872
incl %r14d
jmp 0x3b26
movq %r14, %rdi
callq 0x21c0
pushq $0x1
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x22a0
leaq 0x971(%rip), %rcx       # 0x44e6
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
pushq $0x1b
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x21e0
movq %r14, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x2a28
jmp 0x3bf3
movq %rbx, %rdi
callq 0x28c8
jmp 0x3bf3
movq %r14, %rdi
callq 0x21c0
pushq $0x1
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x22a0
leaq 0x902(%rip), %rcx       # 0x44ca
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
pushq $0x1b
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x21e0
movq %r14, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x293e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x252c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq