#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 *, int);
int dequeue(int *arr, int *pfront, int *prear) {
  int data = arr[*pfront];
  printf("Dequeueing: %d\n", data);
  arr[*pfront] = 0;
  if (*pfront == *prear)
    *pfront = *prear = -1;
  else
    (*pfront)++;
  return data;
}


x86 assembly (clang, -O0):
<dequeue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jne    1181 <dequeue+0x71>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    118c <dequeue+0x7c>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dequeue>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
movslq (%rsi),%rax
mov    (%rdi,%rax,4),%r15d
lea    0xed2(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
movslq (%rbx),%rax
movl   $0x0,0x0(%rbp,%rax,4)
mov    (%rbx),%eax
cmp    (%r14),%eax
jne    1156 <dequeue+0x46>
movl   $0xffffffff,(%r14)
mov    $0xffffffff,%eax
jmp    1159 <dequeue+0x49>
add    $0x1,%eax
mov    %eax,(%rbx)
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Dequeueing: %d\0A\00"
define i32 @dequeue(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %4
%9 = load i32*, i32** %5
%10 = load i32, i32* %9
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %8, i64 %11
%13 = load i32, i32* %12
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %4
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %16, i64 %19
store i32 0, i32* %20
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = load i32*, i32** %6
%24 = load i32, i32* %23
%25 = icmp eq i32 %22, %24
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = load i32*, i32** %6
store i32 -1, i32* %27
%28 = load i32*, i32** %5
store i32 -1, i32* %28
br label %33
29: ; preds = %3
%30 = load i32*, i32** %5
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
br label %33
33: ; preds = %29, %26
%34 = load i32, i32* %7
ret i32 %34
}

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