#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*/ dequeue(int *, int *, int *);
int /*<<< orphan*/ display(int *, int, int);
int /*<<< orphan*/ enqueue(int *, int *, int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int q[5], front = -1, rear = -1;
  system("cls");
  while (1) {
    int choice = 0, item = -1;
    printf("\n::Queue Operations::\n");
    printf("1. Insert in Queue\n");
    printf("2. Delete from Queue\n");
    printf("3. Display Queue\n");
    printf("4. Exit\n");
    printf("Enter Your choice: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1: {
      printf("\nEnter the value to insert: ");
      scanf("%d", &item);
      enqueue(q, &front, &rear, item);
    } break;
    case 2:
      dequeue(q, &front, &rear);
      break;
    case 3:
      display(q, front, rear);
      break;
    case 4:
      printf("\nExiting....\n");
      return 0;
    default:
      printf("\nWrong Choice!\n");
    }
  }
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movl   $0xffffffff,-0x28(%rbp)
lea    0xe8c(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
lea    0xe76(%rip),%rdi
call   1050 <printf@plt>
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
lea    0xe89(%rip),%rdi
call   1050 <printf@plt>
lea    0xe93(%rip),%rdi
call   1050 <printf@plt>
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x3,%eax
ja     128b <main+0x12b>
mov    -0x38(%rbp),%rax
lea    0xdf1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe68(%rip),%rdi
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%ecx
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1080 <enqueue@plt>
jmp    1297 <main+0x137>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <dequeue@plt>
jmp    1297 <main+0x137>
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1030 <display@plt>
jmp    1297 <main+0x137>
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret
lea    0xe20(%rip),%rdi
call   1050 <printf@plt>
jmp    1189 <main+0x29>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0xffffffff,0x4(%rsp)
ff
movl   $0xffffffff,(%rsp)
lea    0xe7c(%rip),%rdi
call   1050 <system@plt>
lea    0xee6(%rip),%r13
lea    0xef0(%rip),%rbx
lea    0xe66(%rip),%rbp
lea    0xe73(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xe3f(%rip),%r12
jmp    11e1 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0x10(%rsp),%rdi
call   1040 <display@plt>
movl   $0x0,0xc(%rsp)
movl   $0xffffffff,0x8(%rsp)
ff
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1060 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1290 <main+0x120>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xdd7(%rip),%rdi
call   1060 <printf@plt>
mov    %r14,%rdi
lea    0x8(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x8(%rsp),%ecx
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1090 <enqueue@plt>
jmp    11e1 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe15(%rip),%rdi
call   1030 <puts@plt>
jmp    11e1 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1070 <dequeue@plt>
jmp    11e1 <main+0x71>
lea    0xdd1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [23 x i8] c"\0A::Queue Operations::\0A\00"
@.str.2 = [20 x i8] c"1. Insert in Queue\0A\00"
@.str.3 = [22 x i8] c"2. Delete from Queue\0A\00"
@.str.4 = [18 x i8] c"3. Display Queue\0A\00"
@.str.5 = [9 x i8] c"4. Exit\0A\00"
@.str.6 = [20 x i8] c"Enter Your choice: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [29 x i8] c"\0AEnter the value to insert: \00"
@.str.9 = [14 x i8] c"\0AExiting....\0A\00"
@.str.10 = [16 x i8] c"\0AWrong Choice!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %3
store i32 -1, i32* %4
%7 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %0, %35
store i32 0, i32* %5
store i32 -1, i32* %6
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%16 = load i32, i32* %5
switch i32 %16, label %33 [
i32 1, label %17
i32 2, label %23
i32 3, label %26
i32 4, label %31
]
17: ; preds = %8
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %6)
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%21 = load i32, i32* %6
%22 = call i32 @enqueue(i32* %20, i32* %3, i32* %4, i32 %21)
br label %35
23: ; preds = %8
%24 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%25 = call i32 @dequeue(i32* %24, i32* %3, i32* %4)
br label %35
26: ; preds = %8
%27 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @display(i32* %27, i32 %28, i32 %29)
br label %35
31: ; preds = %8
%32 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
33: ; preds = %8
%34 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %35
35: ; preds = %33, %26, %23, %17
br label %8
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@.str.6 = [20 x i8] c"Enter Your choice: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [29 x i8] c"\0AEnter the value to insert: \00"
@str = [22 x i8] c"\0A::Queue Operations::\00"
@str.11 = [19 x i8] c"1. Insert in Queue\00"
@str.12 = [21 x i8] c"2. Delete from Queue\00"
@str.13 = [17 x i8] c"3. Display Queue\00"
@str.14 = [8 x i8] c"4. Exit\00"
@str.15 = [13 x i8] c"\0AExiting....\00"
@str.16 = [15 x i8] c"\0AWrong Choice!\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [5 x i32]* %1 to i8*
%7 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%8 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%9 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
br label %13
13: ; preds = %37, %0
store i32 0, i32* %4
store i32 -1, i32* %5
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.14, i64 0, i64 0))
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%21 = load i32, i32* %4
switch i32 %21, label %35 [
i32 1, label %22
i32 2, label %27
i32 3, label %29
i32 4, label %33
]
22: ; preds = %13
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%25 = load i32, i32* %5
%26 = call i32 @enqueue(i32* %12, i32* %2, i32* %3, i32 %25)
br label %37
27: ; preds = %13
%28 = call i32 @dequeue(i32* %12, i32* %2, i32* %3)
br label %37
29: ; preds = %13
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = call i32 @display(i32* %12, i32 %30, i32 %31)
br label %37
33: ; preds = %13
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.15, i64 0, i64 0))
ret i32 0
35: ; preds = %13
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0))
br label %37
37: ; preds = %22, %27, %29, %35
br label %13
}