#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 */
char EOF;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *strchr(char *, char);
char tolower(char);
char menu() {
  char ch;
  printf("Select from the following options\n"
         "a) Add a place 			b) Remove a place\n"
         "c) show places			d) Search for a place\n"
         "e) Number of places        f)To quit\n");
LABEL:
  ch = getchar();
  fflush(stdin);
  ch = tolower(ch);
  if (strchr("abcdef", ch) == NULL) {
    puts("Please enter a, b, c, d, e, or f");
    goto LABEL;
  }
  if (ch == 'f')
    ch = EOF;
  return ch;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x1(%rbp)
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
movsbl -0x1(%rbp),%edi
call   1070 <tolower@plt>
mov    %al,-0x1(%rbp)
lea    0xef4(%rip),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11c3 <menu+0x63>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
jmp    1174 <menu+0x14>
movsbl -0x1(%rbp),%eax
cmp    $0x66,%eax
jne    11dc <menu+0x7c>
mov    0x2e09(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
mov    0x2e74(%rip),%r12
mov    (%r12),%edi
call   1070 <fflush@plt>
movsbl %bl,%edi
call   1060 <tolower@plt>
mov    %eax,%ebx
movsbl %al,%esi
lea    0xe6f(%rip),%rdi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11e4 <menu+0x94>
lea    0xe65(%rip),%r14
lea    0xe57(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
mov    (%r12),%edi
call   1070 <fflush@plt>
movsbl %bl,%edi
call   1060 <tolower@plt>
mov    %eax,%ebx
movsbl %al,%esi
mov    %r15,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     11b0 <menu+0x60>
cmp    $0x66,%bl
mov    0x2df2(%rip),%rax
movzbl (%rax),%ecx
movzbl %bl,%eax
cmove  %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [147 x i8] c"Select from the following options\0Aa) Add a place \09\09\09b) Remove a place\0Ac) show places\09\09\09d) Search for a place\0Ae) Number of places f)To quit\0A\00"
@stdin = global i32 0
@.str.1 = [7 x i8] c"abcdef\00"
@.str.2 = [33 x i8] c"Please enter a, b, c, d, e, or f\00"
@EOF = global i8 0
define signext i8 @menu() {
%1 = alloca i8
%2 = call i32 @printf(i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %12, %0
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %1
%5 = load i32, i32* @stdin
%6 = call i32 @fflush(i32 %5)
%7 = load i8, i8* %1
%8 = call signext i8 @tolower(i8 signext %7)
store i8 %8, i8* %1
%9 = load i8, i8* %1
%10 = call i32* @strchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %3
14: ; preds = %3
%15 = load i8, i8* %1
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 102
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i8, i8* @EOF
store i8 %19, i8* %1
br label %20
20: ; preds = %18, %14
%21 = load i8, i8* %1
ret i8 %21
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [7 x i8] c"abcdef\00"
@.str.2 = [33 x i8] c"Please enter a, b, c, d, e, or f\00"
@EOF = global i8 0
@str = [146 x i8] c"Select from the following options\0Aa) Add a place \09\09\09b) Remove a place\0Ac) show places\09\09\09d) Search for a place\0Ae) Number of places f)To quit\00"
define signext i8 @menu() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([146 x i8], [146 x i8]* @str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = load i32, i32* @stdin
%4 = tail call i32 @fflush(i32 %3)
%5 = tail call signext i8 @tolower(i8 signext %2)
%6 = tail call i32* @strchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %16
8: ; preds = %0, %8
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call signext i8 (...) @getchar()
%11 = load i32, i32* @stdin
%12 = tail call i32 @fflush(i32 %11)
%13 = tail call signext i8 @tolower(i8 signext %10)
%14 = tail call i32* @strchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %8, label %16
16: ; preds = %8, %0
%17 = phi i8 [ %5, %0 ], [ %13, %8 ]
%18 = icmp eq i8 %17, 102
%19 = load i8, i8* @EOF
%20 = select i1 %18, i8 %19, i8 %17
ret i8 %20
}