#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 */
struct Queue {
  int dummy;
};

/* Variables and functions */
struct Queue *CreateQueue();
int DeQueue(struct Queue *);
int /*<<< orphan*/ DeleteQueue(struct Queue *);
int /*<<< orphan*/ EnQueue(struct Queue *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void test_Queue() {
  struct Queue *Q;
  int ans, data = 0;
  do {
    printf("Enter Operation: (1) Create; (2): Enqueue; (3): DeQueue; (4) "
           "DeleteQ; (0): Exit\n");
    scanf("%d", &ans);
    switch (ans) {
    case 1:
      Q = CreateQueue();
      break;
    case 2:
      printf("Enter Queue Element\n");
      scanf("%d", &data);
      if (!Q)
        Q = CreateQueue();
      EnQueue(Q, data);
      break;
    case 3:
      if (Q)
        data = DeQueue(Q);
      printf("Dequeued Element: %d\n", data);
      break;
    case 4:
      if (Q) {
        DeleteQueue(Q);
        Q = NULL;
      }
      break;
    case 0:
      if (Q) {
        DeleteQueue(Q);
        Q = NULL;
      }
      break;
    default:
      printf("Wrong Operation Selected\n");
    }
  } while (ans != 0);
}


x86 assembly (clang, -O0):
<test_Queue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     1276 <test_Queue+0x116>
mov    -0x18(%rbp),%rax
lea    0xe57(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <CreateQueue@plt>
mov    %rax,-0x8(%rbp)
jmp    1284 <test_Queue+0x124>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <scanf@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11f6 <test_Queue+0x96>
mov    $0x0,%al
call   1070 <CreateQueue@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <EnQueue@plt>
jmp    1284 <test_Queue+0x124>
cmpq   $0x0,-0x8(%rbp)
je     121e <test_Queue+0xbe>
mov    -0x8(%rbp),%rdi
call   1040 <DeQueue@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1284 <test_Queue+0x124>
cmpq   $0x0,-0x8(%rbp)
je     1250 <test_Queue+0xf0>
mov    -0x8(%rbp),%rdi
call   1050 <DeleteQueue@plt>
movq   $0x0,-0x8(%rbp)
jmp    1284 <test_Queue+0x124>
cmpq   $0x0,-0x8(%rbp)
je     1271 <test_Queue+0x111>
mov    -0x8(%rbp),%rdi
call   1050 <DeleteQueue@plt>
movq   $0x0,-0x8(%rbp)
jmp    1284 <test_Queue+0x124>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1289 <test_Queue+0x129>
cmpl   $0x0,-0xc(%rbp)
jne    116f <test_Queue+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_Queue>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,(%rsp)
lea    0xea4(%rip),%r14
lea    0xe84(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xe64(%rip),%rbp
lea    0xe74(%rip),%r12
jmp    11cc <test_Queue+0x5c>
lea    0xee5(%rip),%rdi
call   1050 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1292 <test_Queue+0x122>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x4,%rax
ja     11a5 <test_Queue+0x35>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
test   %r13,%r13
jne    1270 <test_Queue+0x100>
jmp    1292 <test_Queue+0x122>
xor    %eax,%eax
call   1080 <CreateQueue@plt>
mov    %rax,%r13
jmp    11c0 <test_Queue+0x50>
lea    0xe6d(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1090 <scanf@plt>
test   %r13,%r13
jne    122f <test_Queue+0xbf>
xor    %eax,%eax
call   1080 <CreateQueue@plt>
mov    %rax,%r13
mov    (%rsp),%esi
mov    %r13,%rdi
call   1030 <EnQueue@plt>
jmp    11c0 <test_Queue+0x50>
test   %r13,%r13
je     1280 <test_Queue+0x110>
mov    %r13,%rdi
call   1040 <DeQueue@plt>
mov    %eax,%esi
mov    %eax,(%rsp)
jmp    1283 <test_Queue+0x113>
test   %r13,%r13
jne    1270 <test_Queue+0x100>
mov    $0x4,%eax
xor    %r13d,%r13d
test   %eax,%eax
jne    11cc <test_Queue+0x5c>
jmp    1292 <test_Queue+0x122>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1060 <DeleteQueue@plt>
xor    %r13d,%r13d
jmp    11c0 <test_Queue+0x50>
mov    (%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    11c0 <test_Queue+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.Queue = type { i32 }
@.str = [81 x i8] c"Enter Operation: (1) Create; (2): Enqueue; (3): DeQueue; (4) DeleteQ; (0): Exit\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"Enter Queue Element\0A\00"
@.str.3 = [22 x i8] c"Dequeued Element: %d\0A\00"
@.str.4 = [26 x i8] c"Wrong Operation Selected\0A\00"
define void @test_Queue() {
%1 = alloca %struct.Queue*
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %47, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
switch i32 %7, label %44 [
i32 1, label %8
i32 2, label %10
i32 3, label %21
i32 4, label %30
i32 0, label %37
]
8: ; preds = %4
%9 = call %struct.Queue* (...) @CreateQueue()
store %struct.Queue* %9, %struct.Queue** %1
br label %46
10: ; preds = %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load %struct.Queue*, %struct.Queue** %1
%14 = icmp ne %struct.Queue* %13, null
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = call %struct.Queue* (...) @CreateQueue()
store %struct.Queue* %16, %struct.Queue** %1
br label %17
17: ; preds = %15, %10
%18 = load %struct.Queue*, %struct.Queue** %1
%19 = load i32, i32* %3
%20 = call i32 @EnQueue(%struct.Queue* %18, i32 %19)
br label %46
21: ; preds = %4
%22 = load %struct.Queue*, %struct.Queue** %1
%23 = icmp ne %struct.Queue* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load %struct.Queue*, %struct.Queue** %1
%26 = call i32 @DeQueue(%struct.Queue* %25)
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %21
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %46
30: ; preds = %4
%31 = load %struct.Queue*, %struct.Queue** %1
%32 = icmp ne %struct.Queue* %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load %struct.Queue*, %struct.Queue** %1
%35 = call i32 @DeleteQueue(%struct.Queue* %34)
store %struct.Queue* null, %struct.Queue** %1
br label %36
36: ; preds = %33, %30
br label %46
37: ; preds = %4
%38 = load %struct.Queue*, %struct.Queue** %1
%39 = icmp ne %struct.Queue* %38, null
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load %struct.Queue*, %struct.Queue** %1
%42 = call i32 @DeleteQueue(%struct.Queue* %41)
store %struct.Queue* null, %struct.Queue** %1
br label %43
43: ; preds = %40, %37
br label %46
44: ; preds = %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %43, %36, %27, %17, %8
br label %47
47: ; preds = %46
%48 = load i32, i32* %2
%49 = icmp ne i32 %48, 0
br i1 %49, label %4, label %50
50: ; preds = %47
ret void
}

LLVM IR (-O2):
%struct.Queue = type { i32 }
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [22 x i8] c"Dequeued Element: %d\0A\00"
@str = [80 x i8] c"Enter Operation: (1) Create; (2): Enqueue; (3): DeQueue; (4) DeleteQ; (0): Exit\00"
@str.5 = [20 x i8] c"Enter Queue Element\00"
@str.6 = [25 x i8] c"Wrong Operation Selected\00"
define void @test_Queue() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %44, %0
%6 = phi %struct.Queue* [ undef, %0 ], [ %46, %44 ]
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
switch i32 %9, label %39 [
i32 1, label %10
i32 2, label %12
i32 3, label %22
i32 4, label %31
i32 0, label %35
]
10: ; preds = %5
%11 = call %struct.Queue* (...) @CreateQueue()
br label %41
12: ; preds = %5
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = icmp eq %struct.Queue* %6, null
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call %struct.Queue* (...) @CreateQueue()
br label %18
18: ; preds = %16, %12
%19 = phi %struct.Queue* [ %6, %12 ], [ %17, %16 ]
%20 = load i32, i32* %2
%21 = call i32 @EnQueue(%struct.Queue* %19, i32 %20)
br label %41
22: ; preds = %5
%23 = icmp eq %struct.Queue* %6, null
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = load i32, i32* %2
br label %28
26: ; preds = %22
%27 = call i32 @DeQueue(%struct.Queue* %6)
store i32 %27, i32* %2
br label %28
28: ; preds = %24, %26
%29 = phi i32 [ %25, %24 ], [ %27, %26 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %41
31: ; preds = %5
%32 = icmp eq %struct.Queue* %6, null
br i1 %32, label %44, label %33
33: ; preds = %31
%34 = call i32 @DeleteQueue(%struct.Queue* %6)
br label %41
35: ; preds = %5
%36 = icmp eq %struct.Queue* %6, null
br i1 %36, label %48, label %37
37: ; preds = %35
%38 = call i32 @DeleteQueue(%struct.Queue* %6)
br label %41
39: ; preds = %5
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
br label %41
41: ; preds = %37, %33, %39, %28, %18, %10
%42 = phi %struct.Queue* [ %11, %10 ], [ %19, %18 ], [ %6, %28 ], [ null, %33 ], [ null, %37 ], [ %6, %39 ]
%43 = load i32, i32* %1
br label %44
44: ; preds = %41, %31
%45 = phi i32 [ %43, %41 ], [ 4, %31 ]
%46 = phi %struct.Queue* [ %42, %41 ], [ null, %31 ]
%47 = icmp eq i32 %45, 0
br i1 %47, label %48, label %5
48: ; preds = %35, %44
ret void
}