#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
short getMainMenuInput();
int /*<<< orphan*/ isValidBounds(short, int /*<<< orphan*/, int);
int /*<<< orphan*/ passwordLengthMenu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ purgeBuffer();
int /*<<< orphan*/ timeAttackMenu();
void mainMenu(void) {
  short input = getMainMenuInput();
  while (1) {
    while (!isValidBounds(input, 0, 2)) {
      purgeBuffer();
      printf("\nNot a menu option\n");
      input = getMainMenuInput();
    }
    switch (input) {
    case 1:
      timeAttackMenu();
      input = getMainMenuInput();
      break;
    case 2:
      passwordLengthMenu();
      input = getMainMenuInput();
      break;
    case 0:
      exit(EXIT_SUCCESS);
    }
  }
}


x86 assembly (clang, -O0):
<mainMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1070 <getMainMenuInput@plt>
mov    %ax,-0x2(%rbp)
jmp    1188 <mainMenu+0x18>
xor    %esi,%esi
mov    $0x2,%edx
movswl -0x2(%rbp),%edi
call   1080 <isValidBounds@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ad <mainMenu+0x3d>
jmp    11d0 <mainMenu+0x60>
mov    $0x0,%al
call   1060 <purgeBuffer@plt>
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getMainMenuInput@plt>
mov    %ax,-0x2(%rbp)
jmp    1188 <mainMenu+0x18>
movswl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
test   %eax,%eax
je     1234 <mainMenu+0xc4>
jmp    11e4 <mainMenu+0x74>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
je     1206 <mainMenu+0x96>
jmp    11f5 <mainMenu+0x85>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     121d <mainMenu+0xad>
jmp    1242 <mainMenu+0xd2>
mov    $0x0,%al
call   1040 <timeAttackMenu@plt>
mov    $0x0,%al
call   1070 <getMainMenuInput@plt>
mov    %ax,-0x2(%rbp)
jmp    1242 <mainMenu+0xd2>
mov    $0x0,%al
call   1030 <passwordLengthMenu@plt>
mov    $0x0,%al
call   1070 <getMainMenuInput@plt>
mov    %ax,-0x2(%rbp)
jmp    1242 <mainMenu+0xd2>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    1183 <mainMenu+0x13>

x86 assembly (clang, -O2):
<mainMenu>:
push   %rbp
push   %rbx
push   %rax
lea    0xe86(%rip),%rbx
jmp    1187 <mainMenu+0x17>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <passwordLengthMenu@plt>
xor    %eax,%eax
call   1070 <getMainMenuInput@plt>
mov    %eax,%ebp
movswl %bp,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %esi,%esi
mov    $0x2,%edx
call   1080 <isValidBounds@plt>
test   %eax,%eax
jne    11d0 <mainMenu+0x60>
xor    %eax,%eax
call   1060 <purgeBuffer@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1070 <getMainMenuInput@plt>
mov    %eax,%ebp
movswl %ax,%edi
jmp    11a0 <mainMenu+0x30>
nopl   (%rax)
movswl %bp,%eax
cmp    $0x1,%eax
je     11f0 <mainMenu+0x80>
cmp    $0x2,%eax
je     1180 <mainMenu+0x10>
test   %eax,%eax
jne    1190 <mainMenu+0x20>
jmp    11f9 <mainMenu+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <timeAttackMenu@plt>
jmp    1187 <mainMenu+0x17>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"\0ANot a menu option\0A\00"
@EXIT_SUCCESS = global i32 0
define void @mainMenu() {
%1 = alloca i16
%2 = call signext i16 (...) @getMainMenuInput()
store i16 %2, i16* %1
br label %3
3: ; preds = %0, %25
br label %4
4: ; preds = %9, %3
%5 = load i16, i16* %1
%6 = call i32 @isValidBounds(i16 signext %5, i32 0, i32 2)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = call i32 (...) @purgeBuffer()
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%12 = call signext i16 (...) @getMainMenuInput()
store i16 %12, i16* %1
br label %4
13: ; preds = %4
%14 = load i16, i16* %1
%15 = sext i16 %14 to i32
switch i32 %15, label %25 [
i32 1, label %16
i32 2, label %19
i32 0, label %22
]
16: ; preds = %13
%17 = call i32 (...) @timeAttackMenu()
%18 = call signext i16 (...) @getMainMenuInput()
store i16 %18, i16* %1
br label %25
19: ; preds = %13
%20 = call i32 (...) @passwordLengthMenu()
%21 = call signext i16 (...) @getMainMenuInput()
store i16 %21, i16* %1
br label %25
22: ; preds = %13
%23 = load i32, i32* @EXIT_SUCCESS
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %13, %19, %16
br label %3
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [19 x i8] c"\0ANot a menu option\00"
define void @mainMenu() {
br label %1
1: ; preds = %18, %0
%2 = tail call signext i16 (...) @getMainMenuInput()
br label %3
3: ; preds = %1, %13
%4 = phi i16 [ %14, %13 ], [ %2, %1 ]
%5 = tail call i32 @isValidBounds(i16 signext %4, i32 0, i32 2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %3, %7
%8 = tail call i32 (...) @purgeBuffer()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%10 = tail call signext i16 (...) @getMainMenuInput()
%11 = tail call i32 @isValidBounds(i16 signext %10, i32 0, i32 2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %7, label %13
13: ; preds = %7, %3
%14 = phi i16 [ %4, %3 ], [ %10, %7 ]
%15 = sext i16 %14 to i32
switch i32 %15, label %3 [
i32 1, label %16
i32 2, label %19
i32 0, label %21
]
16: ; preds = %13
%17 = tail call i32 (...) @timeAttackMenu()
br label %18
18: ; preds = %16, %19
br label %1
19: ; preds = %13
%20 = tail call i32 (...) @passwordLengthMenu()
br label %18
21: ; preds = %13
%22 = load i32, i32* @EXIT_SUCCESS
%23 = tail call i32 @exit(i32 %22)
unreachable
}