#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*/ erase();
char getch();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ mvprintw(int, int, char *);
int print_menu(int rows, int cols) {
  erase();
  char in;
  int choice = 3;
  mvprintw(rows / 2 - 6, (cols - 14) / 2, "   Snake Game");
  mvprintw(rows / 2 - 5, (cols - 14) / 2, "================");
  mvprintw(rows / 2 - 4, (cols - 14) / 2, " 1.  New Game");
  mvprintw(rows / 2 - 3, (cols - 14) / 2, " 2.  Options");
  mvprintw(rows / 2 - 2, (cols - 14) / 2, " 3.  Quit");
  mvprintw(rows / 2, (cols - 14) / 2, "input > 3");
  while (true) {
    in = getch();
    if (in == 10) {
      return choice;
    }
    if (in == '1' || in == '2' || in == '3') {
      mvaddch(rows / 2, (cols + 2) / 2, in);
      if (in == '1')
        choice = 1;
      if (in == '2')
        choice = 2;
      if (in == '3')
        choice = 3;
    }
    mvaddch(rows / 2, (cols + 4) / 2, ' ');
    mvaddch(rows / 2, (cols + 6) / 2, ' ');
    mvaddch(rows / 2, (cols + 8) / 2, ' ');
    move(rows / 2, (cols + 4) / 2);
  }
}


