#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 /*<<< orphan*/ display();
int /*<<< orphan*/ enqueue(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int value;
  int data;
  printf("\n Queue link list example");
  while (1) {
    printf("\nMain Menu");
    printf("\n1.Enqueue \n2.Dequene \n3.Display \n4.exit");
    printf("\nEnter Your Choice");
    scanf("%d", &value);
    switch (value) {
    case 1:
      printf("\nEnter The item to be pushed");
      if (!scanf("%d", &data)) {
        printf("Invalid input \n");
        exit(0);
      }
      enqueue(data);
      break;
    case 2:
      dequeue();
      break;
    case 3:
      display();
      break;
    case 4:
      exit(0);
    default:
      printf("invalid input \n");
      exit(0);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     123c <main+0xdc>
mov    -0x18(%rbp),%rax
lea    0xe31(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
lea    0xe86(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x0,%eax
jne    1210 <main+0xb0>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0xc(%rbp),%edi
call   1080 <enqueue@plt>
jmp    124f <main+0xef>
mov    $0x0,%al
call   1050 <dequeue@plt>
jmp    124f <main+0xef>
mov    $0x0,%al
call   1030 <display@plt>
jmp    124f <main+0xef>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    117b <main+0x1b>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9c(%rip),%r14
lea    0xea0(%rip),%r15
lea    0xec2(%rip),%r12
lea    0xece(%rip),%rbx
lea    0x4(%rsp),%r13
lea    0xe51(%rip),%rbp
jmp    11c7 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <display@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1239 <main+0xc9>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xe6d(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
test   %eax,%eax
je     1249 <main+0xd9>
mov    (%rsp),%edi
call   1090 <enqueue@plt>
jmp    11c7 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <dequeue@plt>
jmp    11c7 <main+0x57>
lea    0xe60(%rip),%rdi
jmp    1250 <main+0xe0>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xe41(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"\0A Queue link list example\00"
@.str.1 = [11 x i8] c"\0AMain Menu\00"
@.str.2 = [41 x i8] c"\0A1.Enqueue \0A2.Dequene \0A3.Display \0A4.exit\00"
@.str.3 = [19 x i8] c"\0AEnter Your Choice\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [29 x i8] c"\0AEnter The item to be pushed\00"
@.str.6 = [16 x i8] c"Invalid input \0A\00"
@.str.7 = [16 x i8] c"invalid input \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %30
%6 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
switch i32 %10, label %27 [
i32 1, label %11
i32 2, label %21
i32 3, label %23
i32 4, label %25
]
11: ; preds = %5
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %11
%19 = load i32, i32* %3
%20 = call i32 @enqueue(i32 %19)
br label %30
21: ; preds = %5
%22 = call i32 (...) @dequeue()
br label %30
23: ; preds = %5
%24 = call i32 (...) @display()
br label %30
25: ; preds = %5
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %5
%28 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %23, %21, %18
br label %5
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0A Queue link list example\00"
@.str.1 = [11 x i8] c"\0AMain Menu\00"
@.str.2 = [41 x i8] c"\0A1.Enqueue \0A2.Dequene \0A3.Display \0A4.exit\00"
@.str.3 = [19 x i8] c"\0AEnter Your Choice\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [29 x i8] c"\0AEnter The item to be pushed\00"
@str = [15 x i8] c"Invalid input \00"
@str.8 = [15 x i8] c"invalid input \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %26, %0
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %29 [
i32 1, label %12
i32 2, label %22
i32 3, label %24
i32 4, label %27
]
12: ; preds = %6
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %12
%20 = load i32, i32* %2
%21 = call i32 @enqueue(i32 %20)
br label %26
22: ; preds = %6
%23 = call i32 (...) @dequeue()
br label %26
24: ; preds = %6
%25 = call i32 (...) @display()
br label %26
26: ; preds = %24, %22, %19
br label %6
27: ; preds = %6
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %6
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0))
%31 = call i32 @exit(i32 0)
unreachable
}