#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 *, ...);
char *test_bitmask(int /*<<< orphan*/);
char *test_deq_basic(int /*<<< orphan*/);
char *test_deq_basic2(int /*<<< orphan*/);
char *test_deq_multi(int /*<<< orphan*/);
int tool_tests(void) {
  int result = 0;
  char *test_group = "tool_tests";
  do {
    char *r = test_deq_basic(0);
    printf("Test Case %s.%s: ", test_group, "test_deq_basic");
    if (r) {
      printf("FAIL: %s\n", r);
      result++;
    } else
      printf("PASS\n");
  } while (0);
  ;
  do {
    char *r = test_deq_basic2(0);
    printf("Test Case %s.%s: ", test_group, "test_deq_basic2");
    if (r) {
      printf("FAIL: %s\n", r);
      result++;
    } else
      printf("PASS\n");
  } while (0);
  ;
  do {
    char *r = test_deq_multi(0);
    printf("Test Case %s.%s: ", test_group, "test_deq_multi");
    if (r) {
      printf("FAIL: %s\n", r);
      result++;
    } else
      printf("PASS\n");
  } while (0);
  ;
  do {
    char *r = test_bitmask(0);
    printf("Test Case %s.%s: ", test_group, "test_bitmask");
    if (r) {
      printf("FAIL: %s\n", r);
      result++;
    } else
      printf("PASS\n");
  } while (0);
  ;
  return result;
}


