#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*/ printf(char *);
scalar_t__ scanf(char *, ...);
int showMenu() {
  int ch;
  char junkChars[256];
  printf("MENU\n");
  printf("====\n");
  printf("1. Insert word\n");
  printf("2. Auto Suggest\n");
  printf("3. Print all words\n");
  printf("4. Exit\n");
  printf("Your Choice: ");
  if (scanf("%d", &ch) == 0) {
    printf("Please type an integer...\n");
    scanf("%s", junkChars);
    return -1;
  }
  return ch;
}


x86 assembly (clang, -O0):
<showMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x0,%rax
jne    11c8 <showMenu+0xa8>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <showMenu+0xae>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showMenu>:
sub    $0x118,%rsp
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %rax,%rax
je     11af <showMenu+0x7f>
mov    0xc(%rsp),%eax
add    $0x118,%rsp
ret
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4f(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0xffffffff,%eax
add    $0x118,%rsp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"MENU\0A\00"
@.str.1 = [6 x i8] c"====\0A\00"
@.str.2 = [16 x i8] c"1. Insert word\0A\00"
@.str.3 = [17 x i8] c"2. Auto Suggest\0A\00"
@.str.4 = [20 x i8] c"3. Print all words\0A\00"
@.str.5 = [9 x i8] c"4. Exit\0A\00"
@.str.6 = [14 x i8] c"Your Choice: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [27 x i8] c"Please type an integer...\0A\00"
@.str.9 = [3 x i8] c"%s\00"
define i32 @showMenu() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%11 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %15)
store i32 -1, i32* %1
br label %19
17: ; preds = %0
%18 = load i32, i32* %2
store i32 %18, i32* %1
br label %19
19: ; preds = %17, %13
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str.6 = [14 x i8] c"Your Choice: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.9 = [3 x i8] c"%s\00"
@str = [5 x i8] c"MENU\00"
@str.10 = [5 x i8] c"====\00"
@str.11 = [15 x i8] c"1. Insert word\00"
@str.12 = [16 x i8] c"2. Auto Suggest\00"
@str.13 = [19 x i8] c"3. Print all words\00"
@str.14 = [8 x i8] c"4. Exit\00"
@str.15 = [26 x i8] c"Please type an integer...\00"
define i32 @showMenu() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.13, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.14, i64 0, i64 0))
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%12 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%16 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %4)
br label %19
17: ; preds = %0
%18 = load i32, i32* %1
br label %19
19: ; preds = %17, %14
%20 = phi i32 [ -1, %14 ], [ %18, %17 ]
ret i32 %20
}