#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 /*<<< orphan*/ Enqueue(int *, int);
int /*<<< orphan*/ Print(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, x;
  int Q[100];
  do {
    printf("1. Print Queue\n");
    printf("2. Enqueue\n");
    printf("3. Dequeue\n");
    printf("0. Exit\n");
    printf("Input: ");
    scanf("%d", &n);
    switch (n) {
    case 1:
      Print(Q);
      break;
    case 2:
      printf("Enter Value: ");
      scanf("%d", &x);
      Enqueue(Q, x);
      Print(Q);
      break;
    case 3:
      Dequeue(Q);
      Print(Q);
      break;
    case 0:
      break;
    default:
      printf("Invalid Input. Try Again.\n");
    }
  } while (n != 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x1a8(%rbp)
sub    $0x3,%rax
ja     1248 <main+0xf8>
mov    -0x1a8(%rbp),%rax
lea    0xe30(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x1a0(%rbp),%rdi
call   1070 <Print@plt>
jmp    1254 <main+0x104>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <Enqueue@plt>
lea    -0x1a0(%rbp),%rdi
call   1070 <Print@plt>
jmp    1254 <main+0x104>
lea    -0x1a0(%rbp),%rdi
call   1060 <Dequeue@plt>
lea    -0x1a0(%rbp),%rdi
call   1070 <Print@plt>
jmp    1254 <main+0x104>
jmp    1254 <main+0x104>
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
jmp    1259 <main+0x109>
cmpl   $0x0,-0x8(%rbp)
jne    1162 <main+0x12>
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xed6(%rip),%r13
lea    0xe91(%rip),%rbx
lea    0xe92(%rip),%rbp
lea    0x8(%rsp),%r14
lea    0xe6e(%rip),%r12
lea    0x10(%rsp),%r15
jmp    11bb <main+0x5b>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1070 <Dequeue@plt>
mov    %r15,%rdi
call   1080 <Print@plt>
cmpl   $0x0,0x8(%rsp)
je     1257 <main+0xf7>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0x3,%rax
ja     1240 <main+0xe0>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r15,%rdi
call   1030 <Enqueue@plt>
jmp    11a8 <main+0x48>
nopw   0x0(%rax,%rax,1)
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x8(%rsp)
jne    11bb <main+0x5b>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"1. Print Queue\0A\00"
@.str.1 = [12 x i8] c"2. Enqueue\0A\00"
@.str.2 = [12 x i8] c"3. Dequeue\0A\00"
@.str.3 = [9 x i8] c"0. Exit\0A\00"
@.str.4 = [8 x i8] c"Input: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [14 x i8] c"Enter Value: \00"
@.str.7 = [27 x i8] c"Invalid Input. Try Again.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i32]
store i32 0, i32* %1
br label %5
5: ; preds = %33, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
switch i32 %12, label %30 [
i32 1, label %13
i32 2, label %16
i32 3, label %24
i32 0, label %29
]
13: ; preds = %5
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%15 = call i32 @Print(i32* %14)
br label %32
16: ; preds = %5
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%20 = load i32, i32* %3
%21 = call i32 @Enqueue(i32* %19, i32 %20)
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%23 = call i32 @Print(i32* %22)
br label %32
24: ; preds = %5
%25 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%26 = call i32 @Dequeue(i32* %25)
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%28 = call i32 @Print(i32* %27)
br label %32
29: ; preds = %5
br label %32
30: ; preds = %5
%31 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %32
32: ; preds = %30, %29, %24, %16, %13
br label %33
33: ; preds = %32
%34 = load i32, i32* %2
%35 = icmp ne i32 %34, 0
br i1 %35, label %5, label %36
36: ; preds = %33
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str.4 = [8 x i8] c"Input: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [14 x i8] c"Enter Value: \00"
@str = [15 x i8] c"1. Print Queue\00"
@str.8 = [11 x i8] c"2. Enqueue\00"
@str.9 = [11 x i8] c"3. Dequeue\00"
@str.10 = [8 x i8] c"0. Exit\00"
@str.11 = [26 x i8] c"Invalid Input. Try Again.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [100 x i32]* %3 to i8*
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
br label %8
8: ; preds = %29, %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.10, i64 0, i64 0))
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
switch i32 %15, label %27 [
i32 1, label %16
i32 2, label %18
i32 3, label %24
i32 0, label %32
]
16: ; preds = %8
%17 = call i32 @Print(i32* %7)
br label %29
18: ; preds = %8
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = call i32 @Enqueue(i32* %7, i32 %21)
%23 = call i32 @Print(i32* %7)
br label %29
24: ; preds = %8
%25 = call i32 @Dequeue(i32* %7)
%26 = call i32 @Print(i32* %7)
br label %29
27: ; preds = %8
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
br label %29
29: ; preds = %16, %18, %24, %27
%30 = load i32, i32* %1
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %8
32: ; preds = %8, %29
ret i32 0
}