x86 assembly (clang, -O0):
<tool_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
xor    %edi,%edi
call   1040 <test_deq_basic@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe8b(%rip),%rdi
lea    0xe96(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11b9 <tool_tests+0x69>
mov    -0x18(%rbp),%rsi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c7 <tool_tests+0x77>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cc <tool_tests+0x7c>
jmp    11d1 <tool_tests+0x81>
xor    %edi,%edi
call   1060 <test_deq_basic2@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe24(%rip),%rdi
lea    0xe4e(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1220 <tool_tests+0xd0>
mov    -0x20(%rbp),%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    122e <tool_tests+0xde>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <tool_tests+0xe3>
jmp    1238 <tool_tests+0xe8>
xor    %edi,%edi
call   1070 <test_deq_multi@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xdbd(%rip),%rdi
lea    0xdf7(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     1287 <tool_tests+0x137>
mov    -0x28(%rbp),%rsi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1295 <tool_tests+0x145>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129a <tool_tests+0x14a>
jmp    129f <tool_tests+0x14f>
xor    %edi,%edi
call   1050 <test_bitmask@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xd56(%rip),%rdi
lea    0xd9f(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
je     12ee <tool_tests+0x19e>
mov    -0x30(%rbp),%rsi
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    12fc <tool_tests+0x1ac>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1301 <tool_tests+0x1b1>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tool_tests>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %edi,%edi
call   1050 <test_deq_basic@plt>
mov    %rax,%rbx
lea    0xe95(%rip),%rdi
lea    0xe83(%rip),%rsi
lea    0xe99(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbx,%rbx
je     11a8 <tool_tests+0x48>
lea    0xe95(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
jmp    11b4 <tool_tests+0x54>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <test_deq_basic2@plt>
mov    %rax,%rbx
lea    0xe46(%rip),%rdi
lea    0xe34(%rip),%rsi
lea    0xe63(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbx,%rbx
je     11f5 <tool_tests+0x95>
lea    0xe46(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
jmp    1201 <tool_tests+0xa1>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <test_deq_multi@plt>
mov    %rax,%rbx
lea    0xdf9(%rip),%rdi
lea    0xde7(%rip),%rsi
lea    0xe26(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbx,%rbx
je     1242 <tool_tests+0xe2>
lea    0xdf9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
jmp    124e <tool_tests+0xee>
lea    0xe19(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <test_bitmask@plt>
mov    %rax,%rbx
lea    0xdac(%rip),%rdi
lea    0xd9a(%rip),%rsi
lea    0xde8(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbx,%rbx
je     128f <tool_tests+0x12f>
lea    0xdac(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
jmp    129b <tool_tests+0x13b>
lea    0xdcc(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"tool_tests\00"
@.str.1 = [18 x i8] c"Test Case %s.%s: \00"
@.str.2 = [15 x i8] c"test_deq_basic\00"
@.str.3 = [10 x i8] c"FAIL: %s\0A\00"
@.str.4 = [6 x i8] c"PASS\0A\00"
@.str.5 = [16 x i8] c"test_deq_basic2\00"
@.str.6 = [15 x i8] c"test_deq_multi\00"
@.str.7 = [13 x i8] c"test_bitmask\00"
define i32 @tool_tests() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %7
7: ; preds = %0
%8 = call i8* @test_deq_basic(i32 0)
store i8* %8, i8** %3
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %20
18: ; preds = %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
br label %21
21: ; preds = %20
br label %22
22: ; preds = %21
%23 = call i8* @test_deq_basic2(i32 0)
store i8* %23, i8** %4
%24 = load i8*, i8** %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%26 = load i8*, i8** %4
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %33
28: ; preds = %22
%29 = load i8*, i8** %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
store i32 %32, i32* %1
br label %35
33: ; preds = %22
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
%38 = call i8* @test_deq_multi(i32 0)
store i8* %38, i8** %5
%39 = load i8*, i8** %2
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %39, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%41 = load i8*, i8** %5
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %48
43: ; preds = %37
%44 = load i8*, i8** %5
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = load i32, i32* %1
%47 = add nsw i32 %46, 1
store i32 %47, i32* %1
br label %50
48: ; preds = %37
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %43
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
%53 = call i8* @test_bitmask(i32 0)
store i8* %53, i8** %6
%54 = load i8*, i8** %2
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %54, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%56 = load i8*, i8** %6
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %63
58: ; preds = %52
%59 = load i8*, i8** %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %59)
%61 = load i32, i32* %1
%62 = add nsw i32 %61, 1
store i32 %62, i32* %1
br label %65
63: ; preds = %52
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %65
65: ; preds = %63, %58
br label %66
66: ; preds = %65
%67 = load i32, i32* %1
ret i32 %67
}

LLVM IR (-O2):
@.str = [11 x i8] c"tool_tests\00"
@.str.1 = [18 x i8] c"Test Case %s.%s: \00"
@.str.2 = [15 x i8] c"test_deq_basic\00"
@.str.3 = [10 x i8] c"FAIL: %s\0A\00"
@.str.5 = [16 x i8] c"test_deq_basic2\00"
@.str.6 = [15 x i8] c"test_deq_multi\00"
@.str.7 = [13 x i8] c"test_bitmask\00"
@str.10 = [5 x i8] c"PASS\00"
define i32 @tool_tests() {
%1 = tail call i8* @test_deq_basic(i32 0)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i8* %1, null
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %8
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.10, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ 1, %4 ], [ 0, %6 ]
%10 = tail call i8* @test_deq_basic2(i32 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i8* %10, null
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%15 = add nuw nsw i32 %9, 1
br label %18
16: ; preds = %8
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.10, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = phi i32 [ %15, %13 ], [ %9, %16 ]
%20 = tail call i8* @test_deq_multi(i32 0)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%22 = icmp eq i8* %20, null
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%25 = add nuw nsw i32 %19, 1
br label %28
26: ; preds = %18
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.10, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = phi i32 [ %25, %23 ], [ %19, %26 ]
%30 = tail call i8* @test_bitmask(i32 0)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%32 = icmp eq i8* %30, null
br i1 %32, label %36, label %33
33: ; preds = %28
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%35 = add nuw nsw i32 %29, 1
br label %38
36: ; preds = %28
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.10, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
%39 = phi i32 [ %35, %33 ], [ %29, %36 ]
ret i32 %39
}