#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 */
scalar_t__ isFullCQ(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
void insertCQ(int CQ[], int *front, int *rear, int key) {
  if (isFullCQ(front, rear)) {
    printf("\tOverflow");
  }
  if (*rear == -1) {
    *rear = 0;
    *front = 0;
  } else if (*rear == 5 - 1)
    *rear = 0;
  else
    *rear = *rear + 1;
  printf("\n\tRear is: %d", *rear);
  CQ[*rear] = key;
}


x86 assembly (clang, -O0):
<insertCQ>:
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),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <isFullCQ@plt>
cmp    $0x0,%rax
je     115c <insertCQ+0x3c>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    1182 <insertCQ+0x62>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    11b2 <insertCQ+0x92>
mov    -0x18(%rbp),%rax
cmpl   $0x4,(%rax)
jne    119e <insertCQ+0x7e>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    11ad <insertCQ+0x8d>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11b2 <insertCQ+0x92>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertCQ>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1040 <isFullCQ@plt>
test   %rax,%rax
je     1151 <insertCQ+0x31>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%esi
cmp    $0x4,%esi
je     116e <insertCQ+0x4e>
cmp    $0xffffffff,%esi
jne    1178 <insertCQ+0x58>
movl   $0x0,(%rbx)
movl   $0x0,0x0(%rbp)
mov    (%rbx),%esi
jmp    117d <insertCQ+0x5d>
movl   $0x0,(%rbx)
xor    %esi,%esi
jmp    117d <insertCQ+0x5d>
add    $0x1,%esi
mov    %esi,(%rbx)
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movslq (%rbx),%rax
mov    %r14d,(%r15,%rax,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"\09Overflow\00"
@.str.1 = [14 x i8] c"\0A\09Rear is: %d\00"
define void @insertCQ(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** %7
%11 = call i64 @isFullCQ(i32* %9, i32* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
%16 = load i32*, i32** %7
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32*, i32** %7
store i32 0, i32* %20
%21 = load i32*, i32** %6
store i32 0, i32* %21
br label %34
22: ; preds = %15
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 4
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i32*, i32** %7
store i32 0, i32* %27
br label %33
28: ; preds = %22
%29 = load i32*, i32** %7
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
%32 = load i32*, i32** %7
store i32 %31, i32* %32
br label %33
33: ; preds = %28, %26
br label %34
34: ; preds = %33, %19
%35 = load i32*, i32** %7
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %8
%39 = load i32*, i32** %5
%40 = load i32*, i32** %7
%41 = load i32, i32* %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %39, i64 %42
store i32 %38, i32* %43
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"\09Overflow\00"
@.str.1 = [14 x i8] c"\0A\09Rear is: %d\00"
define void @insertCQ(i32* nocapture writeonly %0, i32* %1, i32* %2, i32 %3) {
%5 = tail call i64 @isFullCQ(i32* %1, i32* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
%10 = load i32, i32* %2
switch i32 %10, label %14 [
i32 -1, label %11
i32 4, label %13
]
11: ; preds = %9
store i32 0, i32* %2
store i32 0, i32* %1
%12 = load i32, i32* %2
br label %16
13: ; preds = %9
store i32 0, i32* %2
br label %16
14: ; preds = %9
%15 = add nuw nsw i32 %10, 1
store i32 %15, i32* %2
br label %16
16: ; preds = %13, %14, %11
%17 = phi i32 [ 0, %13 ], [ %15, %14 ], [ %12, %11 ]
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %0, i64 %20
store i32 %3, i32* %21
ret void
}