#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(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int showMenu(char *, char *, char **, int);
int main(int argc, char *argv[]) {
  const char *const opts[] = {"Say Hello", "Exit"};
  while (true) {
    int selection = showMenu("", "App: Hello", (char **)opts, 2);
    switch (selection) {
    case 1:
      printf("Hello, world!\n");
      break;
    case 2:
      exit(0);
      break;
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2cc3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc0(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xec5(%rip),%rdi
lea    0xea5(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x2,%ecx
call   1040 <showMenu@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     11a0 <main+0x70>
jmp    118f <main+0x5f>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     11b1 <main+0x81>
jmp    11b8 <main+0x88>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
jmp    11bd <main+0x8d>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    11bd <main+0x8d>
jmp    115c <main+0x2c>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movaps 0x2cce(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeda(%rip),%r14
lea    0xebb(%rip),%r15
mov    %rsp,%rbx
lea    0xebc(%rip),%r12
jmp    1168 <main+0x38>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    $0x2,%ecx
call   1040 <showMenu@plt>
cmp    $0x1,%eax
je     1160 <main+0x30>
cmp    $0x2,%eax
jne    1168 <main+0x38>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"Say Hello\00"
@.str.1 = [5 x i8] c"Exit\00"
@__const.main.opts = [2 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"App: Hello\00"
@.str.4 = [15 x i8] c"Hello, world!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i8*]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [2 x i8*]* %6 to i8*
br label %9
9: ; preds = %2, %18
%10 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 0
%11 = call i32 @showMenu(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %10, i32 2)
store i32 %11, i32* %7
%12 = load i32, i32* %7
switch i32 %12, label %17 [
i32 1, label %13
i32 2, label %15
]
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %18
15: ; preds = %9
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %9
br label %18
18: ; preds = %17, %13
br label %9
}

LLVM IR (-O2):
@.str = [10 x i8] c"Say Hello\00"
@.str.1 = [5 x i8] c"Exit\00"
@__const.main.opts = [2 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"App: Hello\00"
@str = [14 x i8] c"Hello, world!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i8*]
%4 = bitcast [2 x i8*]* %3 to i8*
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
br label %6
6: ; preds = %8, %2
%7 = call i32 @showMenu(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %5, i32 2)
switch i32 %7, label %8 [
i32 1, label %9
i32 2, label %11
]
8: ; preds = %6, %9
br label %6
9: ; preds = %6
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %8
11: ; preds = %6
%12 = call i32 @exit(i32 0)
unreachable
}