#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*/ clear();
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int showMenu(char *prefix, char *title, char **options, int numOptions) {
  int selection;
  clear();
  puts(prefix);
  puts("---");
  puts(title);
  for (int i = 0; i < numOptions; i++) {
    printf("%i. %s\n", i + 1, options[i]);
  }
  printf("Make a selection[1-%i]: ", numOptions);
  scanf("%i", &selection);
  return selection;
}


x86 assembly (clang, -O0):
<showMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <clear@plt>
mov    -0x8(%rbp),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bd <showMenu+0x7d>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1183 <showMenu+0x43>
mov    -0x1c(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe50(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showMenu>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %eax,%eax
call   1060 <clear@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
test   %r14d,%r14d
jle    11a9 <showMenu+0x69>
mov    %r14d,%ebx
lea    0xe7a(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r12,%rbp,8),%rdx
add    $0x1,%rbp
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbp,%rbx
jne    1190 <showMenu+0x50>
lea    0xe5c(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe64(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"---\00"
@.str.1 = [8 x i8] c"%i. %s\0A\00"
@.str.2 = [25 x i8] c"Make a selection[1-%i]: \00"
@.str.3 = [3 x i8] c"%i\00"
define i32 @showMenu(i8* %0, i8* %1, i8** %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
store i32 %3, i32* %8
%11 = call i32 (...) @clear()
%12 = load i8*, i8** %5
%13 = call i32 @puts(i8* %12)
%14 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %6
%16 = call i32 @puts(i8* %15)
store i32 0, i32* %10
br label %17
17: ; preds = %30, %4
%18 = load i32, i32* %10
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i32, i32* %10
%23 = add nsw i32 %22, 1
%24 = load i8**, i8*** %7
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %28)
br label %30
30: ; preds = %21
%31 = load i32, i32* %10
%32 = add nsw i32 %31, 1
store i32 %32, i32* %10
br label %17
33: ; preds = %17
%34 = load i32, i32* %8
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%37 = load i32, i32* %9
ret i32 %37
}

LLVM IR (-O2):
@.str = [4 x i8] c"---\00"
@.str.1 = [8 x i8] c"%i. %s\0A\00"
@.str.2 = [25 x i8] c"Make a selection[1-%i]: \00"
@.str.3 = [3 x i8] c"%i\00"
define i32 @showMenu(i8* nocapture %0, i8* nocapture %1, i8** nocapture %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i32 (...) @clear()
%8 = tail call i32 @puts(i8* dereferenceable(1) %0)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) %1)
%11 = icmp sgt i32 %3, 0
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = zext i32 %3 to i64
br label %18
14: ; preds = %18, %4
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%17 = load i32, i32* %5
ret i32 %17
18: ; preds = %12, %18
%19 = phi i64 [ 0, %12 ], [ %20, %18 ]
%20 = add nuw nsw i64 %19, 1
%21 = getelementptr inbounds i8*, i8** %2, i64 %19
%22 = load i8*, i8** %21
%23 = trunc i64 %20 to i32
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %22)
%25 = icmp eq i64 %20, %13
br i1 %25, label %14, label %18
}