#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 dequeue(int *arr, int *front, int *rear, int *tag, int size) {
  if (*front == *rear && *tag == 0) {
    printf("\nUnderFlow");
    return 0;
  } else {
    printf("\n%d Dequeued", *(arr + *front));
    *front = (*front + 1) % size;
    if (*tag == 1)
      *tag = 0;
    return 0;
  }
}


x86 assembly (clang, -O0):
<dequeue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jne    1165 <dequeue+0x55>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1165 <dequeue+0x55>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <dequeue+0xa2>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltd
idivl  -0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %edx,(%rax)
mov    -0x28(%rbp),%rax
cmpl   $0x1,(%rax)
jne    11ab <dequeue+0x9b>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dequeue>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %rsi,%rbp
movslq (%rsi),%rax
cmp    (%rdx),%eax
jne    1129 <dequeue+0x19>
cmpl   $0x0,(%rbx)
je     1154 <dequeue+0x44>
mov    (%rdi,%rax,4),%esi
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x0(%rbp),%eax
add    $0x1,%eax
cltd
idiv   %r14d
mov    %edx,0x0(%rbp)
cmpl   $0x1,(%rbx)
jne    1162 <dequeue+0x52>
movl   $0x0,(%rbx)
jmp    1162 <dequeue+0x52>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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