#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*/ mainMenu_opt_about();
int /*<<< orphan*/ mainMenu_opt_apps();
int /*<<< orphan*/ mainMenu_opt_help();
int showMenu(char *, char *, char **, int);
int /*<<< orphan*/ shutdown();
int mainMenu() {
  const char *const opts[] = {"Help", "About >", "Applications >", "Exit"};
  while (true) {
    int selection = showMenu("", "UOP main menu", (char **)opts, 4);
    switch (selection) {
    case 1:
      mainMenu_opt_help();
      break;
    case 2:
      mainMenu_opt_about();
      break;
    case 3:
      mainMenu_opt_apps();
      break;
    case 4:
      shutdown();
      break;
    default:
      mainMenu_opt_help();
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<mainMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2ca1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c9b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2c98(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xea0(%rip),%rdi
lea    0xe9f(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x4,%ecx
call   1040 <showMenu@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     11fc <mainMenu+0xac>
mov    -0x30(%rbp),%rax
lea    0xe3d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1050 <mainMenu_opt_help@plt>
jmp    1203 <mainMenu+0xb3>
mov    $0x0,%al
call   1070 <mainMenu_opt_about@plt>
jmp    1203 <mainMenu+0xb3>
mov    $0x0,%al
call   1060 <mainMenu_opt_apps@plt>
jmp    1203 <mainMenu+0xb3>
mov    $0x0,%al
call   1030 <shutdown@plt>
jmp    1203 <mainMenu+0xb3>
mov    $0x0,%al
call   1050 <mainMenu_opt_help@plt>
jmp    1184 <mainMenu+0x34>

x86 assembly (clang, -O2):
<mainMenu>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movaps 0x2cae(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c92(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeb2(%rip),%r14
lea    0xeb1(%rip),%r15
mov    %rsp,%r12
lea    0xe76(%rip),%rbx
jmp    1197 <mainMenu+0x47>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <mainMenu_opt_help@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    $0x4,%ecx
call   1040 <showMenu@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1190 <mainMenu+0x40>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <mainMenu_opt_about@plt>
jmp    1197 <mainMenu+0x47>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <mainMenu_opt_apps@plt>
jmp    1197 <mainMenu+0x47>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <shutdown@plt>
jmp    1197 <mainMenu+0x47>

LLVM IR (-O0):
@.str = [5 x i8] c"Help\00"
@.str.1 = [8 x i8] c"About >\00"
@.str.2 = [15 x i8] c"Applications >\00"
@.str.3 = [5 x i8] c"Exit\00"
@__const.mainMenu.opts = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [14 x i8] c"UOP main menu\00"
define i32 @mainMenu() {
%1 = alloca [4 x i8*]
%2 = alloca i32
%3 = bitcast [4 x i8*]* %1 to i8*
br label %4
4: ; preds = %0, %18
%5 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%6 = call i32 @showMenu(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %5, i32 4)
store i32 %6, i32* %2
%7 = load i32, i32* %2
switch i32 %7, label %16 [
i32 1, label %8
i32 2, label %10
i32 3, label %12
i32 4, label %14
]
8: ; preds = %4
%9 = call i32 (...) @mainMenu_opt_help()
br label %18
10: ; preds = %4
%11 = call i32 (...) @mainMenu_opt_about()
br label %18
12: ; preds = %4
%13 = call i32 (...) @mainMenu_opt_apps()
br label %18
14: ; preds = %4
%15 = call i32 (...) @shutdown()
br label %18
16: ; preds = %4
%17 = call i32 (...) @mainMenu_opt_help()
br label %18
18: ; preds = %16, %14, %12, %10, %8
br label %4
}

LLVM IR (-O2):
@.str = [5 x i8] c"Help\00"
@.str.1 = [8 x i8] c"About >\00"
@.str.2 = [15 x i8] c"Applications >\00"
@.str.3 = [5 x i8] c"Exit\00"
@__const.mainMenu.opts = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [14 x i8] c"UOP main menu\00"
define i32 @mainMenu() {
%1 = alloca [4 x i8*]
%2 = bitcast [4 x i8*]* %1 to i8*
%3 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
br label %4
4: ; preds = %16, %0
%5 = call i32 @showMenu(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %3, i32 4)
switch i32 %5, label %14 [
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
]
6: ; preds = %4
%7 = call i32 (...) @mainMenu_opt_help()
br label %16
8: ; preds = %4
%9 = call i32 (...) @mainMenu_opt_about()
br label %16
10: ; preds = %4
%11 = call i32 (...) @mainMenu_opt_apps()
br label %16
12: ; preds = %4
%13 = call i32 (...) @shutdown()
br label %16
14: ; preds = %4
%15 = call i32 (...) @mainMenu_opt_help()
br label %16
16: ; preds = %14, %12, %10, %8, %6
br label %4
}