#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 *);
scalar_t__ test_allocation();
scalar_t__ test_dequeueing();
scalar_t__ test_enqueueing();
scalar_t__ test_is_empty();
scalar_t__ test_peek();
int queue_test() {
  printf("Testing queue allocation...\n");
  if (test_allocation())
    printf("SUCCESS\n");
  else {
    printf("FAILURE\n");
    return 0;
  }
  printf("Testing queue appending...\n");
  if (test_enqueueing())
    printf("SUCCESS\n");
  else {
    printf("FAILURE\n");
    return 0;
  }
  printf("Testing queue removals...\n");
  if (test_dequeueing())
    printf("SUCCESS\n");
  else {
    printf("FAILURE\n");
    return 0;
  }
  printf("Testing queue iterators...\n");
  if (test_peek())
    printf("SUCCESS\n");
  else {
    printf("FAILURE\n");
    return 0;
  }
  printf("Testing queue state checks...\n");
  if (test_is_empty())
    printf("SUCCESS\n");
  else {
    printf("FAILURE\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<queue_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <test_allocation@plt>
cmp    $0x0,%rax
je     1196 <queue_test+0x36>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <queue_test+0x4e>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cd <queue_test+0x16d>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <test_enqueueing@plt>
cmp    $0x0,%rax
je     11dc <queue_test+0x7c>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
jmp    11f4 <queue_test+0x94>
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cd <queue_test+0x16d>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <test_dequeueing@plt>
cmp    $0x0,%rax
je     1222 <queue_test+0xc2>
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
jmp    123a <queue_test+0xda>
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cd <queue_test+0x16d>
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <test_peek@plt>
cmp    $0x0,%rax
je     1268 <queue_test+0x108>
lea    0xdbf(%rip),%rdi
call   1040 <printf@plt>
jmp    1280 <queue_test+0x120>
lea    0xdb7(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cd <queue_test+0x16d>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <test_is_empty@plt>
cmp    $0x0,%rax
je     12ae <queue_test+0x14e>
lea    0xd79(%rip),%rdi
call   1040 <printf@plt>
jmp    12c6 <queue_test+0x166>
lea    0xd71(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cd <queue_test+0x16d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<queue_test>:
push   %rbp
push   %r14
push   %rbx
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <test_allocation@plt>
lea    0xf0a(%rip),%rbx
test   %rax,%rax
je     122d <queue_test+0xcd>
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <test_enqueueing@plt>
test   %rax,%rax
je     122d <queue_test+0xcd>
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <test_dequeueing@plt>
test   %rax,%rax
je     122d <queue_test+0xcd>
lea    0xeb6(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <test_peek@plt>
test   %rax,%rax
je     122d <queue_test+0xcd>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <test_is_empty@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
lea    0xe61(%rip),%rbx
cmovne %r14,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Testing queue allocation...\0A\00"
@.str.1 = [9 x i8] c"SUCCESS\0A\00"
@.str.2 = [9 x i8] c"FAILURE\0A\00"
@.str.3 = [28 x i8] c"Testing queue appending...\0A\00"
@.str.4 = [27 x i8] c"Testing queue removals...\0A\00"
@.str.5 = [28 x i8] c"Testing queue iterators...\0A\00"
@.str.6 = [31 x i8] c"Testing queue state checks...\0A\00"
define i32 @queue_test() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%3 = call i64 (...) @test_allocation()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %42
9: ; preds = %5
%10 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%11 = call i64 (...) @test_enqueueing()
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %17
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %42
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%19 = call i64 (...) @test_dequeueing()
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %25
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %42
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%27 = call i64 (...) @test_peek()
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %33
31: ; preds = %25
%32 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %42
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%35 = call i64 (...) @test_is_empty()
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %41
39: ; preds = %33
%40 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %42
41: ; preds = %37
store i32 1, i32* %1
br label %42
42: ; preds = %41, %39, %31, %23, %15, %7
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@str = [28 x i8] c"Testing queue allocation...\00"
@str.9 = [27 x i8] c"Testing queue appending...\00"
@str.12 = [26 x i8] c"Testing queue removals...\00"
@str.15 = [27 x i8] c"Testing queue iterators...\00"
@str.18 = [30 x i8] c"Testing queue state checks...\00"
@str.19 = [8 x i8] c"FAILURE\00"
@str.20 = [8 x i8] c"SUCCESS\00"
define i32 @queue_test() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%2 = tail call i64 (...) @test_allocation()
%3 = icmp eq i64 %2, 0
br i1 %3, label %27, label %4
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.20, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i64 (...) @test_enqueueing()
%8 = icmp eq i64 %7, 0
br i1 %8, label %27, label %9
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.20, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.12, i64 0, i64 0))
%12 = tail call i64 (...) @test_dequeueing()
%13 = icmp eq i64 %12, 0
br i1 %13, label %27, label %14
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.20, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.15, i64 0, i64 0))
%17 = tail call i64 (...) @test_peek()
%18 = icmp eq i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %14
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.20, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.18, i64 0, i64 0))
%22 = tail call i64 (...) @test_is_empty()
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.19, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.20, i64 0, i64 0)
%25 = xor i1 %23, true
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %14, %19, %9, %4, %0
%28 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.19, i64 0, i64 0), %0 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.19, i64 0, i64 0), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.19, i64 0, i64 0), %9 ], [ %24, %19 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.19, i64 0, i64 0), %14 ]
%29 = phi i32 [ 0, %0 ], [ 0, %4 ], [ 0, %9 ], [ %26, %19 ], [ 0, %14 ]
%30 = tail call i32 @puts(i8* dereferenceable(1) %28)
ret i32 %29
}