#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 QUEUEgethead();
int /*<<< orphan*/ QUEUEinit(int);
int /*<<< orphan*/ QUEUEputhead(int);
int /*<<< orphan*/ QUEUEputtail(int);
int /*<<< orphan*/ printf(char *, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int i, t;
  srand(time(NULL));
  QUEUEinit(5);
  for (i = 0; i < 5; ++i) {
    t = rand() % 100;
    if (i % 2) {
      QUEUEputhead(t);
      printf("%i to head\n", t);
    } else {
      QUEUEputtail(t);
      printf("%i to tail\n", t);
    }
  }
  printf("Next: %d\n", QUEUEgethead());
  printf("Next: %d\n", QUEUEgethead());
  printf("Next: %d\n", QUEUEgethead());
  printf("Next: %d\n", QUEUEgethead());
  printf("Next: %d\n", QUEUEgethead());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x5,%edi
call   1030 <QUEUEinit@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1226 <main+0xa6>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11fc <main+0x7c>
mov    -0xc(%rbp),%edi
call   1070 <QUEUEputhead@plt>
mov    -0xc(%rbp),%esi
lea    0xe0e(%rip),%rdi
call   1050 <printf@plt>
jmp    1213 <main+0x93>
mov    -0xc(%rbp),%edi
call   1090 <QUEUEputtail@plt>
mov    -0xc(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1050 <printf@plt>
jmp    1218 <main+0x98>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b0 <main+0x30>
mov    $0x0,%al
call   1040 <QUEUEgethead@plt>
mov    %eax,%esi
lea    0xde2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <QUEUEgethead@plt>
mov    %eax,%esi
lea    0xdcd(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <QUEUEgethead@plt>
mov    %eax,%esi
lea    0xdb8(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <QUEUEgethead@plt>
mov    %eax,%esi
lea    0xda3(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <QUEUEgethead@plt>
mov    %eax,%esi
lea    0xd8e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x5,%edi
call   1030 <QUEUEinit@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1090 <QUEUEputtail@plt>
lea    0xe3e(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1070 <QUEUEputhead@plt>
lea    0xdf7(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1090 <QUEUEputtail@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1070 <QUEUEputhead@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1090 <QUEUEputtail@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <QUEUEgethead@plt>
lea    0xd5b(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <QUEUEgethead@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <QUEUEgethead@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <QUEUEgethead@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <QUEUEgethead@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%i to head\0A\00"
@.str.1 = [12 x i8] c"%i to tail\0A\00"
@.str.2 = [10 x i8] c"Next: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
%6 = call i32 @QUEUEinit(i32 5)
store i32 0, i32* %2
br label %7
7: ; preds = %27, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %30
10: ; preds = %7
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 100
store i32 %12, i32* %3
%13 = load i32, i32* %2
%14 = srem i32 %13, 2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load i32, i32* %3
%18 = call i32 @QUEUEputhead(i32 %17)
%19 = load i32, i32* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %26
21: ; preds = %10
%22 = load i32, i32* %3
%23 = call i32 @QUEUEputtail(i32 %22)
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %21, %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %7
30: ; preds = %7
%31 = call i32 (...) @QUEUEgethead()
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = call i32 (...) @QUEUEgethead()
%34 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = call i32 (...) @QUEUEgethead()
%36 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = call i32 (...) @QUEUEgethead()
%38 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = call i32 (...) @QUEUEgethead()
%40 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%i to head\0A\00"
@.str.1 = [12 x i8] c"%i to tail\0A\00"
@.str.2 = [10 x i8] c"Next: %d\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 @QUEUEinit(i32 5)
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 100
%6 = tail call i32 @QUEUEputtail(i32 %5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 100
%10 = tail call i32 @QUEUEputhead(i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9)
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 100
%14 = tail call i32 @QUEUEputtail(i32 %13)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 100
%18 = tail call i32 @QUEUEputhead(i32 %17)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %17)
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 100
%22 = tail call i32 @QUEUEputtail(i32 %21)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%24 = tail call i32 (...) @QUEUEgethead()
%25 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = tail call i32 (...) @QUEUEgethead()
%27 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = tail call i32 (...) @QUEUEgethead()
%29 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = tail call i32 (...) @QUEUEgethead()
%31 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = tail call i32 (...) @QUEUEgethead()
%33 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %32)
ret i32 0
}