#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 *);
void menu(const int blurp) {
  switch (blurp) {
  case 0: {
    printf("avaliable commands:\n");
    printf("0) Choose file\n");
    printf("1) Search\n");
    printf("2) Print\n");
    printf("3) Add\n");
    printf("4) Remove\n");
    printf("5) Show stats\n");
    printf("6) Exit\n");
    break;
  }
  case 1: {
    printf("Enter string to search\n");
    break;
  }
  case 2: {
    printf("Enter interval borders\n");
    break;
  }
  case 3: {
    printf("Enter string to add and position where it will be added\n");
    break;
  }
  case 4: {
    printf("Enter starting position and amount of symbols to delete\n");
    break;
  }
  case 5: {
    printf("Enter filename\n");
    break;
  }
  case 6: {
    printf("wrong option\n");
    break;
  }
  }
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x6,%rax
ja     1206 <menu+0xf6>
mov    -0x10(%rbp),%rax
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <menu+0xf6>
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <menu+0xf6>
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <menu+0xf6>
lea    0xee3(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <menu+0xf6>
lea    0xf0b(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <menu+0xf6>
lea    0xf33(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <menu+0xf6>
lea    0xf32(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
cmp    $0x6,%edi
ja     1192 <menu+0x82>
push   %rax
mov    %edi,%eax
lea    0xfa0(%rip),%rdi
mov    %eax,%eax
lea    0xed8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf9e(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa6(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa9(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa7(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf9f(%rip),%rdi
call   1030 <puts@plt>
lea    0xf9d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf9f(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
ret
lea    0xf0e(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xec9(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xe84(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xe68(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xe4e(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"avaliable commands:\0A\00"
@.str.1 = [16 x i8] c"0) Choose file\0A\00"
@.str.2 = [11 x i8] c"1) Search\0A\00"
@.str.3 = [10 x i8] c"2) Print\0A\00"
@.str.4 = [8 x i8] c"3) Add\0A\00"
@.str.5 = [11 x i8] c"4) Remove\0A\00"
@.str.6 = [15 x i8] c"5) Show stats\0A\00"
@.str.7 = [9 x i8] c"6) Exit\0A\00"
@.str.8 = [24 x i8] c"Enter string to search\0A\00"
@.str.9 = [24 x i8] c"Enter interval borders\0A\00"
@.str.10 = [57 x i8] c"Enter string to add and position where it will be added\0A\00"
@.str.11 = [57 x i8] c"Enter starting position and amount of symbols to delete\0A\00"
@.str.12 = [16 x i8] c"Enter filename\0A\00"
@.str.13 = [14 x i8] c"wrong option\0A\00"
define void @menu(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %25 [
i32 0, label %4
i32 1, label %13
i32 2, label %15
i32 3, label %17
i32 4, label %19
i32 5, label %21
i32 6, label %23
]
4: ; preds = %1
%5 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %25
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %25
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %25
17: ; preds = %1
%18 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.10, i64 0, i64 0))
br label %25
19: ; preds = %1
%20 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.11, i64 0, i64 0))
br label %25
21: ; preds = %1
%22 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %25
23: ; preds = %1
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0))
br label %25
25: ; preds = %1, %23, %21, %19, %17, %15, %13, %4
ret void
}

LLVM IR (-O2):
@str = [13 x i8] c"wrong option\00"
@str.14 = [15 x i8] c"Enter filename\00"
@str.15 = [56 x i8] c"Enter starting position and amount of symbols to delete\00"
@str.16 = [56 x i8] c"Enter string to add and position where it will be added\00"
@str.17 = [23 x i8] c"Enter interval borders\00"
@str.18 = [23 x i8] c"Enter string to search\00"
@str.19 = [20 x i8] c"avaliable commands:\00"
@str.20 = [15 x i8] c"0) Choose file\00"
@str.21 = [10 x i8] c"1) Search\00"
@str.22 = [9 x i8] c"2) Print\00"
@str.23 = [7 x i8] c"3) Add\00"
@str.24 = [10 x i8] c"4) Remove\00"
@str.25 = [14 x i8] c"5) Show stats\00"
@str.26 = [8 x i8] c"6) Exit\00"
define void @menu(i32 %0) {
switch i32 %0, label %18 [
i32 0, label %2
i32 1, label %15
i32 2, label %10
i32 3, label %11
i32 4, label %12
i32 5, label %13
i32 6, label %14
]
2: ; preds = %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.19, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.20, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.21, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.22, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.23, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.24, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.25, i64 0, i64 0))
br label %15
10: ; preds = %1
br label %15
11: ; preds = %1
br label %15
12: ; preds = %1
br label %15
13: ; preds = %1
br label %15
14: ; preds = %1
br label %15
15: ; preds = %1, %2, %10, %11, %12, %13, %14
%16 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), %14 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0), %13 ], [ getelementptr inbounds ([56 x i8], [56 x i8]* @str.15, i64 0, i64 0), %12 ], [ getelementptr inbounds ([56 x i8], [56 x i8]* @str.16, i64 0, i64 0), %11 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0), %10 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.26, i64 0, i64 0), %2 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.18, i64 0, i64 0), %1 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) %16)
br label %18
18: ; preds = %15, %1
ret void
}