#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*/ consumeLine();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int menu() {
  printf("\n");
  printf("Card Catalog:\n");
  printf("\n");
  printf("1: Enter\n");
  printf("2: Search by Author\n");
  printf("3: Search by Title\n");
  printf("4: Quit\n");
  printf("5: Save to Disk");
  printf("\n");
  printf(":");
  int code;
  scanf("%d", &code);
  consumeLine();
  printf("\n");
  if (!(1 <= code && code <= 5)) {
    return 0;
  }
  return code;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <consumeLine@plt>
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jg     11eb <menu+0xbb>
cmpl   $0x5,-0x8(%rbp)
jle    11f7 <menu+0xc7>
movl   $0x0,-0x4(%rbp)
jmp    11fd <menu+0xcd>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rbx
sub    $0x10,%rsp
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
lea    0xea2(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe54(%rip),%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x3a,%edi
call   1030 <putchar@plt>
lea    0xe44(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <consumeLine@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x5,%ecx
cmovb  %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [15 x i8] c"Card Catalog:\0A\00"
@.str.2 = [10 x i8] c"1: Enter\0A\00"
@.str.3 = [21 x i8] c"2: Search by Author\0A\00"
@.str.4 = [20 x i8] c"3: Search by Title\0A\00"
@.str.5 = [9 x i8] c"4: Quit\0A\00"
@.str.6 = [16 x i8] c"5: Save to Disk\00"
@.str.7 = [2 x i8] c":\00"
@.str.8 = [3 x i8] c"%d\00"
define i32 @menu() {
%1 = alloca i32
%2 = alloca i32
%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 ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%14 = call i32 (...) @consumeLine()
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = icmp sle i32 1, %16
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = load i32, i32* %2
%20 = icmp sle i32 %19, 5
br i1 %20, label %22, label %21
21: ; preds = %18, %0
store i32 0, i32* %1
br label %24
22: ; preds = %18
%23 = load i32, i32* %2
store i32 %23, i32* %1
br label %24
24: ; preds = %22, %21
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str.6 = [16 x i8] c"5: Save to Disk\00"
@.str.8 = [3 x i8] c"%d\00"
@str = [14 x i8] c"Card Catalog:\00"
@str.9 = [9 x i8] c"1: Enter\00"
@str.10 = [20 x i8] c"2: Search by Author\00"
@str.11 = [19 x i8] c"3: Search by Title\00"
@str.12 = [8 x i8] c"4: Quit\00"
define i32 @menu() {
%1 = alloca i32
%2 = tail call i32 @putchar(i32 10)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @putchar(i32 10)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32 @putchar(i32 58)
%12 = bitcast i32* %1 to i8*
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%14 = call i32 (...) @consumeLine()
%15 = call i32 @putchar(i32 10)
%16 = load i32, i32* %1
%17 = add i32 %16, -1
%18 = icmp ult i32 %17, 5
%19 = select i1 %18, i32 %16, i32 0
ret i32 %19
}