#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int get_menu_choice(void) {
  int selection = 0;
  do {
    puts("\n1 - Get a signed decimal integer");
    puts("2 - Get a decimal floating-point number");
    puts("3 - Get an unsigned decimal integer");
    puts("4 - Quit");
    puts("\nEnter a selection:");
    scanf("%d", &selection);
  } while (selection < 1 || selection > 4);
  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 <puts@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xefc(%rip),%rdi
call   1030 <puts@plt>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
lea    0xf11(%rip),%rdi
call   1030 <puts@plt>
lea    0xf19(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     1194 <get_menu_choice+0x74>
cmpl   $0x4,-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    0xee8(%rip),%r15
lea    0xf09(%rip),%r12
lea    0xf26(%rip),%r13
lea    0xf28(%rip),%rbx
lea    0xf35(%rip),%rbp
lea    0x4(%rsp),%r14
nopl   0x0(%rax,%rax,1)
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x5(%rax),%ecx
cmp    $0xfffffffc,%ecx
jb     1160 <get_menu_choice+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"\0A1 - Get a signed decimal integer\00"
@.str.1 = [40 x i8] c"2 - Get a decimal floating-point number\00"
@.str.2 = [36 x i8] c"3 - Get an unsigned decimal integer\00"
@.str.3 = [9 x i8] c"4 - Quit\00"
@.str.4 = [20 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 = %15, %0
%3 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
br label %9
9: ; preds = %2
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 4
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %2, label %17
17: ; preds = %15
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [34 x i8] c"\0A1 - Get a signed decimal integer\00"
@.str.1 = [40 x i8] c"2 - Get a decimal floating-point number\00"
@.str.2 = [36 x i8] c"3 - Get an unsigned decimal integer\00"
@.str.3 = [9 x i8] c"4 - Quit\00"
@.str.4 = [20 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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)
%10 = load i32, i32* %1
%11 = add i32 %10, -5
%12 = icmp ult i32 %11, -4
br i1 %12, label %3, label %13
13: ; preds = %3
ret i32 %10
}