#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*/ eatline();
char getchar();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ *strchr(char *, char);
char tolower(char);
char showmenu(void) {
  char ans;
  puts("Enter menu choice:");
  puts("u) uppercase \nl) lowercase");
  puts("t) transposed case \no) original case");
  puts("n) next string \nq) quit");
  ans = getchar();
  ans = tolower(ans);
  eatline();
  while (strchr("ultonq", ans) == NULL) {
    puts("Please enter: u, l, t, o, n or q: ");
    ans = tolower(getchar());
    eatline();
  }
  return ans;
}


x86 assembly (clang, -O0):
<showmenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1070 <tolower@plt>
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1060 <eatline@plt>
lea    0xebf(%rip),%rdi
movsbl -0x1(%rbp),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11e9 <showmenu+0x99>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%edi
call   1070 <tolower@plt>
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1060 <eatline@plt>
jmp    11a5 <showmenu+0x55>
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showmenu>:
push   %r15
push   %r14
push   %rbx
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%edi
call   1070 <tolower@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <eatline@plt>
movsbl %bl,%esi
lea    0xec4(%rip),%rdi
call   1040 <strchr@plt>
test   %rax,%rax
jne    11f0 <showmenu+0xa0>
lea    0xeba(%rip),%r14
lea    0xeac(%rip),%r15
nop
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%edi
call   1070 <tolower@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <eatline@plt>
movsbl %bl,%esi
mov    %r15,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     11c0 <showmenu+0x70>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter menu choice:\00"
@.str.1 = [27 x i8] c"u) uppercase \0Al) lowercase\00"
@.str.2 = [37 x i8] c"t) transposed case \0Ao) original case\00"
@.str.3 = [24 x i8] c"n) next string \0Aq) quit\00"
@.str.4 = [7 x i8] c"ultonq\00"
@.str.5 = [35 x i8] c"Please enter: u, l, t, o, n or q: \00"
define signext i8 @showmenu() {
%1 = alloca i8
%2 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %1
%7 = load i8, i8* %1
%8 = call signext i8 @tolower(i8 signext %7)
store i8 %8, i8* %1
%9 = call i32 (...) @eatline()
br label %10
10: ; preds = %14, %0
%11 = load i8, i8* %1
%12 = call i32* @strchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8 signext %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%16 = call signext i8 (...) @getchar()
%17 = call signext i8 @tolower(i8 signext %16)
store i8 %17, i8* %1
%18 = call i32 (...) @eatline()
br label %10
19: ; preds = %10
%20 = load i8, i8* %1
ret i8 %20
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter menu choice:\00"
@.str.1 = [27 x i8] c"u) uppercase \0Al) lowercase\00"
@.str.2 = [37 x i8] c"t) transposed case \0Ao) original case\00"
@.str.3 = [24 x i8] c"n) next string \0Aq) quit\00"
@.str.4 = [7 x i8] c"ultonq\00"
@.str.5 = [35 x i8] c"Please enter: u, l, t, o, n or q: \00"
define signext i8 @showmenu() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call signext i8 (...) @getchar()
%6 = tail call signext i8 @tolower(i8 signext %5)
%7 = tail call i32 (...) @eatline()
%8 = tail call i32* @strchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8 signext %6)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %17
10: ; preds = %0, %10
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call signext i8 (...) @getchar()
%13 = tail call signext i8 @tolower(i8 signext %12)
%14 = tail call i32 (...) @eatline()
%15 = tail call i32* @strchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8 signext %13)
%16 = icmp eq i32* %15, null
br i1 %16, label %10, label %17
17: ; preds = %10, %0
%18 = phi i8 [ %6, %0 ], [ %13, %10 ]
ret i8 %18
}