// File: /workspace/github_cpp_makefile_star2_O3/BrianEnigma[P]cryptoslam/src/cryptoslam.cpp
// Function: fileMenu(_win_st*, Cryptogram*)
void fileMenu(WINDOW *menu, Cryptogram *cr)
{
    char filename[255];
    char key;
    char *editor = NULL;
    char command[1024] = "";
    while (1)
    {
        wclear(menu);
        wcolor_set(menu, 1, NULL);
        wattron(menu, WA_REVERSE);
        mvwprintw(menu, 0, 0, "%s", FILEMENU);
        wattroff(menu, WA_REVERSE);
        wmove(menu, 0, strlen(FILEMENU));
        wrefresh(menu);

        noecho();
        key = getch();
        echo();
        switch(key)
        {
            case 'L':
            case 'l':
                wclear(menu);
                mvwprintw(menu, 0, 0, "File to open? ");
                wrefresh(menu);
                wgetnstr(menu, filename, 255);
                filename[254] = 0;
                cr->loadFile(filename);
                cr->calcPlaintext();
                return;
            case 'T':
            case 't':
                wclear(menu);
                mvwprintw(menu, 0, 0, "Text file to save? ");
                wrefresh(menu);
                wgetnstr(menu, filename, 255);
                filename[254] = 0;
                cr->saveFileText(filename);
                cr->calcPlaintext();
                return;
            case 'B':
            case 'b':
                wclear(menu);
                mvwprintw(menu, 0, 0, "Binary file to save? ");
                wrefresh(menu);
                wgetnstr(menu, filename, 255);
                filename[254] = 0;
                cr->saveFileBinary(filename);
                cr->calcPlaintext();
                return;
            case 'N':
            case 'n':
                wclear(menu);
                mvwprintw(menu, 0, 0, "File to create? ");
                wrefresh(menu);
                wgetnstr(menu, filename, 255);
                filename[254] = 0;
                editor = getenv("VISUAL");
                if (!editor)
                    editor = getenv("EDITOR");
                if (!editor)
                    return;
                strncpy(command, editor, 512);
                strcat(command, " ");
                strcat(command, filename);
                system(command);
                cr->loadFile(filename);
                cr->calcPlaintext();
                return;
            case 'S':
            case 's':
                wclear(menu);
                mvwprintw(menu, 0, 0, "File to save keys to? ");
                wrefresh(menu);
                wgetnstr(menu, filename, 255);
                filename[254] = 0;
                cr->saveKeys(filename);
                return;
            case 'K':
            case 'k':
                wclear(menu);
                mvwprintw(menu, 0, 0, "File to load keys from? ");
                wrefresh(menu);
                wgetnstr(menu, filename, 255);
                filename[254] = 0;
                cr->loadKeys(filename);
                return;
            case 'C':
            case 'c':
                return;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x518, %rsp            # imm = 0x518
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
leaq 0x310(%rsp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x2110
leaq 0x1a72(%rip), %r15      # 0x5328
leaq 0x1b46(%rip), %r12      # 0x5403
movq 0x471c(%rip), %r13      # 0x7fe0
leaq 0x1ab5(%rip), %rbx      # 0x5380
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 $0x45, %edx
callq 0x21b0
movq %r14, %rdi
callq 0x21d0
callq 0x21e0
movq (%r13), %rdi
callq 0x20b0
movl %eax, %ebp
callq 0x20a0
movsbl %bpl, %eax
cmpl $0x61, %eax
jg 0x3961
leal -0x4b(%rax), %ecx
cmpl $0x9, %ecx
ja 0x3972
leaq 0x1a00(%rip), %rdx      # 0x5358
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
leal -0x6b(%rax), %ecx
cmpl $0x9, %ecx
ja 0x3989
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
cmpl $0x42, %eax
je 0x3b9f
cmpl $0x43, %eax
jne 0x38cb
jmp 0x3bf9
cmpl $0x62, %eax
je 0x3b9f
cmpl $0x63, %eax
jne 0x38cb
jmp 0x3bf9
movq %r14, %rdi
callq 0x2190
leaq 0x1ad3(%rip), %rcx      # 0x5482
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x21d0
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0xff, %edx
callq 0x2290
movb $0x0, 0xfe(%r15)
leaq 0x1aaa(%rip), %rdi      # 0x5493
callq 0x2220
testq %rax, %rax
jne 0x3a08
leaq 0x1aa0(%rip), %rdi      # 0x549a
callq 0x2220
testq %rax, %rax
je 0x3bf9
leaq 0x110(%rsp), %r14
movl $0x200, %edx            # imm = 0x200
movq %r14, %rdi
movq %rax, %rsi
callq 0x20f0
movq %r14, %rdi
callq 0x20d0
movw $0x20, 0x110(%rsp,%rax)
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x22e0
movq %r14, %rdi
callq 0x2140
jmp 0x3a8e
movq %r14, %rdi
callq 0x2190
leaq 0x19ee(%rip), %rcx      # 0x5449
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x21d0
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0xff, %edx
callq 0x2290
movb $0x0, 0xfe(%r15)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x262a
jmp 0x3bf1
movq %r14, %rdi
callq 0x2190
leaq 0x1a06(%rip), %rcx      # 0x54b8
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x21d0
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0xff, %edx
callq 0x2290
movb $0x0, 0xfe(%r15)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2888
jmp 0x3bf9
movq %r14, %rdi
callq 0x2190
leaq 0x1952(%rip), %rcx      # 0x5458
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x21d0
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0xff, %edx
callq 0x2290
movb $0x0, 0xfe(%r15)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2740
jmp 0x3bf1
movq %r14, %rdi
callq 0x2190
leaq 0x1944(%rip), %rcx      # 0x54a1
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x21d0
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0xff, %edx
callq 0x2290
movb $0x0, 0xfe(%r15)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2836
jmp 0x3bf9
movq %r14, %rdi
callq 0x2190
leaq 0x18be(%rip), %rcx      # 0x546c
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2070
movq %r14, %rdi
callq 0x21d0
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0xff, %edx
callq 0x2290
movb $0x0, 0xfe(%r15)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x27ba
movq %rbx, %rdi
callq 0x2566
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq