#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*/ A_BOLD;
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_GREEN;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ COLOR_RED;
scalar_t__ FALSE;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ clear();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int);
int getch();
scalar_t__ has_colors();
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ start_color();
int main(int argc, char *argv[]) {
  bool valid;
  initscr();
  cbreak();
  noecho();
  if (has_colors() == FALSE) {
    printw("No colors in your terminal. Would you mind noticing that we live "
           "in 21st century?");
    exit(1);
  }
  start_color();
  init_pair(1, COLOR_GREEN, COLOR_BLACK);
  init_pair(2, COLOR_RED, COLOR_BLACK);
  printw("Welcome to Stan's Diner!\n"
         "1. Coffee\n"
         "2. Tea\n"
         "3. Fried Eggs\n\n");
  do {
    attron(A_BOLD);
    switch (getch()) {
    case '1':
      attron(COLOR_PAIR(1));
      printw("You chose Coffee\n");
      attroff(COLOR_PAIR(1));
      valid = true;
      break;
    case '2':
      attron(COLOR_PAIR(1));
      printw("You chose Tea\n");
      attroff(COLOR_PAIR(1));
      valid = true;
      break;
    case '3':
      attron(COLOR_PAIR(1));
      printw("You chose Fried Eggs\n");
      attroff(COLOR_PAIR(1));
      valid = true;
      break;
    default:
      clear();
      attroff(A_BOLD);
      printw("Welcome to Stan's Diner!\n"
             "1. Coffee\n"
             "2. Tea\n"
             "3. Fried Eggs\n\n");
      attron(A_BOLD);
      attron(COLOR_PAIR(2));
      printw("Wrong choice!");
      attroff(COLOR_PAIR(2));
      valid = false;
    }
    attroff(A_BOLD);
  } while (!valid);
  printw("Press any key to exit\n");
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <initscr@plt>
mov    $0x0,%al
call   1050 <cbreak@plt>
mov    $0x0,%al
call   10e0 <noecho@plt>
mov    $0x0,%al
call   1040 <has_colors@plt>
mov    0x2db7(%rip),%rcx
cmp    (%rcx),%rax
jne    1238 <main+0x58>
lea    0xdd7(%rip),%rdi
call   10a0 <printw@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    $0x0,%al
call   1080 <start_color@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%esi
mov    0x2d99(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
mov    0x2d7d(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
lea    0xdd4(%rip),%rdi
call   10a0 <printw@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
call   1090 <attron@plt>
xor    %eax,%eax
call   10c0 <getch@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
sub    $0x31,%eax
je     12cd <main+0xed>
jmp    12ab <main+0xcb>
mov    -0x18(%rbp),%eax
sub    $0x32,%eax
je     1307 <main+0x127>
jmp    12bc <main+0xdc>
mov    -0x18(%rbp),%eax
sub    $0x33,%eax
je     1341 <main+0x161>
jmp    137b <main+0x19b>
mov    $0x1,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
lea    0xda7(%rip),%rdi
call   10a0 <printw@plt>
mov    $0x1,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
movl   $0x1,-0x14(%rbp)
jmp    13df <main+0x1ff>
mov    $0x1,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
lea    0xd7f(%rip),%rdi
call   10a0 <printw@plt>
mov    $0x1,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
movl   $0x1,-0x14(%rbp)
jmp    13df <main+0x1ff>
mov    $0x1,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
lea    0xd54(%rip),%rdi
call   10a0 <printw@plt>
mov    $0x1,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
movl   $0x1,-0x14(%rbp)
jmp    13df <main+0x1ff>
mov    $0x0,%al
call   1100 <clear@plt>
mov    0x2c3f(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
lea    0xcbb(%rip),%rdi
call   10a0 <printw@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
call   1090 <attron@plt>
mov    $0x2,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
lea    0xd01(%rip),%rdi
call   10a0 <printw@plt>
mov    $0x2,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
movl   $0x0,-0x14(%rbp)
mov    0x2be2(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1283 <main+0xa3>
lea    0xccc(%rip),%rdi
call   10a0 <printw@plt>
mov    $0x0,%al
call   10c0 <getch@plt>
mov    $0x0,%al
call   10d0 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1070 <initscr@plt>
xor    %eax,%eax
call   1050 <cbreak@plt>
xor    %eax,%eax
call   10e0 <noecho@plt>
xor    %eax,%eax
call   1040 <has_colors@plt>
mov    0x2dc8(%rip),%rcx
cmp    (%rcx),%rax
je     1339 <main+0x159>
xor    %eax,%eax
call   1080 <start_color@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
mov    0x2dc0(%rip),%rbx
mov    (%rbx),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
lea    0xe02(%rip),%r14
mov    %r14,%rdi
call   10a0 <printw@plt>
mov    0x2d69(%rip),%rbx
lea    0xe5d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edi
call   1090 <attron@plt>
xor    %eax,%eax
call   10c0 <getch@plt>
add    $0xffffffcf,%eax
cmp    $0x3,%eax
jb     12d6 <main+0xf6>
xor    %eax,%eax
call   1100 <clear@plt>
mov    (%rbx),%edi
call   1030 <attroff@plt>
mov    %r14,%rdi
call   10a0 <printw@plt>
mov    (%rbx),%edi
call   1090 <attron@plt>
mov    $0x2,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
mov    %r15,%rdi
call   10a0 <printw@plt>
mov    $0x2,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    (%rbx),%edi
call   1030 <attroff@plt>
jmp    1270 <main+0x90>
cltq
lea    0xe09(%rip),%rcx
movslq (%rcx,%rax,4),%r14
add    %rcx,%r14
mov    $0x1,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1090 <attron@plt>
mov    %r14,%rdi
call   10a0 <printw@plt>
mov    $0x1,%edi
call   10b0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    (%rbx),%edi
call   1030 <attroff@plt>
lea    0xdb3(%rip),%rdi
call   10a0 <printw@plt>
xor    %eax,%eax
call   10c0 <getch@plt>
xor    %eax,%eax
call   10d0 <endwin@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xcc0(%rip),%rdi
call   10a0 <printw@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@FALSE = global i64 0
@.str = [82 x i8] c"No colors in your terminal. Would you mind noticing that we live in 21st century?\00"
@COLOR_GREEN = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_RED = global i32 0
@.str.1 = [58 x i8] c"Welcome to Stan's Diner!\0A1. Coffee\0A2. Tea\0A3. Fried Eggs\0A\0A\00"
@A_BOLD = global i32 0
@.str.2 = [18 x i8] c"You chose Coffee\0A\00"
@.str.3 = [15 x i8] c"You chose Tea\0A\00"
@.str.4 = [22 x i8] c"You chose Fried Eggs\0A\00"
@.str.5 = [14 x i8] c"Wrong choice!\00"
@.str.6 = [23 x i8] c"Press any key to exit\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @initscr()
%8 = call i32 (...) @cbreak()
%9 = call i32 (...) @noecho()
%10 = call i64 (...) @has_colors()
%11 = load i64, i64* @FALSE
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 @printw(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i32 (...) @start_color()
%18 = load i32, i32* @COLOR_GREEN
%19 = load i32, i32* @COLOR_BLACK
%20 = call i32 @init_pair(i32 1, i32 %18, i32 %19)
%21 = load i32, i32* @COLOR_RED
%22 = load i32, i32* @COLOR_BLACK
%23 = call i32 @init_pair(i32 2, i32 %21, i32 %22)
%24 = call i32 @printw(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %62, %16
%26 = load i32, i32* @A_BOLD
%27 = call i32 @attron(i32 %26)
%28 = call i32 (...) @getch()
switch i32 %28, label %47 [
i32 49, label %29
i32 50, label %35
i32 51, label %41
]
29: ; preds = %25
%30 = call i32 @COLOR_PAIR(i32 1)
%31 = call i32 @attron(i32 %30)
%32 = call i32 @printw(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @COLOR_PAIR(i32 1)
%34 = call i32 @attroff(i32 %33)
store i32 1, i32* %6
br label %59
35: ; preds = %25
%36 = call i32 @COLOR_PAIR(i32 1)
%37 = call i32 @attron(i32 %36)
%38 = call i32 @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 @COLOR_PAIR(i32 1)
%40 = call i32 @attroff(i32 %39)
store i32 1, i32* %6
br label %59
41: ; preds = %25
%42 = call i32 @COLOR_PAIR(i32 1)
%43 = call i32 @attron(i32 %42)
%44 = call i32 @printw(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%45 = call i32 @COLOR_PAIR(i32 1)
%46 = call i32 @attroff(i32 %45)
store i32 1, i32* %6
br label %59
47: ; preds = %25
%48 = call i32 (...) @clear()
%49 = load i32, i32* @A_BOLD
%50 = call i32 @attroff(i32 %49)
%51 = call i32 @printw(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%52 = load i32, i32* @A_BOLD
%53 = call i32 @attron(i32 %52)
%54 = call i32 @COLOR_PAIR(i32 2)
%55 = call i32 @attron(i32 %54)
%56 = call i32 @printw(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%57 = call i32 @COLOR_PAIR(i32 2)
%58 = call i32 @attroff(i32 %57)
store i32 0, i32* %6
br label %59
59: ; preds = %47, %41, %35, %29
%60 = load i32, i32* @A_BOLD
%61 = call i32 @attroff(i32 %60)
br label %62
62: ; preds = %59
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
%65 = xor i1 %64, true
br i1 %65, label %25, label %66
66: ; preds = %62
%67 = call i32 @printw(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%68 = call i32 (...) @getch()
%69 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@FALSE = global i64 0
@.str = [82 x i8] c"No colors in your terminal. Would you mind noticing that we live in 21st century?\00"
@COLOR_GREEN = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_RED = global i32 0
@.str.1 = [58 x i8] c"Welcome to Stan's Diner!\0A1. Coffee\0A2. Tea\0A3. Fried Eggs\0A\0A\00"
@A_BOLD = global i32 0
@.str.2 = [18 x i8] c"You chose Coffee\0A\00"
@.str.3 = [15 x i8] c"You chose Tea\0A\00"
@.str.4 = [22 x i8] c"You chose Fried Eggs\0A\00"
@.str.5 = [14 x i8] c"Wrong choice!\00"
@.str.6 = [23 x i8] c"Press any key to exit\0A\00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @cbreak()
%5 = tail call i32 (...) @noecho()
%6 = tail call i64 (...) @has_colors()
%7 = load i64, i64* @FALSE
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i32 @printw(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = tail call i32 (...) @start_color()
%14 = load i32, i32* @COLOR_GREEN
%15 = load i32, i32* @COLOR_BLACK
%16 = tail call i32 @init_pair(i32 1, i32 %14, i32 %15)
%17 = load i32, i32* @COLOR_RED
%18 = load i32, i32* @COLOR_BLACK
%19 = tail call i32 @init_pair(i32 2, i32 %17, i32 %18)
%20 = tail call i32 @printw(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %27, %12
%22 = load i32, i32* @A_BOLD
%23 = tail call i32 @attron(i32 %22)
%24 = tail call i32 (...) @getch()
%25 = add i32 %24, -49
%26 = icmp ult i32 %25, 3
br i1 %26, label %41, label %27
27: ; preds = %21
%28 = tail call i32 (...) @clear()
%29 = load i32, i32* @A_BOLD
%30 = tail call i32 @attroff(i32 %29)
%31 = tail call i32 @printw(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* @A_BOLD
%33 = tail call i32 @attron(i32 %32)
%34 = tail call i32 @COLOR_PAIR(i32 2)
%35 = tail call i32 @attron(i32 %34)
%36 = tail call i32 @printw(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%37 = tail call i32 @COLOR_PAIR(i32 2)
%38 = tail call i32 @attroff(i32 %37)
%39 = load i32, i32* @A_BOLD
%40 = tail call i32 @attroff(i32 %39)
br label %21
41: ; preds = %21
%42 = sext i32 %25 to i64
%43 = shl i64 %42, 2
%44 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %43)
%45 = tail call i32 @COLOR_PAIR(i32 1)
%46 = tail call i32 @attron(i32 %45)
%47 = tail call i32 @printw(i8* %44)
%48 = tail call i32 @COLOR_PAIR(i32 1)
%49 = tail call i32 @attroff(i32 %48)
%50 = load i32, i32* @A_BOLD
%51 = tail call i32 @attroff(i32 %50)
%52 = tail call i32 @printw(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%53 = tail call i32 (...) @getch()
%54 = tail call i32 (...) @endwin()
ret i32 0
}