#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*/ add(int);
int del();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  unsigned ch;
  int p;
  do {
    puts("Choose an action");
    puts("0: Exit");
    puts("1: Add");
    puts("2: Del");
    scanf(" %d%*c", &ch);
    switch (ch) {
    case 0:
      puts("Bye!");
      break;
    case 1:
      scanf(" %d%*c", &p);
      add(p);
      break;
    case 2:
      if ((p = del()) != -1)
        printf("%d\n", p);
      break;
    default:
      printf("Invalid Input!\n");
      break;
    }
    putchar('\n');
  } while (ch);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <puts@plt>
lea    0xe8f(%rip),%rdi
call   1050 <puts@plt>
lea    0xe8b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe86(%rip),%rdi
call   1050 <puts@plt>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     11e6 <main+0x86>
jmp    11c4 <main+0x64>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11f7 <main+0x97>
jmp    11d5 <main+0x75>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1216 <main+0xb6>
jmp    123f <main+0xdf>
lea    0xe41(%rip),%rdi
call   1050 <puts@plt>
jmp    124d <main+0xed>
lea    0xe29(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1040 <add@plt>
jmp    124d <main+0xed>
mov    $0x0,%al
call   1080 <del@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
je     123a <main+0xda>
mov    -0xc(%rbp),%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    124d <main+0xed>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,-0x8(%rbp)
jne    116f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%r14
lea    0xe98(%rip),%r15
lea    0xe99(%rip),%r12
lea    0xe99(%rip),%r13
lea    0xe99(%rip),%rbx
lea    0x4(%rsp),%rbp
jmp    11c1 <main+0x61>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe90(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x4(%rsp)
je     1258 <main+0xf8>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r12,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     1230 <main+0xd0>
cmp    $0x1,%eax
je     1210 <main+0xb0>
test   %eax,%eax
jne    11a0 <main+0x40>
lea    0xe27(%rip),%rdi
jmp    11a7 <main+0x47>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    (%rsp),%edi
call   1040 <add@plt>
jmp    11ac <main+0x4c>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <del@plt>
mov    %eax,(%rsp)
cmp    $0xffffffff,%eax
je     11ac <main+0x4c>
lea    0xde9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11ac <main+0x4c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Choose an action\00"
@.str.1 = [8 x i8] c"0: Exit\00"
@.str.2 = [7 x i8] c"1: Add\00"
@.str.3 = [7 x i8] c"2: Del\00"
@.str.4 = [7 x i8] c" %d%*c\00"
@.str.5 = [5 x i8] c"Bye!\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [16 x i8] c"Invalid Input!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %28, %0
%5 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
switch i32 %10, label %24 [
i32 0, label %11
i32 1, label %13
i32 2, label %17
]
11: ; preds = %4
%12 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %26
13: ; preds = %4
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = call i32 @add(i32 %15)
br label %26
17: ; preds = %4
%18 = call i32 (...) @del()
store i32 %18, i32* %3
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %17
br label %26
24: ; preds = %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %26
26: ; preds = %24, %23, %13, %11
%27 = call i32 @putchar(i8 signext 10)
br label %28
28: ; preds = %26
%29 = load i32, i32* %2
%30 = icmp ne i32 %29, 0
br i1 %30, label %4, label %31
31: ; preds = %28
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Choose an action\00"
@.str.1 = [8 x i8] c"0: Exit\00"
@.str.2 = [7 x i8] c"1: Add\00"
@.str.3 = [7 x i8] c"2: Del\00"
@.str.4 = [7 x i8] c" %d%*c\00"
@.str.5 = [5 x i8] c"Bye!\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@str = [15 x i8] c"Invalid Input!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %25, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %23 [
i32 0, label %12
i32 1, label %14
i32 2, label %18
]
12: ; preds = %5
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %25
14: ; preds = %5
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = call i32 @add(i32 %16)
br label %25
18: ; preds = %5
%19 = call i32 (...) @del()
store i32 %19, i32* %2
%20 = icmp eq i32 %19, -1
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %19)
br label %25
23: ; preds = %5
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %25
25: ; preds = %18, %21, %23, %14, %12
%26 = call i32 @putchar(i8 signext 10)
%27 = load i32, i32* %1
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %5
29: ; preds = %25
ret i32 0
}