#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 delete1();
int /*<<< orphan*/ display1();
int /*<<< orphan*/ insert1();
int peek1();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void Linearqueue1() {
  int option, val;
  printf("\n\t\t\t\t\t\t\t\t\t*****MAIN MENU*****");
  printf("\n\t\t\t\t\t\t\t\t\t1.Insert an element");
  printf("\n\t\t\t\t\t\t\t\t\t2.Delete an element");
  printf("\n\t\t\t\t\t\t\t\t\t3.Peek");
  printf("\n\t\t\t\t\t\t\t\t\t4.Display the queue");
  printf("\n\t\t\t\t\t\t\t\t\t5.TO STOP\n");
  do {
    printf("\n\t\t\t\t\t\t\t\t\tEnter the option: ");
    scanf("%d", &option);
    switch (option) {
    case 1:
      insert1();
      break;
    case 2:
      val = delete1();
      if (val != -1)
        printf("\n\t\t\t\t\t\t\t\t\tThe number deleted is : %d", val);
      break;
    case 3:
      val = peek1();
      if (val != -1)
        printf("\n\t\t\t\t\t\t\t\t\tThe first value in queue is : %d", val);
      break;
    case 4:
      display1();
      break;
    case 5:
      break;
    default:
      printf("OPTION DOESN\'T EXIST TRY AGAIN");
    }
  } while (option != 5);
}


x86 assembly (clang, -O0):
<Linearqueue1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeef(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf20(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     1274 <Linearqueue1+0x114>
mov    -0x10(%rbp),%rax
lea    0xe06(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <insert1@plt>
jmp    1282 <Linearqueue1+0x122>
mov    $0x0,%al
call   1050 <delete1@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1234 <Linearqueue1+0xd4>
mov    -0x8(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1282 <Linearqueue1+0x122>
mov    $0x0,%al
call   1030 <peek1@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     125e <Linearqueue1+0xfe>
mov    -0x8(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1282 <Linearqueue1+0x122>
mov    $0x0,%al
call   1070 <display1@plt>
jmp    1282 <Linearqueue1+0x122>
jmp    1282 <Linearqueue1+0x122>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1287 <Linearqueue1+0x127>
cmpl   $0x5,-0x4(%rbp)
jne    11bc <Linearqueue1+0x5c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Linearqueue1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf61(%rip),%rdi
call   1040 <puts@plt>
lea    0xec9(%rip),%r14
lea    0xf01(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xf23(%rip),%r12
lea    0xe12(%rip),%r13
lea    0xeea(%rip),%rbp
jmp    121b <Linearqueue1+0xab>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
nopw   0x0(%rax,%rax,1)
cmpl   $0x5,0x4(%rsp)
je     129c <Linearqueue1+0x12c>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1200 <Linearqueue1+0x90>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %eax,%eax
call   1090 <insert1@plt>
jmp    1210 <Linearqueue1+0xa0>
nop
xor    %eax,%eax
call   1060 <delete1@plt>
cmp    $0xffffffff,%eax
je     1210 <Linearqueue1+0xa0>
lea    0xe57(%rip),%rdi
jmp    127f <Linearqueue1+0x10f>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1030 <peek1@plt>
cmp    $0xffffffff,%eax
je     1210 <Linearqueue1+0xa0>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1210 <Linearqueue1+0xa0>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <display1@plt>
jmp    1210 <Linearqueue1+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0A\09\09\09\09\09\09\09\09\09*****MAIN MENU*****\00"
@.str.1 = [30 x i8] c"\0A\09\09\09\09\09\09\09\09\091.Insert an element\00"
@.str.2 = [30 x i8] c"\0A\09\09\09\09\09\09\09\09\092.Delete an element\00"
@.str.3 = [17 x i8] c"\0A\09\09\09\09\09\09\09\09\093.Peek\00"
@.str.4 = [30 x i8] c"\0A\09\09\09\09\09\09\09\09\094.Display the queue\00"
@.str.5 = [21 x i8] c"\0A\09\09\09\09\09\09\09\09\095.TO STOP\0A\00"
@.str.6 = [29 x i8] c"\0A\09\09\09\09\09\09\09\09\09Enter the option: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [37 x i8] c"\0A\09\09\09\09\09\09\09\09\09The number deleted is : %d\00"
@.str.9 = [43 x i8] c"\0A\09\09\09\09\09\09\09\09\09The first value in queue is : %d\00"
@.str.10 = [31 x i8] c"OPTION DOESN'T EXIST TRY AGAIN\00"
define void @Linearqueue1() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %9
9: ; preds = %37, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
switch i32 %12, label %34 [
i32 1, label %13
i32 2, label %15
i32 3, label %23
i32 4, label %31
i32 5, label %33
]
13: ; preds = %9
%14 = call i32 (...) @insert1()
br label %36
15: ; preds = %9
%16 = call i32 (...) @delete1()
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %15
br label %36
23: ; preds = %9
%24 = call i32 (...) @peek1()
store i32 %24, i32* %2
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %23
br label %36
31: ; preds = %9
%32 = call i32 (...) @display1()
br label %36
33: ; preds = %9
br label %36
34: ; preds = %9
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
br label %36
36: ; preds = %34, %33, %31, %30, %22, %13
br label %37
37: ; preds = %36
%38 = load i32, i32* %1
%39 = icmp ne i32 %38, 5
br i1 %39, label %9, label %40
40: ; preds = %37
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"\0A\09\09\09\09\09\09\09\09\09*****MAIN MENU*****\00"
@.str.1 = [30 x i8] c"\0A\09\09\09\09\09\09\09\09\091.Insert an element\00"
@.str.2 = [30 x i8] c"\0A\09\09\09\09\09\09\09\09\092.Delete an element\00"
@.str.3 = [17 x i8] c"\0A\09\09\09\09\09\09\09\09\093.Peek\00"
@.str.4 = [30 x i8] c"\0A\09\09\09\09\09\09\09\09\094.Display the queue\00"
@.str.6 = [29 x i8] c"\0A\09\09\09\09\09\09\09\09\09Enter the option: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [37 x i8] c"\0A\09\09\09\09\09\09\09\09\09The number deleted is : %d\00"
@.str.9 = [43 x i8] c"\0A\09\09\09\09\09\09\09\09\09The first value in queue is : %d\00"
@.str.10 = [31 x i8] c"OPTION DOESN'T EXIST TRY AGAIN\00"
@str = [20 x i8] c"\0A\09\09\09\09\09\09\09\09\095.TO STOP\00"
define void @Linearqueue1() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %29, %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
switch i32 %12, label %27 [
i32 1, label %13
i32 2, label %15
i32 3, label %20
i32 4, label %25
i32 5, label %32
]
13: ; preds = %9
%14 = call i32 (...) @insert1()
br label %29
15: ; preds = %9
%16 = call i32 (...) @delete1()
%17 = icmp eq i32 %16, -1
br i1 %17, label %29, label %18
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %16)
br label %29
20: ; preds = %9
%21 = call i32 (...) @peek1()
%22 = icmp eq i32 %21, -1
br i1 %22, label %29, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %21)
br label %29
25: ; preds = %9
%26 = call i32 (...) @display1()
br label %29
27: ; preds = %9
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
br label %29
29: ; preds = %13, %25, %27, %18, %15, %23, %20
%30 = load i32, i32* %1
%31 = icmp eq i32 %30, 5
br i1 %31, label %32, label %9
32: ; preds = %9, %29
ret void
}