// File: /workspace/github_cpp_makefile_star2_O3/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 0x2190
movq %rbx, %rdi
movq %r15, %rsi
callq 0x347c
movq %r15, %rdi
callq 0x21d0
leaq 0x16e7(%rip), %r15      # 0x5328
leaq 0x1889(%rip), %r12      # 0x54d1
movq 0x4391(%rip), %r13      # 0x7fe0
movq %r14, %rdi
callq 0x2190
movq %r14, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2260
movq %r14, %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x20e0
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
movl $0x40000, %esi          # imm = 0x40000
xorl %edx, %edx
callq 0x2240
movq %r14, %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x21b0
movq %r14, %rdi
callq 0x21d0
callq 0x21e0
movq (%r13), %rdi
callq 0x20b0
movl %eax, %ebp
callq 0x20a0
movsbl %bpl, %eax
cmpl $0x53, %eax
jle 0x3cea
cmpl $0x66, %eax
jle 0x3d03
cmpl $0x67, %eax
je 0x3d32
cmpl $0x72, %eax
je 0x3d25
cmpl $0x74, %eax
jne 0x3c4f
jmp 0x3d91
cmpl $0x46, %eax
jg 0x3d17
cmpl $0x33, %eax
je 0x3dde
cmpl $0x43, %eax
jne 0x3c4f
jmp 0x3d82
cmpl $0x54, %eax
je 0x3d91
cmpl $0x63, %eax
jne 0x3c4f
jmp 0x3d82
cmpl $0x47, %eax
je 0x3d32
cmpl $0x52, %eax
jne 0x3c4f
movq %rbx, %rdi
callq 0x2978
jmp 0x3e0e
movq %r14, %rdi
callq 0x2190
movq %r14, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2260
leaq 0x17d6(%rip), %rcx      # 0x5526
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
xorl %esi, %esi
movl $0x1b, %edx
callq 0x21b0
movq %r14, %rdi
callq 0x21d0
movq %rbx, %rdi
callq 0x2b8c
jmp 0x3e0e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x2190
movq %r14, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2260
leaq 0x175b(%rip), %rcx      # 0x550a
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
xorl %esi, %esi
movl $0x1b, %edx
callq 0x21b0
movq %r14, %rdi
callq 0x21d0
movq %rbx, %rdi
callq 0x2a72
jmp 0x3e0e
xorl %r14d, %r14d
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 0x290a
incl %r14d
cmpl $0x1a, %r14d
jne 0x3de1
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2566