#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 *, int *, int);
int /*<<< orphan*/ display(int *);
int /*<<< orphan*/ enqueue(int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int n, m, k;
  int *arr1;
  int *arr2;
  printf("enter the size\n");
  scanf("%d", &n);
  arr1 = (int *)malloc(sizeof(int) * n);
  arr2 = (int *)malloc(sizeof(int) * n);
  do {
    printf("1.enqueue\n2.dequeue\n3.display\n");
    scanf("%d", &m);
    switch (m) {
    case 1:
      enqueue(arr1, n);
      break;
    case 2:
      dequeue(arr1, arr2, n);
      break;
    case 3:
      display(arr1);
      break;
    }
    printf("press 1 to continue\n");
    scanf("%d", &k);
  } while (k);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     1203 <main+0xa3>
jmp    11e1 <main+0x81>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     1214 <main+0xb4>
jmp    11f2 <main+0x92>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
je     1229 <main+0xc9>
jmp    1232 <main+0xd2>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <enqueue@plt>
jmp    1232 <main+0xd2>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1050 <dequeue@plt>
jmp    1232 <main+0xd2>
mov    -0x18(%rbp),%rdi
call   1030 <display@plt>
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
lea    0xdcb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11b1 <main+0x51>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7f(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
lea    0xe5d(%rip),%r12
lea    0xc(%rsp),%r13
lea    0xe6f(%rip),%rbp
lea    0x8(%rsp),%r15
jmp    11fb <main+0x9b>
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    0x10(%rsp),%rsi
call   1050 <dequeue@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
je     123a <main+0xda>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     1230 <main+0xd0>
cmp    $0x2,%eax
je     11d0 <main+0x70>
cmp    $0x1,%eax
jne    11e1 <main+0x81>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1080 <enqueue@plt>
jmp    11e1 <main+0x81>
nop
mov    %r14,%rdi
call   1040 <display@plt>
jmp    11e1 <main+0x81>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"enter the size\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"1.enqueue\0A2.dequeue\0A3.display\0A\00"
@.str.3 = [21 x i8] c"press 1 to continue\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 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* %2)
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = mul i64 4, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %5
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = mul i64 4, %16
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32*
store i32* %20, i32** %6
br label %21
21: ; preds = %40, %0
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%24 = load i32, i32* %3
switch i32 %24, label %37 [
i32 1, label %25
i32 2, label %29
i32 3, label %34
]
25: ; preds = %21
%26 = load i32*, i32** %5
%27 = load i32, i32* %2
%28 = call i32 @enqueue(i32* %26, i32 %27)
br label %37
29: ; preds = %21
%30 = load i32*, i32** %5
%31 = load i32*, i32** %6
%32 = load i32, i32* %2
%33 = call i32 @dequeue(i32* %30, i32* %31, i32 %32)
br label %37
34: ; preds = %21
%35 = load i32*, i32** %5
%36 = call i32 @display(i32* %35)
br label %37
37: ; preds = %21, %34, %29, %25
%38 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %40
40: ; preds = %37
%41 = load i32, i32* %4
%42 = icmp ne i32 %41, 0
br i1 %42, label %21, label %43
43: ; preds = %40
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [15 x i8] c"enter the size\00"
@str.4 = [30 x i8] c"1.enqueue\0A2.dequeue\0A3.display\00"
@str.5 = [20 x i8] c"press 1 to continue\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 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
%10 = shl i32 %9, 2
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
%13 = load i32, i32* %1
%14 = shl i32 %13, 2
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i32*
br label %17
17: ; preds = %29, %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
switch i32 %20, label %29 [
i32 1, label %21
i32 2, label %24
i32 3, label %27
]
21: ; preds = %17
%22 = load i32, i32* %1
%23 = call i32 @enqueue(i32* %12, i32 %22)
br label %29
24: ; preds = %17
%25 = load i32, i32* %1
%26 = call i32 @dequeue(i32* %12, i32* %16, i32 %25)
br label %29
27: ; preds = %17
%28 = call i32 @display(i32* %12)
br label %29
29: ; preds = %17, %27, %24, %21
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %17
34: ; preds = %29
ret i32 0
}