#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 /*<<< orphan*/ scanf(char *, char *);
char tolower(char);
char menu() {
  char ch;
  printf("\nD -- dodaj liczbe\n");
  printf("U -- usun liczbe\n");
  printf("P -- drukuj liste\n");
  printf("Q -- zakoncz\n");
  do {
    scanf("%c", &ch);
  } while (ch < '!' || ch > '~');
  return tolower(ch);
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x21,%ecx
mov    %al,-0x2(%rbp)
jl     1197 <menu+0x67>
movsbl -0x1(%rbp),%eax
cmp    $0x7e,%eax
setg   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
test   $0x1,%al
jne    1168 <menu+0x38>
movsbl -0x1(%rbp),%edi
call   1040 <tolower@plt>
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r14
push   %rbx
push   %rax
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xe95(%rip),%r14
lea    0x7(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movzbl 0x7(%rsp),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa2,%cl
jb     1170 <menu+0x40>
movsbl %al,%edi
call   1040 <tolower@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AD -- dodaj liczbe\0A\00"
@.str.1 = [18 x i8] c"U -- usun liczbe\0A\00"
@.str.2 = [19 x i8] c"P -- drukuj liste\0A\00"
@.str.3 = [14 x i8] c"Q -- zakoncz\0A\00"
@.str.4 = [3 x i8] c"%c\00"
define signext i8 @menu() {
%1 = alloca i8
%2 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %6
6: ; preds = %16, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
br label %8
8: ; preds = %6
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
%11 = icmp slt i32 %10, 33
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i8, i8* %1
%14 = sext i8 %13 to i32
%15 = icmp sgt i32 %14, 126
br label %16
16: ; preds = %12, %8
%17 = phi i1 [ true, %8 ], [ %15, %12 ]
br i1 %17, label %6, label %18
18: ; preds = %16
%19 = load i8, i8* %1
%20 = call signext i8 @tolower(i8 signext %19)
ret i8 %20
}

LLVM IR (-O2):
@.str.4 = [3 x i8] c"%c\00"
@str = [19 x i8] c"\0AD -- dodaj liczbe\00"
@str.5 = [17 x i8] c"U -- usun liczbe\00"
@str.6 = [18 x i8] c"P -- drukuj liste\00"
@str.7 = [13 x i8] c"Q -- zakoncz\00"
define signext i8 @menu() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
br label %6
6: ; preds = %6, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%8 = load i8, i8* %1
%9 = add i8 %8, -127
%10 = icmp ult i8 %9, -94
br i1 %10, label %6, label %11
11: ; preds = %6
%12 = call signext i8 @tolower(i8 signext %8)
ret i8 %12
}