#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
char tolower(char);
int /*<<< orphan*/ ui_generate_report();
int /*<<< orphan*/ ui_input_menu();
void ui_menu() {
  while (1) {
    char option;
    do {
      printf("A - Load input file\n"
             "B - Generate report\n"
             "C - Print records tree\n"
             "D - Print clients list\n"
             "E - Exit\n");
      scanf("%c", &option);
      getchar();
    } while (tolower(option) < 'a' || tolower(option) > 'e');
    switch (option) {
    case 'A':
      ui_input_menu();
      break;
    case 'B':
      ui_generate_report();
      break;
    case 'C':
      break;
    case 'D':
      break;
    case 'E':
      exit(0);
    }
  }
}


x86 assembly (clang, -O0):
<ui_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
jmp    117d <ui_menu+0xd>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl -0x1(%rbp),%edi
call   1050 <tolower@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x61,%ecx
mov    %al,-0x2(%rbp)
jl     11cf <ui_menu+0x5f>
movsbl -0x1(%rbp),%edi
call   1050 <tolower@plt>
movsbl %al,%eax
cmp    $0x65,%eax
setg   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
test   $0x1,%al
jne    117d <ui_menu+0xd>
movsbl -0x1(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     122d <ui_menu+0xbd>
mov    -0x10(%rbp),%rax
lea    0xe05(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <ui_input_menu@plt>
jmp    122d <ui_menu+0xbd>
mov    $0x0,%al
call   1080 <ui_generate_report@plt>
jmp    122d <ui_menu+0xbd>
jmp    122d <ui_menu+0xbd>
jmp    122d <ui_menu+0xbd>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    1178 <ui_menu+0x8>

x86 assembly (clang, -O2):
<ui_menu>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe83(%rip),%r14
lea    0xe79(%rip),%r15
lea    0xf(%rsp),%rbx
jmp    11a0 <ui_menu+0x30>
xor    %eax,%eax
call   1080 <ui_generate_report@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
movsbl 0xf(%rsp),%edi
call   1050 <tolower@plt>
cmp    $0x61,%al
jl     11a0 <ui_menu+0x30>
movsbl 0xf(%rsp),%edi
call   1050 <tolower@plt>
cmp    $0x65,%al
jg     11a0 <ui_menu+0x30>
movsbl 0xf(%rsp),%eax
cmp    $0x41,%eax
je     11ec <ui_menu+0x7c>
cmp    $0x42,%eax
je     118e <ui_menu+0x1e>
cmp    $0x45,%eax
jne    11a0 <ui_menu+0x30>
jmp    11f5 <ui_menu+0x85>
xor    %eax,%eax
call   1060 <ui_input_menu@plt>
jmp    11a0 <ui_menu+0x30>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [96 x i8] c"A - Load input file\0AB - Generate report\0AC - Print records tree\0AD - Print clients list\0AE - Exit\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define void @ui_menu() {
%1 = alloca i8
br label %2
2: ; preds = %0, %30
br label %3
3: ; preds = %17, %2
%4 = call i32 @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%6 = call i32 (...) @getchar()
br label %7
7: ; preds = %3
%8 = load i8, i8* %1
%9 = call signext i8 @tolower(i8 signext %8)
%10 = sext i8 %9 to i32
%11 = icmp slt i32 %10, 97
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = load i8, i8* %1
%14 = call signext i8 @tolower(i8 signext %13)
%15 = sext i8 %14 to i32
%16 = icmp sgt i32 %15, 101
br label %17
17: ; preds = %12, %7
%18 = phi i1 [ true, %7 ], [ %16, %12 ]
br i1 %18, label %3, label %19
19: ; preds = %17
%20 = load i8, i8* %1
%21 = sext i8 %20 to i32
switch i32 %21, label %30 [
i32 65, label %22
i32 66, label %24
i32 67, label %26
i32 68, label %27
i32 69, label %28
]
22: ; preds = %19
%23 = call i32 (...) @ui_input_menu()
br label %30
24: ; preds = %19
%25 = call i32 (...) @ui_generate_report()
br label %30
26: ; preds = %19
br label %30
27: ; preds = %19
br label %30
28: ; preds = %19
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %19, %27, %26, %24, %22
br label %2
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@str = [95 x i8] c"A - Load input file\0AB - Generate report\0AC - Print records tree\0AD - Print clients list\0AE - Exit\00"
define void @ui_menu() {
%1 = alloca i8
br label %2
2: ; preds = %0, %24
br label %3
3: ; preds = %14, %2
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%6 = call i32 (...) @getchar()
%7 = load i8, i8* %1
%8 = call signext i8 @tolower(i8 signext %7)
%9 = icmp slt i8 %8, 97
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i8, i8* %1
%12 = call signext i8 @tolower(i8 signext %11)
%13 = icmp sgt i8 %12, 101
br i1 %13, label %14, label %15
14: ; preds = %10, %3
br label %3
15: ; preds = %10
%16 = load i8, i8* %1
%17 = sext i8 %16 to i32
switch i32 %17, label %24 [
i32 65, label %18
i32 66, label %20
i32 69, label %22
]
18: ; preds = %15
%19 = call i32 (...) @ui_input_menu()
br label %24
20: ; preds = %15
%21 = call i32 (...) @ui_generate_report()
br label %24
22: ; preds = %15
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %15, %20, %18
br label %2
}