#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*/ printf(char *, ...);
void enqueue(int *queue, int *front, int *rear, int item) {
  if ((*front == 0 && *rear == 5 - 1) || (*front == *rear + 1)) {
    printf("\nQueue is full!\n");
    return;
  }
  if (*front == -1)
    *front = *rear = 0;
  else if (*rear == 5 - 1)
    *rear = 1;
  else
    *rear += 1;
  queue[*rear] = item;
  printf("\n%d was Inserted.\n", item);
}


x86 assembly (clang, -O0):
<enqueue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1141 <enqueue+0x31>
mov    -0x18(%rbp),%rax
cmpl   $0x4,(%rax)
je     1158 <enqueue+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    116b <enqueue+0x5b>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11df <enqueue+0xcf>
mov    -0x10(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    1191 <enqueue+0x81>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    11bd <enqueue+0xad>
mov    -0x18(%rbp),%rax
cmpl   $0x4,(%rax)
jne    11ad <enqueue+0x9d>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11b8 <enqueue+0xa8>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11bd <enqueue+0xad>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enqueue>:
mov    (%rsi),%eax
mov    (%rdx),%r8d
test   %eax,%eax
je     1148 <enqueue+0x28>
lea    0x1(%r8),%r9d
cmp    %r9d,%eax
je     116f <enqueue+0x4f>
cmp    $0xffffffff,%eax
jne    115b <enqueue+0x3b>
movl   $0x0,(%rdx)
movl   $0x0,(%rsi)
mov    (%rdx),%r9d
jmp    117e <enqueue+0x5e>
mov    %r8d,%r9d
inc    %r9d
sete   %al
cmp    $0x4,%r8d
je     116f <enqueue+0x4f>
test   %al,%al
jne    116f <enqueue+0x4f>
cmp    $0x4,%r8d
jne    117b <enqueue+0x5b>
movl   $0x1,(%rdx)
mov    $0x1,%r9d
jmp    117e <enqueue+0x5e>
lea    0xe9d(%rip),%rdi
jmp    1030 <puts@plt>
mov    %r9d,(%rdx)
movslq %r9d,%rax
mov    %ecx,(%rdi,%rax,4)
lea    0xe75(%rip),%rdi
mov    %ecx,%esi
xor    %eax,%eax
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"\0AQueue is full!\0A\00"
@.str.1 = [19 x i8] c"\0A%d was Inserted.\0A\00"
define void @enqueue(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%9 = load i32*, i32** %6
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load i32*, i32** %7
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 4
br i1 %15, label %23, label %16
16: ; preds = %12, %4
%17 = load i32*, i32** %6
%18 = load i32, i32* %17
%19 = load i32*, i32** %7
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
%22 = icmp eq i32 %18, %21
br i1 %22, label %23, label %25
23: ; preds = %16, %12
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %52
25: ; preds = %16
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32*, i32** %7
store i32 0, i32* %30
%31 = load i32*, i32** %6
store i32 0, i32* %31
br label %43
32: ; preds = %25
%33 = load i32*, i32** %7
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 4
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32*, i32** %7
store i32 1, i32* %37
br label %42
38: ; preds = %32
%39 = load i32*, i32** %7
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
br label %42
42: ; preds = %38, %36
br label %43
43: ; preds = %42, %29
%44 = load i32, i32* %8
%45 = load i32*, i32** %5
%46 = load i32*, i32** %7
%47 = load i32, i32* %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %45, i64 %48
store i32 %44, i32* %49
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %43, %23
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"\0A%d was Inserted.\0A\00"
@str = [16 x i8] c"\0AQueue is full!\00"
define void @enqueue(i32* nocapture writeonly %0, i32* nocapture %1, i32* nocapture %2, i32 %3) {
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
%7 = load i32, i32* %2
br i1 %6, label %8, label %13
8: ; preds = %4
%9 = icmp eq i32 %7, 4
%10 = add nsw i32 %7, 1
%11 = icmp eq i32 %10, 0
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %16, label %22
13: ; preds = %4
%14 = add nsw i32 %7, 1
%15 = icmp eq i32 %5, %14
br i1 %15, label %16, label %18
16: ; preds = %13, %8
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %32
18: ; preds = %13
%19 = icmp eq i32 %5, -1
br i1 %19, label %20, label %22
20: ; preds = %18
store i32 0, i32* %2
store i32 0, i32* %1
%21 = load i32, i32* %2
br label %27
22: ; preds = %8, %18
%23 = phi i32 [ %14, %18 ], [ %10, %8 ]
%24 = icmp eq i32 %7, 4
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 1, i32* %2
br label %27
26: ; preds = %22
store i32 %23, i32* %2
br label %27
27: ; preds = %25, %26, %20
%28 = phi i32 [ 1, %25 ], [ %23, %26 ], [ %21, %20 ]
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %0, i64 %29
store i32 %3, i32* %30
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3)
br label %32
32: ; preds = %27, %16
ret void
}