#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_FAILURE;
int /*<<< orphan*/ addItem(char **, int *, int);
char **calloc(int, int);
int /*<<< orphan*/ deleteItem(char **, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char **);
char getchar();
int /*<<< orphan*/ listfreeallitems(char **, int);
int /*<<< orphan*/ listprint(char **, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  char **list;
  int count = 0;
  int capacity = 3;
  if (NULL == (list = calloc(capacity, sizeof(char *)))) {
    printf("Fehler konnte keine Speicher zu weisen!!\n");
    exit(EXIT_FAILURE);
  }
  char menusel = 0;
  do {
    printf("1 Titel hinzufuegen\n");
    printf("2 Titel entfernen\n");
    printf("3 Liste ausgeben\n");
    printf("X Ende\n");
    menusel = getchar();
    while (getchar() != '\n')
      ;
    if (menusel == '1')
      addItem(list, &count, capacity);
    if (menusel == '2')
      deleteItem(list, &count);
    if (menusel == '3')
      listprint(list, count);
  } while (menusel != 'X' && menusel != 'x');
  listfreeallitems(list, count);
  free(list);
  list = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11e6 <main+0x56>
lea    0xe2d(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movb   $0x0,-0x19(%rbp)
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
lea    0xe42(%rip),%rdi
call   1050 <printf@plt>
lea    0xe49(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %al,-0x19(%rbp)
mov    $0x0,%al
call   1070 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     123c <main+0xac>
jmp    1224 <main+0x94>
movsbl -0x19(%rbp),%eax
cmp    $0x31,%eax
jne    1259 <main+0xc9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    -0x14(%rbp),%rsi
call   1090 <addItem@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x32,%eax
jne    1273 <main+0xe3>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <deleteItem@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x33,%eax
jne    128c <main+0xfc>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10b0 <listprint@plt>
jmp    1291 <main+0x101>
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0x58,%ecx
mov    %al,-0x1a(%rbp)
je     12b0 <main+0x120>
movsbl -0x19(%rbp),%eax
cmp    $0x78,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    11ea <main+0x5a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <listfreeallitems@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
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
movl   $0x0,0x4(%rsp)
mov    $0x3,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     1296 <main+0x106>
mov    %rax,%rbx
lea    0xe3b(%rip),%r14
lea    0xe48(%rip),%r15
lea    0xe53(%rip),%r12
lea    0xe5d(%rip),%r13
jmp    11f7 <main+0x67>
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1080 <deleteItem@plt>
and    $0xdf,%bpl
cmp    $0x58,%bpl
je     1271 <main+0xe1>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0xa,%al
jne    1220 <main+0x90>
cmp    $0x33,%bpl
je     1260 <main+0xd0>
cmp    $0x32,%bpl
je     11e0 <main+0x50>
cmp    $0x31,%bpl
jne    11ed <main+0x5d>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
mov    $0x3,%edx
call   1090 <addItem@plt>
jmp    11ed <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   10b0 <listprint@plt>
jmp    11ed <main+0x5d>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1050 <listfreeallitems@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda1(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [42 x i8] c"Fehler konnte keine Speicher zu weisen!!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [21 x i8] c"1 Titel hinzufuegen\0A\00"
@.str.2 = [19 x i8] c"2 Titel entfernen\0A\00"
@.str.3 = [18 x i8] c"3 Liste ausgeben\0A\00"
@.str.4 = [8 x i8] c"X Ende\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %3
store i32 3, i32* %4
%6 = load i32, i32* %4
%7 = call i8** @calloc(i32 %6, i32 8)
store i8** %7, i8*** %2
%8 = icmp eq i8** null, %7
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
store i8 0, i8* %5
br label %14
14: ; preds = %57, %13
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%19 = call signext i8 (...) @getchar()
store i8 %19, i8* %5
br label %20
20: ; preds = %24, %14
%21 = call signext i8 (...) @getchar()
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 10
br i1 %23, label %24, label %25
24: ; preds = %20
br label %20
25: ; preds = %20
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 49
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i8**, i8*** %2
%31 = load i32, i32* %4
%32 = call i32 @addItem(i8** %30, i32* %3, i32 %31)
br label %33
33: ; preds = %29, %25
%34 = load i8, i8* %5
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 50
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i8**, i8*** %2
%39 = call i32 @deleteItem(i8** %38, i32* %3)
br label %40
40: ; preds = %37, %33
%41 = load i8, i8* %5
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 51
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8**, i8*** %2
%46 = load i32, i32* %3
%47 = call i32 @listprint(i8** %45, i32 %46)
br label %48
48: ; preds = %44, %40
br label %49
49: ; preds = %48
%50 = load i8, i8* %5
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 88
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = load i8, i8* %5
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 120
br label %57
57: ; preds = %53, %49
%58 = phi i1 [ false, %49 ], [ %56, %53 ]
br i1 %58, label %14, label %59
59: ; preds = %57
%60 = load i8**, i8*** %2
%61 = load i32, i32* %3
%62 = call i32 @listfreeallitems(i8** %60, i32 %61)
%63 = load i8**, i8*** %2
%64 = call i32 @free(i8** %63)
store i8** null, i8*** %2
ret i32 0
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@str = [20 x i8] c"1 Titel hinzufuegen\00"
@str.5 = [18 x i8] c"2 Titel entfernen\00"
@str.6 = [17 x i8] c"3 Liste ausgeben\00"
@str.7 = [7 x i8] c"X Ende\00"
@str.8 = [41 x i8] c"Fehler konnte keine Speicher zu weisen!!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i8** @calloc(i32 3, i32 8)
%4 = icmp eq i8** %3, null
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %0, %26
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.7, i64 0, i64 0))
%14 = call signext i8 (...) @getchar()
br label %15
15: ; preds = %15, %9
%16 = call signext i8 (...) @getchar()
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %15
18: ; preds = %15
switch i8 %14, label %26 [
i8 49, label %19
i8 50, label %21
i8 51, label %23
]
19: ; preds = %18
%20 = call i32 @addItem(i8** %3, i32* %1, i32 3)
br label %26
21: ; preds = %18
%22 = call i32 @deleteItem(i8** %3, i32* %1)
br label %26
23: ; preds = %18
%24 = load i32, i32* %1
%25 = call i32 @listprint(i8** %3, i32 %24)
br label %26
26: ; preds = %21, %19, %18, %23
%27 = and i8 %14, -33
%28 = icmp eq i8 %27, 88
br i1 %28, label %29, label %9
29: ; preds = %26
%30 = load i32, i32* %1
%31 = call i32 @listfreeallitems(i8** %3, i32 %30)
%32 = call i32 @free(i8** %3)
ret i32 0
}