// File: /workspace/github_cpp_makefile_star2_O1/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 0x110(%rsp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x2110
leaq 0x1a8e(%rip), %r15      # 0x52e8
leaq 0x1b62(%rip), %r12      # 0x53c3
movq 0x4778(%rip), %r13      # 0x7fe0
leaq 0x1ad1(%rip), %rbx      # 0x5340
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 0x3905
leal -0x4b(%rax), %ecx
cmpl $0x9, %ecx
ja 0x3916
leaq 0x1a1c(%rip), %rdx      # 0x5318
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
leal -0x6b(%rax), %ecx
cmpl $0x9, %ecx
ja 0x392d
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
cmpl $0x42, %eax
je 0x3b43
cmpl $0x43, %eax
jne 0x386f
jmp 0x3b9d
cmpl $0x62, %eax
je 0x3b43
cmpl $0x63, %eax
jne 0x386f
jmp 0x3b9d
movq %r14, %rdi
callq 0x2190
leaq 0x1aef(%rip), %rcx      # 0x5442
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 0x1ac6(%rip), %rdi      # 0x5453
callq 0x2220
testq %rax, %rax
jne 0x39a3
leaq 0x1abc(%rip), %rdi      # 0x545a
callq 0x2220
testq %rax, %rax
je 0x3b9d
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 0x3a32
movq %r14, %rdi
callq 0x2190
leaq 0x1a0a(%rip), %rcx      # 0x5409
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 0x2628
jmp 0x3b95
movq %r14, %rdi
callq 0x2190
leaq 0x1a22(%rip), %rcx      # 0x5478
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 0x2886
jmp 0x3b9d
movq %r14, %rdi
callq 0x2190
leaq 0x196e(%rip), %rcx      # 0x5418
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 0x273e
jmp 0x3b95
movq %r14, %rdi
callq 0x2190
leaq 0x1960(%rip), %rcx      # 0x5461
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 0x2834
jmp 0x3b9d
movq %r14, %rdi
callq 0x2190
leaq 0x18da(%rip), %rcx      # 0x542c
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 0x27b8
movq %rbx, %rdi
callq 0x2566
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq