#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 /*<<< orphan*/ clrscr();
int /*<<< orphan*/ gotoxy(int, int /*<<< orphan*/);
int menuSelector(int, int, int);
int /*<<< orphan*/ printf(char *);
int mainMenu(void) {
  int x = 10, y = 5;
  int yStart = y;
  int selected;
  clrscr();
  gotoxy(x, y++);
  printf("New Game\n");
  gotoxy(x, y++);
  printf("High Scores\n");
  gotoxy(x, y++);
  printf("Controls\n");
  gotoxy(x, y++);
  printf("Exit\n");
  gotoxy(x, y++);
  selected = menuSelector(x, y, yStart);
  return (selected);
}


x86 assembly (clang, -O0):
<mainMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xa,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <clrscr@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
call   1050 <gotoxy@plt>
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
call   1050 <gotoxy@plt>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
call   1050 <gotoxy@plt>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
call   1050 <gotoxy@plt>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
call   1050 <gotoxy@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <menuSelector@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mainMenu>:
push   %rax
xor    %eax,%eax
call   1030 <clrscr@plt>
mov    $0xa,%edi
mov    $0x5,%esi
call   1050 <gotoxy@plt>
lea    0xea2(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
mov    $0x6,%esi
call   1050 <gotoxy@plt>
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
mov    $0x7,%esi
call   1050 <gotoxy@plt>
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
mov    $0x8,%esi
call   1050 <gotoxy@plt>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
mov    $0x9,%esi
call   1050 <gotoxy@plt>
mov    $0xa,%edi
mov    $0xa,%esi
mov    $0x5,%edx
pop    %rax
jmp    1060 <menuSelector@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"New Game\0A\00"
@.str.1 = [13 x i8] c"High Scores\0A\00"
@.str.2 = [10 x i8] c"Controls\0A\00"
@.str.3 = [6 x i8] c"Exit\0A\00"
define i32 @mainMenu() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 10, i32* %1
store i32 5, i32* %2
%5 = load i32, i32* %2
store i32 %5, i32* %3
%6 = call i32 (...) @clrscr()
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = add nsw i32 %8, 1
store i32 %9, i32* %2
%10 = call i32 @gotoxy(i32 %7, i32 %8)
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
%15 = call i32 @gotoxy(i32 %12, i32 %13)
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
%20 = call i32 @gotoxy(i32 %17, i32 %18)
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* %1
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
%25 = call i32 @gotoxy(i32 %22, i32 %23)
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
%30 = call i32 @gotoxy(i32 %27, i32 %28)
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = call i32 @menuSelector(i32 %31, i32 %32, i32 %33)
store i32 %34, i32* %4
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@str = [9 x i8] c"New Game\00"
@str.4 = [12 x i8] c"High Scores\00"
@str.5 = [9 x i8] c"Controls\00"
@str.6 = [5 x i8] c"Exit\00"
define i32 @mainMenu() {
%1 = tail call i32 (...) @clrscr()
%2 = tail call i32 @gotoxy(i32 10, i32 5)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @gotoxy(i32 10, i32 6)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 @gotoxy(i32 10, i32 7)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0))
%8 = tail call i32 @gotoxy(i32 10, i32 8)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.6, i64 0, i64 0))
%10 = tail call i32 @gotoxy(i32 10, i32 9)
%11 = tail call i32 @menuSelector(i32 10, i32 10, i32 5)
ret i32 %11
}