#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 scanf(char *, ...);
int menu(void) {
  int code, status;
  printf("\n%s%s\n", "********************************",
         "********************************");
  printf("Enter the number of the desired hotel: \n");
  printf("1) Fairfield Arms  2) Hotel Olympic\n");
  printf("3) Chertworthy Plaza  4) The Stockton\n");
  printf("5) quit\n");
  printf("\n%s%s\n", "********************************",
         "********************************");
  while ((status = scanf("%d", &code)) != 1 || (code < 1 || code > 5)) {
    if (status != 1)
      scanf("%*s");
    printf("Enter an integer from 1 to 5, please.\n");
  }
  return code;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    0xed1(%rip),%rdx
mov    %rdx,%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
lea    0xe81(%rip),%rdx
mov    %rdx,%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
mov    $0x1,%al
cmp    $0x1,%ecx
mov    %al,-0x9(%rbp)
jne    11d4 <menu+0xb4>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0xa(%rbp)
jl     11ce <menu+0xae>
cmpl   $0x5,-0x4(%rbp)
setg   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    11e4 <menu+0xc4>
jmp    120f <menu+0xef>
cmpl   $0x1,-0x8(%rbp)
je     11fc <menu+0xdc>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1190 <menu+0x70>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%r14
lea    0xec1(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
lea    0xf20(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8b(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xf00(%rip),%rbx
lea    0xe7b(%rip),%r12
jmp    11d2 <menu+0xa2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11c0 <menu+0x90>
mov    0x4(%rsp),%eax
lea    -0x6(%rax),%ecx
cmp    $0xfffffffb,%ecx
jb     11ca <menu+0x9a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\0A%s%s\0A\00"
@.str.1 = [33 x i8] c"********************************\00"
@.str.2 = [41 x i8] c"Enter the number of the desired hotel: \0A\00"
@.str.3 = [37 x i8] c"1) Fairfield Arms 2) Hotel Olympic\0A\00"
@.str.4 = [39 x i8] c"3) Chertworthy Plaza 4) The Stockton\0A\00"
@.str.5 = [9 x i8] c"5) quit\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [4 x i8] c"%*s\00"
@.str.8 = [39 x i8] c"Enter an integer from 1 to 5, please.\0A\00"
define i32 @menu() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %27, %0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
store i32 %10, i32* %2
%11 = icmp ne i32 %10, 1
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 1
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 5
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ true, %12 ], [ %17, %15 ]
br label %20
20: ; preds = %18, %9
%21 = phi i1 [ true, %9 ], [ %19, %18 ]
br i1 %21, label %22, label %29
22: ; preds = %20
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %9
29: ; preds = %20
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [7 x i8] c"\0A%s%s\0A\00"
@.str.1 = [33 x i8] c"********************************\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [4 x i8] c"%*s\00"
@str = [40 x i8] c"Enter the number of the desired hotel: \00"
@str.9 = [36 x i8] c"1) Fairfield Arms 2) Hotel Olympic\00"
@str.10 = [38 x i8] c"3) Chertworthy Plaza 4) The Stockton\00"
@str.11 = [8 x i8] c"5) quit\00"
@str.12 = [38 x i8] c"Enter an integer from 1 to 5, please.\00"
define i32 @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.9, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.11, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %18, %0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* %1
%14 = add i32 %13, -6
%15 = icmp ult i32 %14, -5
br i1 %15, label %18, label %20
16: ; preds = %9
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %18
18: ; preds = %12, %16
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.12, i64 0, i64 0))
br label %9
20: ; preds = %12
ret i32 %13
}