// File: /workspace/github_cpp_makefile_star2_O1/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 0x3426
movq %r15, %rdi
callq 0x21d0
leaq 0x1703(%rip), %r15      # 0x52e8
leaq 0x18a5(%rip), %r12      # 0x5491
movq 0x43ed(%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 0x3c8e
cmpl $0x66, %eax
jle 0x3ca7
cmpl $0x67, %eax
je 0x3cd6
cmpl $0x72, %eax
je 0x3cc9
cmpl $0x74, %eax
jne 0x3bf3
jmp 0x3d35
cmpl $0x46, %eax
jg 0x3cbb
cmpl $0x33, %eax
je 0x3d82
cmpl $0x43, %eax
jne 0x3bf3
jmp 0x3d26
cmpl $0x54, %eax
je 0x3d35
cmpl $0x63, %eax
jne 0x3bf3
jmp 0x3d26
cmpl $0x47, %eax
je 0x3cd6
cmpl $0x52, %eax
jne 0x3bf3
movq %rbx, %rdi
callq 0x2976
jmp 0x3dce
movq %r14, %rdi
callq 0x2190
movq %r14, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2260
leaq 0x17f2(%rip), %rcx      # 0x54e6
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 0x2b2e
jmp 0x3dce
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 0x1777(%rip), %rcx      # 0x54ca
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 0x2a0e
jmp 0x3dce
movl $0x1a, %r14d
movb $0x4e, %r15b
movl $0xd, %r12d
movb $0x41, %bpl
movl %r12d, %eax
imulq $0x4ec4ec4f, %rax, %rax # imm = 0x4EC4EC4F
shrq $0x23, %rax
leal (%rax,%rax,4), %ecx
leal (%rcx,%rcx,4), %ecx
addl %eax, %ecx
movl %r15d, %eax
subb %cl, %al
movsbl %al, %edx
movsbl %bpl, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2908
incb %r15b
incl %r12d
incb %bpl
decl %r14d
jne 0x3d94
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2566