x86 assembly (clang, -O0):
<print_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <erase@plt>
movl   $0x3,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
sub    $0x6,%edi
mov    -0x8(%rbp),%eax
sub    $0xe,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe6d(%rip),%rdx
call   1060 <mvprintw@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
sub    $0x5,%edi
mov    -0x8(%rbp),%eax
sub    $0xe,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe4f(%rip),%rdx
call   1060 <mvprintw@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
sub    $0x4,%edi
mov    -0x8(%rbp),%eax
sub    $0xe,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe34(%rip),%rdx
call   1060 <mvprintw@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
sub    $0x3,%edi
mov    -0x8(%rbp),%eax
sub    $0xe,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe16(%rip),%rdx
call   1060 <mvprintw@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
sub    $0x2,%edi
mov    -0x8(%rbp),%eax
sub    $0xe,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xdf7(%rip),%rdx
call   1060 <mvprintw@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%eax
sub    $0xe,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xdd8(%rip),%rdx
call   1060 <mvprintw@plt>
mov    $0x0,%al
call   1040 <getch@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    1291 <print_menu+0x141>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
movsbl -0x9(%rbp),%eax
cmp    $0x31,%eax
je     12b8 <print_menu+0x168>
movsbl -0x9(%rbp),%eax
cmp    $0x32,%eax
je     12b8 <print_menu+0x168>
movsbl -0x9(%rbp),%eax
cmp    $0x33,%eax
jne    131f <print_menu+0x1cf>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movsbl -0x9(%rbp),%edx
call   1050 <mvaddch@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x31,%eax
jne    12f2 <print_menu+0x1a2>
movl   $0x1,-0x10(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x32,%eax
jne    1306 <print_menu+0x1b6>
movl   $0x2,-0x10(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x33,%eax
jne    131a <print_menu+0x1ca>
movl   $0x3,-0x10(%rbp)
jmp    131f <print_menu+0x1cf>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%eax
add    $0x4,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%eax
add    $0x6,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%eax
add    $0x8,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%eax
add    $0x4,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1070 <move@plt>
jmp    1271 <print_menu+0x121>

x86 assembly (clang, -O2):
<print_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <erase@plt>
mov    %ebp,%ebx
shr    $0x1f,%ebx
add    %ebp,%ebx
sar    %ebx
lea    -0x6(%rbx),%edi
lea    -0xe(%r14),%eax
shr    $0x1f,%eax
lea    (%r14,%rax,1),%ebp
add    $0xfffffff2,%ebp
sar    %ebp
lea    0xe76(%rip),%rdx
mov    %ebp,%esi
call   1060 <mvprintw@plt>
lea    -0x5(%rbx),%edi
lea    0xe73(%rip),%rdx
mov    %ebp,%esi
call   1060 <mvprintw@plt>
lea    -0x4(%rbx),%edi
lea    0xe73(%rip),%rdx
mov    %ebp,%esi
call   1060 <mvprintw@plt>
lea    -0x3(%rbx),%edi
lea    0xe70(%rip),%rdx
mov    %ebp,%esi
call   1060 <mvprintw@plt>
lea    -0x2(%rbx),%edi
lea    0xe6c(%rip),%rdx
mov    %ebp,%esi
call   1060 <mvprintw@plt>
lea    0xe68(%rip),%rdx
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <mvprintw@plt>
xor    %eax,%eax
call   1040 <getch@plt>
mov    $0x3,%r15d
cmp    $0xa,%al
jne    1208 <print_menu+0xb8>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0x2(%r14),%eax
shr    $0x1f,%eax
add    %r14d,%eax
add    $0x2,%eax
sar    %eax
mov    %eax,0x4(%rsp)
lea    0x4(%r14),%eax
shr    $0x1f,%eax
lea    (%r14,%rax,1),%r13d
add    $0x4,%r13d
sar    %r13d
lea    0x6(%r14),%eax
shr    $0x1f,%eax
lea    (%r14,%rax,1),%r12d
add    $0x6,%r12d
sar    %r12d
mov    %r14d,%eax
add    $0x8,%eax
shr    $0x1f,%eax
add    %eax,%r14d
add    $0x8,%r14d
sar    %r14d
mov    $0x3,%r15d
jmp    12a8 <print_menu+0x158>
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r13d,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    %ebx,%edi
mov    %r12d,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    %ebx,%edi
mov    %r14d,%esi
mov    $0x20,%edx
call   1050 <mvaddch@plt>
mov    %ebx,%edi
mov    %r13d,%esi
call   1070 <move@plt>
xor    %eax,%eax
call   1040 <getch@plt>
mov    %eax,%ebp
cmp    $0xa,%al
je     11f6 <print_menu+0xa6>
lea    -0x31(%rbp),%eax
cmp    $0x2,%al
ja     1260 <print_menu+0x110>
movsbl %bpl,%edx
mov    %ebx,%edi
mov    0x4(%rsp),%esi
call   1050 <mvaddch@plt>
cmp    $0x31,%bpl
mov    $0x1,%eax
cmove  %eax,%r15d
cmp    $0x32,%bpl
mov    $0x2,%eax
cmove  %eax,%r15d
cmp    $0x33,%bpl
mov    $0x3,%eax
cmove  %eax,%r15d
jmp    1260 <print_menu+0x110>

LLVM IR (-O0):
@.str = [14 x i8] c" Snake Game\00"
@.str.1 = [17 x i8] c"================\00"
@.str.2 = [14 x i8] c" 1. New Game\00"
@.str.3 = [13 x i8] c" 2. Options\00"
@.str.4 = [10 x i8] c" 3. Quit\00"
@.str.5 = [10 x i8] c"input > 3\00"
define i32 @print_menu(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i32 (...) @erase()
store i32 3, i32* %6
%8 = load i32, i32* %3
%9 = sdiv i32 %8, 2
%10 = sub nsw i32 %9, 6
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 14
%13 = sdiv i32 %12, 2
%14 = call i32 @mvprintw(i32 %10, i32 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = sdiv i32 %15, 2
%17 = sub nsw i32 %16, 5
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 14
%20 = sdiv i32 %19, 2
%21 = call i32 @mvprintw(i32 %17, i32 %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %3
%23 = sdiv i32 %22, 2
%24 = sub nsw i32 %23, 4
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 14
%27 = sdiv i32 %26, 2
%28 = call i32 @mvprintw(i32 %24, i32 %27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* %3
%30 = sdiv i32 %29, 2
%31 = sub nsw i32 %30, 3
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 14
%34 = sdiv i32 %33, 2
%35 = call i32 @mvprintw(i32 %31, i32 %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* %3
%37 = sdiv i32 %36, 2
%38 = sub nsw i32 %37, 2
%39 = load i32, i32* %4
%40 = sub nsw i32 %39, 14
%41 = sdiv i32 %40, 2
%42 = call i32 @mvprintw(i32 %38, i32 %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%43 = load i32, i32* %3
%44 = sdiv i32 %43, 2
%45 = load i32, i32* %4
%46 = sub nsw i32 %45, 14
%47 = sdiv i32 %46, 2
%48 = call i32 @mvprintw(i32 %44, i32 %47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %2, %91
%50 = call signext i8 (...) @getch()
store i8 %50, i8* %5
%51 = load i8, i8* %5
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 10
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = load i32, i32* %6
ret i32 %55
56: ; preds = %49
%57 = load i8, i8* %5
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 49
br i1 %59, label %68, label %60
60: ; preds = %56
%61 = load i8, i8* %5
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 50
br i1 %63, label %68, label %64
64: ; preds = %60
%65 = load i8, i8* %5
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 51
br i1 %67, label %68, label %91
68: ; preds = %64, %60, %56
%69 = load i32, i32* %3
%70 = sdiv i32 %69, 2
%71 = load i32, i32* %4
%72 = add nsw i32 %71, 2
%73 = sdiv i32 %72, 2
%74 = load i8, i8* %5
%75 = call i32 @mvaddch(i32 %70, i32 %73, i8 signext %74)
%76 = load i8, i8* %5
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 49
br i1 %78, label %79, label %80
79: ; preds = %68
store i32 1, i32* %6
br label %80
80: ; preds = %79, %68
%81 = load i8, i8* %5
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 50
br i1 %83, label %84, label %85
84: ; preds = %80
store i32 2, i32* %6
br label %85
85: ; preds = %84, %80
%86 = load i8, i8* %5
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 51
br i1 %88, label %89, label %90
89: ; preds = %85
store i32 3, i32* %6
br label %90
90: ; preds = %89, %85
br label %91
91: ; preds = %90, %64
%92 = load i32, i32* %3
%93 = sdiv i32 %92, 2
%94 = load i32, i32* %4
%95 = add nsw i32 %94, 4
%96 = sdiv i32 %95, 2
%97 = call i32 @mvaddch(i32 %93, i32 %96, i8 signext 32)
%98 = load i32, i32* %3
%99 = sdiv i32 %98, 2
%100 = load i32, i32* %4
%101 = add nsw i32 %100, 6
%102 = sdiv i32 %101, 2
%103 = call i32 @mvaddch(i32 %99, i32 %102, i8 signext 32)
%104 = load i32, i32* %3
%105 = sdiv i32 %104, 2
%106 = load i32, i32* %4
%107 = add nsw i32 %106, 8
%108 = sdiv i32 %107, 2
%109 = call i32 @mvaddch(i32 %105, i32 %108, i8 signext 32)
%110 = load i32, i32* %3
%111 = sdiv i32 %110, 2
%112 = load i32, i32* %4
%113 = add nsw i32 %112, 4
%114 = sdiv i32 %113, 2
%115 = call i32 @move(i32 %111, i32 %114)
br label %49
}

LLVM IR (-O2):
@.str = [14 x i8] c" Snake Game\00"
@.str.1 = [17 x i8] c"================\00"
@.str.2 = [14 x i8] c" 1. New Game\00"
@.str.3 = [13 x i8] c" 2. Options\00"
@.str.4 = [10 x i8] c" 3. Quit\00"
@.str.5 = [10 x i8] c"input > 3\00"
define i32 @print_menu(i32 %0, i32 %1) {
%3 = tail call i32 (...) @erase()
%4 = sdiv i32 %0, 2
%5 = add nsw i32 %4, -6
%6 = add nsw i32 %1, -14
%7 = sdiv i32 %6, 2
%8 = tail call i32 @mvprintw(i32 %5, i32 %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = add nsw i32 %4, -5
%10 = tail call i32 @mvprintw(i32 %9, i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = add nsw i32 %4, -4
%12 = tail call i32 @mvprintw(i32 %11, i32 %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%13 = add nsw i32 %4, -3
%14 = tail call i32 @mvprintw(i32 %13, i32 %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%15 = add nsw i32 %4, -2
%16 = tail call i32 @mvprintw(i32 %15, i32 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i32 @mvprintw(i32 %4, i32 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%18 = tail call signext i8 (...) @getch()
%19 = icmp eq i8 %18, 10
br i1 %19, label %29, label %20
20: ; preds = %2
%21 = add nsw i32 %1, 2
%22 = sdiv i32 %21, 2
%23 = add nsw i32 %1, 4
%24 = sdiv i32 %23, 2
%25 = add nsw i32 %1, 6
%26 = sdiv i32 %25, 2
%27 = add nsw i32 %1, 8
%28 = sdiv i32 %27, 2
br label %31
29: ; preds = %44, %2
%30 = phi i32 [ 3, %2 ], [ %45, %44 ]
ret i32 %30
31: ; preds = %20, %44
%32 = phi i8 [ %18, %20 ], [ %50, %44 ]
%33 = phi i32 [ 3, %20 ], [ %45, %44 ]
%34 = add i8 %32, -49
%35 = icmp ult i8 %34, 3
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = icmp eq i8 %32, 51
%38 = icmp eq i8 %32, 50
%39 = icmp eq i8 %32, 49
%40 = tail call i32 @mvaddch(i32 %4, i32 %22, i8 signext %32)
%41 = select i1 %39, i32 1, i32 %33
%42 = select i1 %38, i32 2, i32 %41
%43 = select i1 %37, i32 3, i32 %42
br label %44
44: ; preds = %36, %31
%45 = phi i32 [ %33, %31 ], [ %43, %36 ]
%46 = tail call i32 @mvaddch(i32 %4, i32 %24, i8 signext 32)
%47 = tail call i32 @mvaddch(i32 %4, i32 %26, i8 signext 32)
%48 = tail call i32 @mvaddch(i32 %4, i32 %28, i8 signext 32)
%49 = tail call i32 @move(i32 %4, i32 %24)
%50 = tail call signext i8 (...) @getch()
%51 = icmp eq i8 %50, 10
br i1 %51, label %29, label %31
}