#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 item {
  int dummy;
};

/* Variables and functions */
struct item *add(struct item *, int);
struct item *del(struct item *, int *);
int /*<<< orphan*/ is_empty(struct item *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ show_queue(struct item *);
void queue_managing() {
  struct item *qu_p = NULL;
  int cho = -1, val;
  while (cho != 0) {
    printf("\n\n\n");
    printf("\t||QUEUE||\n");
    printf("\t 1) ADD AN ELEMENT \n");
    printf("\t 2) DELETE AN ELEMENT \n");
    printf("\t 3) SHOW QUEUE \n");
    printf("\t 0) QUIT \n");
    printf("\t Choose an option : ");
    scanf("%d", &cho);
    printf("\n\n\n");
    switch (cho) {
    case 1:
      printf("Type a new value : \n");
      scanf("%d", &val);
      qu_p = add(qu_p, val);
      break;
    case 2:
      if (is_empty(qu_p))
        printf("Queue is empty \n");
      else {
        qu_p = del(qu_p, &val);
        printf("%d deleted ", val);
      }
      break;
    case 3:
      if (!is_empty(qu_p))
        show_queue(qu_p);
      else
        printf("Queue is empty \n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<queue_managing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     12f9 <queue_managing+0x199>
lea    0xe78(%rip),%rdi
mov    %rdi,-0x20(%rbp)
xor    %eax,%eax
mov    %al,-0x15(%rbp)
call   1040 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    -0x15(%rbp),%al
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x15(%rbp),%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     1242 <queue_managing+0xe2>
jmp    1220 <queue_managing+0xc0>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1275 <queue_managing+0x115>
jmp    1231 <queue_managing+0xd1>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     12c1 <queue_managing+0x161>
jmp    12f4 <queue_managing+0x194>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1c(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <add@plt>
mov    %rax,-0x8(%rbp)
jmp    12f4 <queue_managing+0x194>
mov    -0x8(%rbp),%rdi
call   1050 <is_empty@plt>
cmp    $0x0,%eax
je     129a <queue_managing+0x13a>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bc <queue_managing+0x15c>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1080 <del@plt>
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f4 <queue_managing+0x194>
mov    -0x8(%rbp),%rdi
call   1050 <is_empty@plt>
cmp    $0x0,%eax
jne    12e1 <queue_managing+0x181>
mov    -0x8(%rbp),%rdi
call   1060 <show_queue@plt>
jmp    12ef <queue_managing+0x18f>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f4 <queue_managing+0x194>
jmp    1177 <queue_managing+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<queue_managing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xeef(%rip),%rbx
lea    0xedd(%rip),%rbp
lea    0xe68(%rip),%r14
lea    0xe77(%rip),%r15
lea    0x4(%rsp),%r12
xor    %r13d,%r13d
jmp    11d8 <queue_managing+0x68>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1060 <is_empty@plt>
test   %eax,%eax
je     12b4 <queue_managing+0x144>
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     12c1 <queue_managing+0x151>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe3e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
lea    0xe52(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
je     11b0 <queue_managing+0x40>
cmp    $0x2,%eax
je     1280 <queue_managing+0x110>
cmp    $0x1,%eax
jne    11d0 <queue_managing+0x60>
lea    0xe39(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%esi
mov    %r13,%rdi
call   1030 <add@plt>
mov    %rax,%r13
jmp    11cc <queue_managing+0x5c>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1060 <is_empty@plt>
test   %eax,%eax
jne    11c0 <queue_managing+0x50>
mov    %r13,%rdi
mov    %rsp,%rsi
call   1090 <del@plt>
mov    %rax,%r13
mov    (%rsp),%esi
lea    0xd71(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cc <queue_managing+0x5c>
mov    %r13,%rdi
call   1070 <show_queue@plt>
jmp    11cc <queue_managing+0x5c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.item = type { i32 }
@.str = [4 x i8] c"\0A\0A\0A\00"
@.str.1 = [12 x i8] c"\09||QUEUE||\0A\00"
@.str.2 = [22 x i8] c"\09 1) ADD AN ELEMENT \0A\00"
@.str.3 = [25 x i8] c"\09 2) DELETE AN ELEMENT \0A\00"
@.str.4 = [18 x i8] c"\09 3) SHOW QUEUE \0A\00"
@.str.5 = [12 x i8] c"\09 0) QUIT \0A\00"
@.str.6 = [22 x i8] c"\09 Choose an option : \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [21 x i8] c"Type a new value : \0A\00"
@.str.9 = [17 x i8] c"Queue is empty \0A\00"
@.str.10 = [12 x i8] c"%d deleted \00"
define void @queue_managing() {
%1 = alloca %struct.item*
%2 = alloca i32
%3 = alloca i32
store %struct.item* null, %struct.item** %1
store i32 -1, i32* %2
br label %4
4: ; preds = %46, %0
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %47
7: ; preds = %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 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* %2)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %2
switch i32 %17, label %46 [
i32 1, label %18
i32 2, label %24
i32 3, label %36
]
18: ; preds = %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%21 = load %struct.item*, %struct.item** %1
%22 = load i32, i32* %3
%23 = call %struct.item* @add(%struct.item* %21, i32 %22)
store %struct.item* %23, %struct.item** %1
br label %46
24: ; preds = %7
%25 = load %struct.item*, %struct.item** %1
%26 = call i32 @is_empty(%struct.item* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %35
30: ; preds = %24
%31 = load %struct.item*, %struct.item** %1
%32 = call %struct.item* @del(%struct.item* %31, i32* %3)
store %struct.item* %32, %struct.item** %1
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %30, %28
br label %46
36: ; preds = %7
%37 = load %struct.item*, %struct.item** %1
%38 = call i32 @is_empty(%struct.item* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %36
%41 = load %struct.item*, %struct.item** %1
%42 = call i32 @show_queue(%struct.item* %41)
br label %45
43: ; preds = %36
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
br label %46
46: ; preds = %7, %45, %35, %18
br label %4
47: ; preds = %4
ret void
}

LLVM IR (-O2):
%struct.item = type { i32 }
@.str.6 = [22 x i8] c"\09 Choose an option : \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.10 = [12 x i8] c"%d deleted \00"
@str.11 = [11 x i8] c"\09||QUEUE||\00"
@str.12 = [21 x i8] c"\09 1) ADD AN ELEMENT \00"
@str.13 = [24 x i8] c"\09 2) DELETE AN ELEMENT \00"
@str.14 = [17 x i8] c"\09 3) SHOW QUEUE \00"
@str.15 = [11 x i8] c"\09 0) QUIT \00"
@str.16 = [3 x i8] c"\0A\0A\00"
@str.18 = [16 x i8] c"Queue is empty \00"
@str.19 = [20 x i8] c"Type a new value : \00"
define void @queue_managing() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %41
%6 = phi %struct.item* [ null, %0 ], [ %43, %41 ]
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.11, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.13, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.15, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0))
%16 = load i32, i32* %1
switch i32 %16, label %41 [
i32 1, label %17
i32 2, label %22
i32 3, label %31
]
17: ; preds = %5
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.19, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = call %struct.item* @add(%struct.item* %6, i32 %20)
br label %38
22: ; preds = %5
%23 = call i32 @is_empty(%struct.item* %6)
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.18, i64 0, i64 0))
br label %38
27: ; preds = %22
%28 = call %struct.item* @del(%struct.item* %6, i32* %2)
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %29)
br label %38
31: ; preds = %5
%32 = call i32 @is_empty(%struct.item* %6)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @show_queue(%struct.item* %6)
br label %38
36: ; preds = %31
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.18, i64 0, i64 0))
br label %38
38: ; preds = %17, %27, %25, %36, %34
%39 = phi %struct.item* [ %21, %17 ], [ %28, %27 ], [ %6, %25 ], [ %6, %34 ], [ %6, %36 ]
%40 = load i32, i32* %1
br label %41
41: ; preds = %38, %5
%42 = phi i32 [ %40, %38 ], [ %16, %5 ]
%43 = phi %struct.item* [ %39, %38 ], [ %6, %5 ]
%44 = icmp eq i32 %42, 0
br i1 %44, label %45, label %5
45: ; preds = %41
ret void
}