#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*/ clean();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ insert_node(int);
int /*<<< orphan*/ print_list();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ remove_node(int);
int /*<<< orphan*/ scanf(char *, int *);
char toupper(int /*<<< orphan*/);
int main(void) {
  char ch;
  int pozitie;
  do {
    puts("\nChoose your whatever:");
    printf("I - Insert\nR - Remove\nP - Print\nQ - Quit\n");
    printf("Your choice > ");
    ch = toupper(getchar());
    clean();
    switch (ch) {
    case 'I':
      printf("Where do you want to insert something? ");
      scanf("%d", &pozitie);
      clean();
      printf("Ok, let's insert something into %d\n", pozitie);
      insert_node(pozitie);
      break;
    case 'R':
      printf("What position do you want removed: ");
      scanf("%d", &pozitie);
      clean();
      printf("Ok, let's remove the node from %d\n", pozitie);
      remove_node(pozitie);
      break;
    case 'P':
      print_list();
      break;
    case 'Q':
      puts("Goodbye then!");
      break;
    default:
      puts("Wrong choice!");
      break;
    }
  } while (ch != 'Q');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1060 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xea3(%rip),%rdi
call   1060 <printf@plt>
mov    -0x19(%rbp),%al
call   1070 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x19(%rbp),%al
mov    %cl,-0x5(%rbp)
call   1090 <clean@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffb7,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     12b4 <main+0x124>
mov    -0x18(%rbp),%rax
lea    0xdf8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe7a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10b0 <scanf@plt>
mov    $0x0,%al
call   1090 <clean@plt>
mov    -0xc(%rbp),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
call   1080 <insert_node@plt>
jmp    12c0 <main+0x130>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe37(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10b0 <scanf@plt>
mov    $0x0,%al
call   1090 <clean@plt>
mov    -0xc(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%edi
call   10a0 <remove_node@plt>
jmp    12c0 <main+0x130>
mov    $0x0,%al
call   1050 <print_list@plt>
jmp    12c0 <main+0x130>
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
jmp    12c0 <main+0x130>
lea    0xe61(%rip),%rdi
call   1040 <puts@plt>
jmp    12c5 <main+0x135>
movsbl -0x5(%rbp),%eax
cmp    $0x51,%eax
jne    119f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe86(%rip),%r14
lea    0xf57(%rip),%r15
lea    0xe8f(%rip),%rbx
lea    0xe49(%rip),%rbp
lea    0x4(%rsp),%r12
jmp    11d6 <main+0x46>
xchg   %ax,%ax
lea    0xf2b(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x51,%r13b
je     12d4 <main+0x144>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1090 <clean@plt>
movsbl %r13b,%eax
add    $0xffffffb7,%eax
cmp    $0x9,%eax
ja     11c0 <main+0x30>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xe29(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe43(%rip),%rdi
mov    %r12,%rsi
call   10b0 <scanf@plt>
xor    %eax,%eax
call   1090 <clean@plt>
mov    0x4(%rsp),%esi
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%edi
call   1080 <insert_node@plt>
jmp    11cc <main+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <print_list@plt>
jmp    11cc <main+0x3c>
nopl   0x0(%rax)
lea    0xe5d(%rip),%rdi
jmp    11c7 <main+0x37>
nopl   0x0(%rax)
lea    0xe06(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdd1(%rip),%rdi
mov    %r12,%rsi
call   10b0 <scanf@plt>
xor    %eax,%eax
call   1090 <clean@plt>
mov    0x4(%rsp),%esi
lea    0xe02(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%edi
call   10a0 <remove_node@plt>
jmp    11cc <main+0x3c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0AChoose your whatever:\00"
@.str.1 = [42 x i8] c"I - Insert\0AR - Remove\0AP - Print\0AQ - Quit\0A\00"
@.str.2 = [15 x i8] c"Your choice > \00"
@.str.3 = [40 x i8] c"Where do you want to insert something? \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [36 x i8] c"Ok, let's insert something into %d\0A\00"
@.str.6 = [36 x i8] c"What position do you want removed: \00"
@.str.7 = [35 x i8] c"Ok, let's remove the node from %d\0A\00"
@.str.8 = [14 x i8] c"Goodbye then!\00"
@.str.9 = [14 x i8] c"Wrong choice!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %36, %0
%5 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (...) @getchar()
%9 = call signext i8 @toupper(i32 %8)
store i8 %9, i8* %2
%10 = call i32 (...) @clean()
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
switch i32 %12, label %33 [
i32 73, label %13
i32 82, label %21
i32 80, label %29
i32 81, label %31
]
13: ; preds = %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%16 = call i32 (...) @clean()
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %3
%20 = call i32 @insert_node(i32 %19)
br label %35
21: ; preds = %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%24 = call i32 (...) @clean()
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %3
%28 = call i32 @remove_node(i32 %27)
br label %35
29: ; preds = %4
%30 = call i32 (...) @print_list()
br label %35
31: ; preds = %4
%32 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %35
33: ; preds = %4
%34 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %35
35: ; preds = %33, %31, %29, %21, %13
br label %36
36: ; preds = %35
%37 = load i8, i8* %2
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 81
br i1 %39, label %4, label %40
40: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"\0AChoose your whatever:\00"
@.str.2 = [15 x i8] c"Your choice > \00"
@.str.3 = [40 x i8] c"Where do you want to insert something? \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [36 x i8] c"Ok, let's insert something into %d\0A\00"
@.str.6 = [36 x i8] c"What position do you want removed: \00"
@.str.7 = [35 x i8] c"Ok, let's remove the node from %d\0A\00"
@.str.8 = [14 x i8] c"Goodbye then!\00"
@.str.9 = [14 x i8] c"Wrong choice!\00"
@str = [41 x i8] c"I - Insert\0AR - Remove\0AP - Print\0AQ - Quit\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %33, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (...) @getchar()
%8 = call signext i8 @toupper(i32 %7)
%9 = call i32 (...) @clean()
%10 = sext i8 %8 to i32
switch i32 %10, label %31 [
i32 73, label %11
i32 82, label %19
i32 80, label %27
i32 81, label %29
]
11: ; preds = %3
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%14 = call i32 (...) @clean()
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %1
%18 = call i32 @insert_node(i32 %17)
br label %33
19: ; preds = %3
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%22 = call i32 (...) @clean()
%23 = load i32, i32* %1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
%26 = call i32 @remove_node(i32 %25)
br label %33
27: ; preds = %3
%28 = call i32 (...) @print_list()
br label %33
29: ; preds = %3
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %33
31: ; preds = %3
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %33
33: ; preds = %11, %19, %27, %29, %31
%34 = icmp eq i8 %8, 81
br i1 %34, label %35, label %3
35: ; preds = %33
ret i32 0
}