#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 *, int, int);
int /*<<< orphan*/ insert(int *, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int qdelete(int *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int front = -1, rear = -1;
  int queue[10 + 1];
  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);
      insert(queue, front, rear, item);
      break;
    case 2:
      item = qdelete(queue, front, rear);
      if (item != -1)
        printf("Item removed: %d \n", item);
      break;
    case 3:
      display(queue, front, rear);
      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    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x51(%rbp)
call   1040 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x44(%rbp),%eax
mov    %rax,-0x50(%rbp)
sub    $0x3,%rax
ja     127e <main+0x12e>
mov    -0x50(%rbp),%rax
lea    0xe0b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4d(%rip),%rdi
lea    -0x48(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x48(%rbp),%ecx
call   1070 <insert@plt>
jmp    128c <main+0x13c>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <qdelete@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0xffffffff,-0x48(%rbp)
je     1260 <main+0x110>
mov    -0x48(%rbp),%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128c <main+0x13c>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <display@plt>
jmp    128c <main+0x13c>
jmp    128c <main+0x13c>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1291 <main+0x141>
cmpl   $0x0,-0x44(%rbp)
jne    116d <main+0x1d>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xef9(%rip),%r13
lea    0xefd(%rip),%rbx
lea    0xe8d(%rip),%rbp
lea    0xe95(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xe6a(%rip),%r12
jmp    11b7 <main+0x57>
nopl   0x0(%rax,%rax,1)
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
je     12a9 <main+0x149>
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    0xc(%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
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%ecx
lea    0x10(%rsp),%rdi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
call   1080 <insert@plt>
jmp    11ac <main+0x4c>
nopl   0x0(%rax,%rax,1)
lea    0x10(%rsp),%rdi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
call   1060 <qdelete@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
je     11ac <main+0x4c>
lea    0xdba(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ac <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
lea    0x10(%rsp),%rdi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
call   1040 <display@plt>
jmp    11ac <main+0x4c>
xor    %eax,%eax
add    $0x48,%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
%4 = alloca [11 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
store i32 -1, i32* %3
br label %7
7: ; preds = %44, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%15 = load i32, i32* %5
switch i32 %15, label %41 [
i32 1, label %16
i32 2, label %24
i32 3, label %35
i32 0, label %40
]
16: ; preds = %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %6)
%19 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 0
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = load i32, i32* %6
%23 = call i32 @insert(i32* %19, i32 %20, i32 %21, i32 %22)
br label %43
24: ; preds = %7
%25 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 0
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = call i32 @qdelete(i32* %25, i32 %26, i32 %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp ne i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i32, i32* %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %24
br label %43
35: ; preds = %7
%36 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 0
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = call i32 @display(i32* %36, i32 %37, i32 %38)
br label %43
40: ; preds = %7
br label %43
41: ; preds = %7
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %43
43: ; preds = %41, %40, %35, %34, %16
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = icmp ne i32 %45, 0
br i1 %46, label %7, label %47
47: ; preds = %44
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 [11 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [11 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 0
br label %8
8: ; preds = %31, %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.11, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.12, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.13, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
switch i32 %16, label %29 [
i32 1, label %17
i32 2, label %22
i32 3, label %27
i32 0, label %34
]
17: ; preds = %8
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%20 = load i32, i32* %3
%21 = call i32 @insert(i32* %7, i32 -1, i32 -1, i32 %20)
br label %31
22: ; preds = %8
%23 = call i32 @qdelete(i32* %7, i32 -1, i32 -1)
store i32 %23, i32* %3
%24 = icmp eq i32 %23, -1
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %23)
br label %31
27: ; preds = %8
%28 = call i32 @display(i32* %7, i32 -1, i32 -1)
br label %31
29: ; preds = %8
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.14, i64 0, i64 0))
br label %31
31: ; preds = %17, %27, %29, %25, %22
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %8
34: ; preds = %8, %31
ret i32 0
}