#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int getch();
int /*<<< orphan*/ move(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mvaddstr(int, int, char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ title();
int main_menu() {
  title();
  mvaddstr(6, 27, "[L]oad a file");
  mvaddstr(7, 27, "[W]rite RAM to file");
  mvaddstr(8, 27, "[D]isply RAM");
  mvaddstr(9, 27, "[F]ill RAM with blank state (0xFFFF)");
  mvaddstr(11, 27, "[R]ead contents of PIC into RAM");
  mvaddstr(12, 27, "[P]rogram PIC from RAM");
  mvaddstr(13, 27, "[V]erify PIC with RAM");
  mvaddstr(15, 27, "[C]onfigure PICPRG");
  mvaddstr(16, 27, "[Q]uit");
  move(0, 0);
  refresh();
  return getch();
}


x86 assembly (clang, -O0):
<main_menu>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <title@plt>
mov    $0x6,%edi
mov    $0x1b,%esi
lea    0xe94(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0x7,%edi
mov    $0x1b,%esi
lea    0xe8c(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0x8,%edi
mov    $0x1b,%esi
lea    0xe8a(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0x9,%edi
mov    $0x1b,%esi
lea    0xe81(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0xb,%edi
mov    $0x1b,%esi
lea    0xe90(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0xc,%edi
mov    $0x1b,%esi
lea    0xe9a(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0xd,%edi
mov    $0x1b,%esi
lea    0xe9b(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0xf,%edi
mov    $0x1b,%esi
lea    0xe9b(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0x10,%edi
mov    $0x1b,%esi
lea    0xe98(%rip),%rdx
call   1060 <mvaddstr@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1070 <move@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x0,%al
call   1050 <getch@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_menu>:
push   %rax
xor    %eax,%eax
call   1030 <title@plt>
lea    0xea1(%rip),%rdx
mov    $0x6,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
lea    0xe99(%rip),%rdx
mov    $0x7,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
lea    0xe97(%rip),%rdx
mov    $0x8,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
lea    0xe8e(%rip),%rdx
mov    $0x9,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
lea    0xe9d(%rip),%rdx
mov    $0xb,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
lea    0xea7(%rip),%rdx
mov    $0xc,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
lea    0xea8(%rip),%rdx
mov    $0xd,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
lea    0xea8(%rip),%rdx
mov    $0xf,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
lea    0xea5(%rip),%rdx
mov    $0x10,%edi
mov    $0x1b,%esi
call   1060 <mvaddstr@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1070 <move@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <getch@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"[L]oad a file\00"
@.str.1 = [20 x i8] c"[W]rite RAM to file\00"
@.str.2 = [13 x i8] c"[D]isply RAM\00"
@.str.3 = [37 x i8] c"[F]ill RAM with blank state (0xFFFF)\00"
@.str.4 = [32 x i8] c"[R]ead contents of PIC into RAM\00"
@.str.5 = [23 x i8] c"[P]rogram PIC from RAM\00"
@.str.6 = [22 x i8] c"[V]erify PIC with RAM\00"
@.str.7 = [19 x i8] c"[C]onfigure PICPRG\00"
@.str.8 = [7 x i8] c"[Q]uit\00"
define i32 @main_menu() {
%1 = call i32 (...) @title()
%2 = call i32 @mvaddstr(i32 6, i32 27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @mvaddstr(i32 7, i32 27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @mvaddstr(i32 8, i32 27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @mvaddstr(i32 9, i32 27, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @mvaddstr(i32 11, i32 27, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @mvaddstr(i32 12, i32 27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @mvaddstr(i32 13, i32 27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @mvaddstr(i32 15, i32 27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%10 = call i32 @mvaddstr(i32 16, i32 27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%11 = call i32 @move(i32 0, i32 0)
%12 = call i32 (...) @refresh()
%13 = call i32 (...) @getch()
ret i32 %13
}

LLVM IR (-O2):
@.str = [14 x i8] c"[L]oad a file\00"
@.str.1 = [20 x i8] c"[W]rite RAM to file\00"
@.str.2 = [13 x i8] c"[D]isply RAM\00"
@.str.3 = [37 x i8] c"[F]ill RAM with blank state (0xFFFF)\00"
@.str.4 = [32 x i8] c"[R]ead contents of PIC into RAM\00"
@.str.5 = [23 x i8] c"[P]rogram PIC from RAM\00"
@.str.6 = [22 x i8] c"[V]erify PIC with RAM\00"
@.str.7 = [19 x i8] c"[C]onfigure PICPRG\00"
@.str.8 = [7 x i8] c"[Q]uit\00"
define i32 @main_menu() {
%1 = tail call i32 (...) @title()
%2 = tail call i32 @mvaddstr(i32 6, i32 27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @mvaddstr(i32 7, i32 27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @mvaddstr(i32 8, i32 27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @mvaddstr(i32 9, i32 27, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @mvaddstr(i32 11, i32 27, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @mvaddstr(i32 12, i32 27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%8 = tail call i32 @mvaddstr(i32 13, i32 27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%9 = tail call i32 @mvaddstr(i32 15, i32 27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%10 = tail call i32 @mvaddstr(i32 16, i32 27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%11 = tail call i32 @move(i32 0, i32 0)
%12 = tail call i32 (...) @refresh()
%13 = tail call i32 (...) @getch()
ret i32 %13
}