#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 getOption() {
  int option;
  printf("\n\n   M E N U\n");
  printf("\n1. Pattern One");
  printf("\n2. Pattern Two");
  printf("\n3. Pattern Three");
  printf("\n4. Pattern Four");
  printf("\n5. Quit\n\n");
  printf("\nChoose an Option (between 1 and 5): ");
  scanf("%d", &option);
  while (option < 1 || option > 5) {
    printf("Your Option is incorrect.  Please try again.");
    printf("\nChoose an Option (between 1 and 5): ");
    scanf("%d", &option);
  }
  return option;
}


x86 assembly (clang, -O0):
<getOption>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11a5 <getOption+0x85>
cmpl   $0x5,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    11b5 <getOption+0x95>
jmp    11e2 <getOption+0xc2>
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
jmp    118c <getOption+0x6c>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getOption>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xf5a(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x6(%rax),%ecx
cmp    $0xfffffffa,%ecx
ja     11f7 <getOption+0xc7>
lea    0xebc(%rip),%r14
lea    0xe8c(%rip),%r15
lea    0xeab(%rip),%r12
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x6(%rax),%ecx
cmp    $0xfffffffb,%ecx
jb     11d0 <getOption+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0A\0A M E N U\0A\00"
@.str.1 = [16 x i8] c"\0A1. Pattern One\00"
@.str.2 = [16 x i8] c"\0A2. Pattern Two\00"
@.str.3 = [18 x i8] c"\0A3. Pattern Three\00"
@.str.4 = [17 x i8] c"\0A4. Pattern Four\00"
@.str.5 = [11 x i8] c"\0A5. Quit\0A\0A\00"
@.str.6 = [38 x i8] c"\0AChoose an Option (between 1 and 5): \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [45 x i8] c"Your Option is incorrect. Please try again.\00"
define i32 @getOption() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
br label %10
10: ; preds = %18, %0
%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, 5
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %22
18: ; preds = %16
%19 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
br label %10
22: ; preds = %16
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"\0A1. Pattern One\00"
@.str.2 = [16 x i8] c"\0A2. Pattern Two\00"
@.str.3 = [18 x i8] c"\0A3. Pattern Three\00"
@.str.4 = [17 x i8] c"\0A4. Pattern Four\00"
@.str.6 = [38 x i8] c"\0AChoose an Option (between 1 and 5): \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [45 x i8] c"Your Option is incorrect. Please try again.\00"
@str = [13 x i8] c"\0A\0A M E N U\00"
@str.9 = [10 x i8] c"\0A5. Quit\0A\00"
define i32 @getOption() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.9, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = add i32 %11, -6
%13 = icmp ult i32 %12, -5
br i1 %13, label %14, label %21
14: ; preds = %0, %14
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = add i32 %18, -6
%20 = icmp ult i32 %19, -5
br i1 %20, label %14, label %21
21: ; preds = %14, %0
%22 = phi i32 [ %11, %0 ], [ %18, %14 ]
ret i32 %22
}