#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*/ display();
int /*<<< orphan*/ printf(char *, ...);
int qdelete();
int /*<<< orphan*/ qinsert(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int ch, item;
  do {
    printf("\n-------------------\n");
    printf("1. Insert\n");
    printf("2. Delete\n");
    printf("3. Display\n");
    printf("0. Exit\n");
    printf("Enter choice: ");
    scanf("%d", &ch);
    switch (ch) {
    case 1:
      printf("Enter an item: ");
      scanf("%d", &item);
      qinsert(item);
      break;
    case 2:
      item = qdelete();
      if (item != -1)
        printf("Item removed: %d \n", item);
      break;
    case 3:
      display();
      break;
    case 0:
      break;
    default:
      printf("Invalid Choice!\n");
    }
  } while (ch != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     1256 <main+0x106>
mov    -0x18(%rbp),%rax
lea    0xe19(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5b(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1070 <qinsert@plt>
jmp    1264 <main+0x114>
mov    $0x0,%al
call   1050 <qdelete@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     1240 <main+0xf0>
mov    -0xc(%rbp),%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1264 <main+0x114>
mov    $0x0,%al
call   1030 <display@plt>
jmp    1264 <main+0x114>
jmp    1264 <main+0x114>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1269 <main+0x119>
cmpl   $0x0,-0x8(%rbp)
jne    115f <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    0xefc(%rip),%r13
lea    0xf00(%rip),%rbx
lea    0xe90(%rip),%rbp
lea    0xe98(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xe6d(%rip),%r12
jmp    11b7 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
je     127c <main+0x11c>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     11a0 <main+0x40>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xe08(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%edi
call   1080 <qinsert@plt>
jmp    11ac <main+0x4c>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <qdelete@plt>
mov    %eax,(%rsp)
cmp    $0xffffffff,%eax
je     11ac <main+0x4c>
lea    0xdd8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ac <main+0x4c>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <display@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 = [22 x i8] c"\0A-------------------\0A\00"
@.str.1 = [11 x i8] c"1. Insert\0A\00"
@.str.2 = [11 x i8] c"2. Delete\0A\00"
@.str.3 = [12 x i8] c"3. Display\0A\00"
@.str.4 = [9 x i8] c"0. Exit\0A\00"
@.str.5 = [15 x i8] c"Enter choice: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [16 x i8] c"Enter an item: \00"
@.str.8 = [19 x i8] c"Item removed: %d \0A\00"
@.str.9 = [17 x i8] c"Invalid Choice!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %32, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
switch i32 %12, label %29 [
i32 1, label %13
i32 2, label %18
i32 3, label %26
i32 0, label %28
]
13: ; preds = %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
%17 = call i32 @qinsert(i32 %16)
br label %31
18: ; preds = %4
%19 = call i32 (...) @qdelete()
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %18
br label %31
26: ; preds = %4
%27 = call i32 (...) @display()
br label %31
28: ; preds = %4
br label %31
29: ; preds = %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %31
31: ; preds = %29, %28, %26, %25, %13
br label %32
32: ; preds = %31
%33 = load i32, i32* %2
%34 = icmp ne i32 %33, 0
br i1 %34, label %4, label %35
35: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [15 x i8] c"Enter choice: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [16 x i8] c"Enter an item: \00"
@.str.8 = [19 x i8] c"Item removed: %d \0A\00"
@str = [21 x i8] c"\0A-------------------\00"
@str.10 = [10 x i8] c"1. Insert\00"
@str.11 = [10 x i8] c"2. Delete\00"
@str.12 = [11 x i8] c"3. Display\00"
@str.13 = [8 x i8] c"0. Exit\00"
@str.14 = [16 x i8] c"Invalid Choice!\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 = %28, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.11, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.13, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
switch i32 %13, label %26 [
i32 1, label %14
i32 2, label %19
i32 3, label %24
i32 0, label %31
]
14: ; preds = %5
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
%18 = call i32 @qinsert(i32 %17)
br label %28
19: ; preds = %5
%20 = call i32 (...) @qdelete()
store i32 %20, i32* %2
%21 = icmp eq i32 %20, -1
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %20)
br label %28
24: ; preds = %5
%25 = call i32 (...) @display()
br label %28
26: ; preds = %5
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.14, i64 0, i64 0))
br label %28
28: ; preds = %14, %24, %26, %22, %19
%29 = load i32, i32* %1
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %5
31: ; preds = %5, %28
ret i32 0
}