#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ print_bad();
int /*<<< orphan*/ print_ok();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ test_boundry_alloc_free(int);
int /*<<< orphan*/ test_create_distroy();
int /*<<< orphan*/ test_random_alloc_free(int, int);
int /*<<< orphan*/ test_simple_alloc_free(int);
int main() {
  fprintf(stderr, "Testing create distroy ...... ");
  if (!test_create_distroy()) {
    print_bad();
    exit(1);
  } else
    print_ok();
  fprintf(stderr, "Testing simple alloc free ...... ");
  if (!test_simple_alloc_free(500)) {
    print_bad();
    exit(1);
  } else
    print_ok();
  fprintf(stderr, "Testing boundry alloc free ...... ");
  if (!test_boundry_alloc_free(500)) {
    print_bad();
    exit(1);
  } else
    print_ok();
  fprintf(stderr, "Testing random alloc free ...... ");
  if (!test_random_alloc_free(500, 100)) {
    print_bad();
    exit(1);
  } else
    print_ok();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1030 <test_create_distroy@plt>
cmp    $0x0,%eax
jne    11c5 <main+0x45>
mov    $0x0,%al
call   1080 <print_bad@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1050 <print_ok@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1f4,%edi
call   1070 <test_simple_alloc_free@plt>
cmp    $0x0,%eax
jne    1205 <main+0x85>
mov    $0x0,%al
call   1080 <print_bad@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1050 <print_ok@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1f4,%edi
call   10a0 <test_boundry_alloc_free@plt>
cmp    $0x0,%eax
jne    1245 <main+0xc5>
mov    $0x0,%al
call   1080 <print_bad@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1050 <print_ok@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1f4,%edi
mov    $0x64,%esi
call   1040 <test_random_alloc_free@plt>
cmp    $0x0,%eax
jne    128a <main+0x10a>
mov    $0x0,%al
call   1080 <print_bad@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1050 <print_ok@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e58(%rip),%rbx
mov    (%rbx),%edi
lea    0xe6f(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1030 <test_create_distroy@plt>
test   %eax,%eax
je     121a <main+0x9a>
xor    %eax,%eax
call   1050 <print_ok@plt>
mov    (%rbx),%edi
lea    0xe6e(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1f4,%edi
call   1070 <test_simple_alloc_free@plt>
test   %eax,%eax
je     121a <main+0x9a>
xor    %eax,%eax
call   1050 <print_ok@plt>
mov    (%rbx),%edi
lea    0xe6d(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1f4,%edi
call   10a0 <test_boundry_alloc_free@plt>
test   %eax,%eax
je     121a <main+0x9a>
xor    %eax,%eax
call   1050 <print_ok@plt>
mov    (%rbx),%edi
lea    0xe6d(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1f4,%edi
mov    $0x64,%esi
call   1040 <test_random_alloc_free@plt>
test   %eax,%eax
je     121a <main+0x9a>
xor    %eax,%eax
call   1050 <print_ok@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1080 <print_bad@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Testing create distroy ...... \00"
@.str.1 = [34 x i8] c"Testing simple alloc free ...... \00"
@.str.2 = [35 x i8] c"Testing boundry alloc free ...... \00"
@.str.3 = [34 x i8] c"Testing random alloc free ...... \00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @stderr
%3 = call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @test_create_distroy()
%5 = icmp ne i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 (...) @print_bad()
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i32 (...) @print_ok()
br label %11
11: ; preds = %9
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @test_simple_alloc_free(i32 500)
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = call i32 (...) @print_bad()
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %11
%20 = call i32 (...) @print_ok()
br label %21
21: ; preds = %19
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @test_boundry_alloc_free(i32 500)
%25 = icmp ne i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %21
%27 = call i32 (...) @print_bad()
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %21
%30 = call i32 (...) @print_ok()
br label %31
31: ; preds = %29
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @test_random_alloc_free(i32 500, i32 100)
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %31
%37 = call i32 (...) @print_bad()
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %31
%40 = call i32 (...) @print_ok()
br label %41
41: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Testing create distroy ...... \00"
@.str.1 = [34 x i8] c"Testing simple alloc free ...... \00"
@.str.2 = [35 x i8] c"Testing boundry alloc free ...... \00"
@.str.3 = [34 x i8] c"Testing random alloc free ...... \00"
define i32 @main() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @test_create_distroy()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 (...) @print_bad()
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i32 (...) @print_ok()
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @test_simple_alloc_free(i32 500)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = tail call i32 (...) @print_bad()
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %8
%18 = tail call i32 (...) @print_ok()
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @test_boundry_alloc_free(i32 500)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = tail call i32 (...) @print_bad()
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %17
%27 = tail call i32 (...) @print_ok()
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%30 = tail call i32 @test_random_alloc_free(i32 500, i32 100)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = tail call i32 (...) @print_bad()
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %26
%36 = tail call i32 (...) @print_ok()
ret i32 0
}