#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*/ displayMenu();
int promptValue(char *);
int /*<<< orphan*/ puts(char *);
int promptOperation() {
  displayMenu();
  int result;
  do {
    result = promptValue("Choose an option");
    if (result >= 1 && result <= 4) {
      break;
    }
    puts("Please choose a valid option (1-4)");
  } while (true);
  return result;
}


x86 assembly (clang, -O0):
<promptOperation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <displayMenu@plt>
lea    0xeba(%rip),%rdi
call   1050 <promptValue@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jl     1167 <promptOperation+0x37>
cmpl   $0x4,-0x4(%rbp)
jg     1167 <promptOperation+0x37>
jmp    1182 <promptOperation+0x52>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%al
test   $0x1,%al
jne    113f <promptOperation+0xf>
jmp    1182 <promptOperation+0x52>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<promptOperation>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <displayMenu@plt>
lea    0xebe(%rip),%rdi
call   1050 <promptValue@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
cmp    $0x4,%ecx
jb     1178 <promptOperation+0x48>
lea    0xeb9(%rip),%r14
lea    0xea1(%rip),%rbx
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <promptValue@plt>
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
ja     1160 <promptOperation+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Choose an option\00"
@.str.1 = [35 x i8] c"Please choose a valid option (1-4)\00"
define i32 @promptOperation() {
%1 = alloca i32
%2 = call i32 (...) @displayMenu()
br label %3
3: ; preds = %13, %0
%4 = call i32 @promptValue(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp sge i32 %5, 1
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i32, i32* %1
%9 = icmp sle i32 %8, 4
br i1 %9, label %10, label %11
10: ; preds = %7
br label %14
11: ; preds = %7, %3
%12 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11
br i1 true, label %3, label %14
14: ; preds = %13, %10
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [17 x i8] c"Choose an option\00"
@.str.1 = [35 x i8] c"Please choose a valid option (1-4)\00"
define i32 @promptOperation() {
%1 = tail call i32 (...) @displayMenu()
%2 = tail call i32 @promptValue(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = add i32 %2, -1
%4 = icmp ult i32 %3, 4
br i1 %4, label %10, label %5
5: ; preds = %0, %5
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @promptValue(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = add i32 %7, -1
%9 = icmp ult i32 %8, 4
br i1 %9, label %10, label %5
10: ; preds = %5, %0
%11 = phi i32 [ %2, %0 ], [ %7, %5 ]
ret i32 %11
}