#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 delete ();
int /*<<< orphan*/ display();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ insert(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  printf("\nQueue Test\n\n");
  int val, choice;
  while (1) {
    printf("\nQueue Operations : \n");
    printf("1. insert\n2. remove\n3. display\n4. Quit\n");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("Enter element to insert\n");
      scanf("%d", &val);
      insert(val);
      break;
    case 2:
      val = delete ();
      printf("Removed Value : %d \n", val);
      break;
    case 3:
      display();
      break;
    case 4:
      exit(0);
    default:
      printf("Wrong entry : \n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1234 <main+0xd4>
mov    -0x18(%rbp),%rax
lea    0xe33(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe71(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1060 <insert@plt>
jmp    1242 <main+0xe2>
mov    $0x0,%al
call   1070 <delete@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1242 <main+0xe2>
mov    $0x0,%al
call   1030 <display@plt>
jmp    1242 <main+0xe2>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    117d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
lea    0xea7(%rip),%r14
lea    0xeb5(%rip),%r15
lea    0xe74(%rip),%rbx
lea    0x4(%rsp),%r12
lea    0xe58(%rip),%r13
lea    0xe64(%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   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1220 <main+0xb0>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
call   1070 <insert@plt>
jmp    11c7 <main+0x57>
nopl   0x0(%rax)
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
jmp    11c7 <main+0x57>
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <delete@plt>
mov    %eax,(%rsp)
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c7 <main+0x57>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"\0AQueue Test\0A\0A\00"
@.str.1 = [22 x i8] c"\0AQueue Operations : \0A\00"
@.str.2 = [40 x i8] c"1. insert\0A2. remove\0A3. display\0A4. Quit\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [25 x i8] c"Enter element to insert\0A\00"
@.str.5 = [21 x i8] c"Removed Value : %d \0A\00"
@.str.6 = [16 x i8] c"Wrong entry : \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %25
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
switch i32 %9, label %23 [
i32 1, label %10
i32 2, label %15
i32 3, label %19
i32 4, label %21
]
10: ; preds = %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = call i32 @insert(i32 %13)
br label %25
15: ; preds = %5
%16 = call i32 (...) @delete()
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %17)
br label %25
19: ; preds = %5
%20 = call i32 (...) @display()
br label %25
21: ; preds = %5
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %25
25: ; preds = %23, %19, %15, %10
br label %5
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [21 x i8] c"Removed Value : %d \0A\00"
@str = [13 x i8] c"\0AQueue Test\0A\00"
@str.7 = [21 x i8] c"\0AQueue Operations : \00"
@str.8 = [39 x i8] c"1. insert\0A2. remove\0A3. display\0A4. Quit\00"
@str.9 = [24 x i8] c"Enter element to insert\00"
@str.10 = [15 x i8] c"Wrong entry : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
br label %6
6: ; preds = %25, %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.8, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
switch i32 %10, label %23 [
i32 1, label %11
i32 2, label %16
i32 3, label %19
i32 4, label %21
]
11: ; preds = %6
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = call i32 @insert(i32 %14)
br label %25
16: ; preds = %6
%17 = call i32 (...) @delete()
store i32 %17, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %17)
br label %25
19: ; preds = %6
%20 = call i32 (...) @display()
br label %25
21: ; preds = %6
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %6
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.10, i64 0, i64 0))
br label %25
25: ; preds = %23, %19, %16, %11
br label %6
}