#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 dequeue();
int /*<<< orphan*/ enqueue(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ queueDisplay();
int /*<<< orphan*/ queueEmpty();
int /*<<< orphan*/ queueInit(int);
int rand();
int main(void) {
  int i, item;
  queueInit(100);
  for (i = 0; i < 10; i++)
    enqueue(rand() % 100);
  printf("Initial Contents: ");
  queueDisplay();
  for (i = 0; i < 5; i++) {
    if (!queueEmpty()) {
      item = dequeue();
      printf("%d dequeue from queue\n", item);
    }
  }
  printf("Contents after dequeuing off 5 items: ");
  queueDisplay();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
call   1070 <queueInit@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11be <main+0x4e>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1080 <enqueue@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <main+0x20>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <queueDisplay@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1222 <main+0xb2>
mov    $0x0,%al
call   1060 <queueEmpty@plt>
cmp    $0x0,%eax
jne    120f <main+0x9f>
mov    $0x0,%al
call   1050 <dequeue@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <main+0xa4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11da <main+0x6a>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <queueDisplay@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x64,%edi
call   1070 <queueInit@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdi
imul   $0x51eb851f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
call   1080 <enqueue@plt>
lea    0xcee(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <queueDisplay@plt>
xor    %eax,%eax
call   1060 <queueEmpty@plt>
test   %eax,%eax
jne    1342 <main+0x1d2>
xor    %eax,%eax
call   1050 <dequeue@plt>
lea    0xcda(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <queueEmpty@plt>
test   %eax,%eax
jne    1364 <main+0x1f4>
xor    %eax,%eax
call   1050 <dequeue@plt>
lea    0xcb8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <queueEmpty@plt>
test   %eax,%eax
jne    1386 <main+0x216>
xor    %eax,%eax
call   1050 <dequeue@plt>
lea    0xc96(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <queueEmpty@plt>
test   %eax,%eax
jne    13a8 <main+0x238>
xor    %eax,%eax
call   1050 <dequeue@plt>
lea    0xc74(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <queueEmpty@plt>
test   %eax,%eax
jne    13ca <main+0x25a>
xor    %eax,%eax
call   1050 <dequeue@plt>
lea    0xc52(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc59(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <queueDisplay@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Initial Contents: \00"
@.str.1 = [23 x i8] c"%d dequeue from queue\0A\00"
@.str.2 = [39 x i8] c"Contents after dequeuing off 5 items: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @queueInit(i32 100)
store i32 0, i32* %2
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 100
%11 = call i32 @enqueue(i32 %10)
br label %12
12: ; preds = %8
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %5
15: ; preds = %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (...) @queueDisplay()
store i32 0, i32* %2
br label %18
18: ; preds = %29, %15
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 5
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = call i32 (...) @queueEmpty()
%23 = icmp ne i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = call i32 (...) @dequeue()
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %21
br label %29
29: ; preds = %28
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %18
32: ; preds = %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 (...) @queueDisplay()
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Initial Contents: \00"
@.str.1 = [23 x i8] c"%d dequeue from queue\0A\00"
@.str.2 = [39 x i8] c"Contents after dequeuing off 5 items: \00"
define i32 @main() {
%1 = tail call i32 @queueInit(i32 100)
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 100
%4 = tail call i32 @enqueue(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = tail call i32 @enqueue(i32 %6)
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 100
%10 = tail call i32 @enqueue(i32 %9)
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 100
%13 = tail call i32 @enqueue(i32 %12)
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 100
%16 = tail call i32 @enqueue(i32 %15)
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 100
%19 = tail call i32 @enqueue(i32 %18)
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 100
%22 = tail call i32 @enqueue(i32 %21)
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, 100
%25 = tail call i32 @enqueue(i32 %24)
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 100
%28 = tail call i32 @enqueue(i32 %27)
%29 = tail call i32 (...) @rand()
%30 = srem i32 %29, 100
%31 = tail call i32 @enqueue(i32 %30)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%33 = tail call i32 (...) @queueDisplay()
%34 = tail call i32 (...) @queueEmpty()
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %0
%37 = tail call i32 (...) @dequeue()
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %0, %36
%40 = tail call i32 (...) @queueEmpty()
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = tail call i32 (...) @dequeue()
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %39
%46 = tail call i32 (...) @queueEmpty()
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = tail call i32 (...) @dequeue()
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %48, %45
%52 = tail call i32 (...) @queueEmpty()
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = tail call i32 (...) @dequeue()
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %54, %51
%58 = tail call i32 (...) @queueEmpty()
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = tail call i32 (...) @dequeue()
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %60, %57
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%65 = tail call i32 (...) @queueDisplay()
ret i32 0
}