#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 /*<<< orphan*/ test_sorted();
int /*<<< orphan*/ test_sorted_empty_array();
int /*<<< orphan*/ test_unsorted();
int /*<<< orphan*/ test_unsorted_empty_array();
int main() {
  int counter = 0;
  if (!test_unsorted()) {
    printf("Unsorted test failed!\n");
    counter++;
  }
  if (!test_unsorted_empty_array()) {
    printf("Unsorted empty array test failed!\n");
    counter++;
  }
  if (!test_sorted()) {
    printf("Sorted test failed!\n");
    counter++;
  }
  if (!test_sorted_empty_array()) {
    printf("Sorted empty array test failed!\n");
    counter++;
  }
  printf("%d tests failed.\n", counter);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <test_unsorted@plt>
cmp    $0x0,%eax
jne    118d <main+0x3d>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <test_unsorted_empty_array@plt>
cmp    $0x0,%eax
jne    11b4 <main+0x64>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <test_sorted@plt>
cmp    $0x0,%eax
jne    11db <main+0x8b>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <test_sorted_empty_array@plt>
cmp    $0x0,%eax
jne    1202 <main+0xb2>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <test_unsorted@plt>
test   %eax,%eax
jne    117f <main+0x1f>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
xor    %eax,%eax
call   1070 <test_unsorted_empty_array@plt>
test   %eax,%eax
jne    1199 <main+0x39>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <test_sorted@plt>
test   %eax,%eax
jne    11b3 <main+0x53>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1080 <test_sorted_empty_array@plt>
test   %eax,%eax
jne    11cd <main+0x6d>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%ebx
lea    0xe2c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Unsorted test failed!\0A\00"
@.str.1 = [35 x i8] c"Unsorted empty array test failed!\0A\00"
@.str.2 = [21 x i8] c"Sorted test failed!\0A\00"
@.str.3 = [33 x i8] c"Sorted empty array test failed!\0A\00"
@.str.4 = [18 x i8] c"%d tests failed.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 (...) @test_unsorted()
%4 = icmp ne i32 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 1
store i32 %8, i32* %2
br label %9
9: ; preds = %5, %0
%10 = call i32 (...) @test_unsorted_empty_array()
%11 = icmp ne i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %16
16: ; preds = %12, %9
%17 = call i32 (...) @test_sorted()
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %23
23: ; preds = %19, %16
%24 = call i32 (...) @test_sorted_empty_array()
%25 = icmp ne i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %30
30: ; preds = %26, %23
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str.4 = [18 x i8] c"%d tests failed.\0A\00"
@str = [22 x i8] c"Unsorted test failed!\00"
@str.5 = [34 x i8] c"Unsorted empty array test failed!\00"
@str.6 = [20 x i8] c"Sorted test failed!\00"
@str.7 = [32 x i8] c"Sorted empty array test failed!\00"
define i32 @main() {
%1 = tail call i32 (...) @test_unsorted()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = phi i32 [ 0, %0 ], [ 1, %3 ]
%7 = tail call i32 (...) @test_unsorted_empty_array()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.5, i64 0, i64 0))
%11 = add nuw nsw i32 %6, 1
br label %12
12: ; preds = %9, %5
%13 = phi i32 [ %6, %5 ], [ %11, %9 ]
%14 = tail call i32 (...) @test_sorted()
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%18 = add nuw nsw i32 %13, 1
br label %19
19: ; preds = %16, %12
%20 = phi i32 [ %13, %12 ], [ %18, %16 ]
%21 = tail call i32 (...) @test_sorted_empty_array()
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
%25 = add nuw nsw i32 %20, 1
br label %26
26: ; preds = %23, %19
%27 = phi i32 [ %20, %19 ], [ %25, %23 ]
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %27)
ret i32 0
}