#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 *);
int /*<<< orphan*/ scanf(char *, int *);
int get_menu_choice(void) {
  int selection = 0;
  do {
    printf("\n");
    printf("\n1 - Beep Computer");
    printf("\n2 - Display Report");
    printf("\n3 - Quit");
    printf("\n");
    printf("\nEnter a selection: ");
    scanf("%d", &selection);
  } while (selection < 1 || selection > 3);
  return selection;
}


x86 assembly (clang, -O0):
<get_menu_choice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11a0 <get_menu_choice+0x80>
cmpl   $0x3,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    112f <get_menu_choice+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_menu_choice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeb6(%rip),%r14
lea    0xec2(%rip),%r15
lea    0xecf(%rip),%r12
lea    0xed2(%rip),%r13
lea    0xee0(%rip),%rbx
lea    0x4(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x4(%rax),%ecx
cmp    $0xfffffffd,%ecx
jb     1170 <get_menu_choice+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [19 x i8] c"\0A1 - Beep Computer\00"
@.str.2 = [20 x i8] c"\0A2 - Display Report\00"
@.str.3 = [10 x i8] c"\0A3 - Quit\00"
@.str.4 = [21 x i8] c"\0AEnter a selection: \00"
@.str.5 = [3 x i8] c"%d\00"
define i32 @get_menu_choice() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %16, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
br label %10
10: ; preds = %2
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 1
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 3
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %2, label %18
18: ; preds = %16
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"\0A1 - Beep Computer\00"
@.str.2 = [20 x i8] c"\0A2 - Display Report\00"
@.str.3 = [10 x i8] c"\0A3 - Quit\00"
@.str.4 = [21 x i8] c"\0AEnter a selection: \00"
@.str.5 = [3 x i8] c"%d\00"
define i32 @get_menu_choice() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %3, %0
%4 = call i32 @putchar(i32 10)
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @putchar(i32 10)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = add i32 %11, -4
%13 = icmp ult i32 %12, -3
br i1 %13, label %3, label %14
14: ; preds = %3
ret i32 %11
}