#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int pool_alloc_free_alloc();
int pool_basic_alloc();
int pool_basic_alloc_limited();
int pool_size_calc();
int pool_size_rounding();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int failures = 0;
  {
    int ret = pool_size_calc();
    if (ret != 0) {
      failures++;
      fprintf(stderr, "Test %s FAILED!\n", "pool_size_calc");
    } else {
      printf("Test %s passed.\n", "pool_size_calc");
    }
  };
  {
    int ret = pool_size_rounding();
    if (ret != 0) {
      failures++;
      fprintf(stderr, "Test %s FAILED!\n", "pool_size_rounding");
    } else {
      printf("Test %s passed.\n", "pool_size_rounding");
    }
  };
  {
    int ret = pool_basic_alloc();
    if (ret != 0) {
      failures++;
      fprintf(stderr, "Test %s FAILED!\n", "pool_basic_alloc");
    } else {
      printf("Test %s passed.\n", "pool_basic_alloc");
    }
  };
  {
    int ret = pool_basic_alloc_limited();
    if (ret != 0) {
      failures++;
      fprintf(stderr, "Test %s FAILED!\n", "pool_basic_alloc_limited");
    } else {
      printf("Test %s passed.\n", "pool_basic_alloc_limited");
    }
  };
  {
    int ret = pool_alloc_free_alloc();
    if (ret != 0) {
      failures++;
      fprintf(stderr, "Test %s FAILED!\n", "pool_alloc_free_alloc");
    } else {
      printf("Test %s passed.\n", "pool_alloc_free_alloc");
    }
  };
  return failures;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1030 <pool_size_calc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11cb <main+0x5b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
lea    0xe50(%rip),%rdx
call   1070 <fprintf@plt>
jmp    11de <main+0x6e>
lea    0xe4e(%rip),%rdi
lea    0xe38(%rip),%rsi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <pool_size_rounding@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     121c <main+0xac>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
lea    0xe1f(%rip),%rdx
call   1070 <fprintf@plt>
jmp    122f <main+0xbf>
lea    0xdfd(%rip),%rdi
lea    0xe07(%rip),%rsi
call   1040 <printf@plt>
mov    $0x0,%al
call   1090 <pool_basic_alloc@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     126d <main+0xfd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
lea    0xde1(%rip),%rdx
call   1070 <fprintf@plt>
jmp    1280 <main+0x110>
lea    0xdac(%rip),%rdi
lea    0xdc9(%rip),%rsi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <pool_basic_alloc_limited@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     12be <main+0x14e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
lea    0xd53(%rip),%rsi
lea    0xda1(%rip),%rdx
call   1070 <fprintf@plt>
jmp    12d1 <main+0x161>
lea    0xd5b(%rip),%rdi
lea    0xd89(%rip),%rsi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <pool_alloc_free_alloc@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     130f <main+0x19f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
lea    0xd02(%rip),%rsi
lea    0xd69(%rip),%rdx
call   1070 <fprintf@plt>
jmp    1322 <main+0x1b2>
lea    0xd0a(%rip),%rdi
lea    0xd51(%rip),%rsi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <pool_size_calc@plt>
test   %eax,%eax
je     11a1 <main+0x31>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
lea    0xe7c(%rip),%rdx
call   1070 <fprintf@plt>
mov    $0x1,%ebx
jmp    11b4 <main+0x44>
lea    0xe78(%rip),%rdi
lea    0xe62(%rip),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <pool_size_rounding@plt>
test   %eax,%eax
je     11e0 <main+0x70>
add    $0x1,%ebx
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
lea    0xe58(%rip),%rdx
call   1070 <fprintf@plt>
jmp    11f3 <main+0x83>
lea    0xe39(%rip),%rdi
lea    0xe43(%rip),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <pool_basic_alloc@plt>
test   %eax,%eax
je     121f <main+0xaf>
add    $0x1,%ebx
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xdef(%rip),%rsi
lea    0xe2c(%rip),%rdx
call   1070 <fprintf@plt>
jmp    1232 <main+0xc2>
lea    0xdfa(%rip),%rdi
lea    0xe17(%rip),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <pool_basic_alloc_limited@plt>
test   %eax,%eax
je     125e <main+0xee>
add    $0x1,%ebx
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xdb0(%rip),%rsi
lea    0xdfe(%rip),%rdx
call   1070 <fprintf@plt>
jmp    1271 <main+0x101>
lea    0xdbb(%rip),%rdi
lea    0xde9(%rip),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1080 <pool_alloc_free_alloc@plt>
test   %eax,%eax
je     129d <main+0x12d>
add    $0x1,%ebx
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
lea    0xd71(%rip),%rsi
lea    0xdd8(%rip),%rdx
call   1070 <fprintf@plt>
jmp    12b0 <main+0x140>
lea    0xd7c(%rip),%rdi
lea    0xdc3(%rip),%rsi
call   1040 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Test %s FAILED!\0A\00"
@.str.1 = [15 x i8] c"pool_size_calc\00"
@.str.2 = [17 x i8] c"Test %s passed.\0A\00"
@.str.3 = [19 x i8] c"pool_size_rounding\00"
@.str.4 = [17 x i8] c"pool_basic_alloc\00"
@.str.5 = [25 x i8] c"pool_basic_alloc_limited\00"
@.str.6 = [22 x i8] c"pool_alloc_free_alloc\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @pool_size_calc()
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %10
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ 1, %5 ], [ 0, %8 ]
%12 = tail call i32 (...) @pool_size_rounding()
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = add nuw nsw i32 %11, 1
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %20
18: ; preds = %10
%19 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = phi i32 [ %15, %14 ], [ %11, %18 ]
%22 = tail call i32 (...) @pool_basic_alloc()
%23 = icmp eq i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = add nuw nsw i32 %21, 1
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %30
28: ; preds = %20
%29 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
%31 = phi i32 [ %25, %24 ], [ %21, %28 ]
%32 = tail call i32 (...) @pool_basic_alloc_limited()
%33 = icmp eq i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = add nuw nsw i32 %31, 1
%36 = load i32, i32* @stderr
%37 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %40
38: ; preds = %30
%39 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = phi i32 [ %35, %34 ], [ %31, %38 ]
%42 = tail call i32 (...) @pool_alloc_free_alloc()
%43 = icmp eq i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = add nuw nsw i32 %41, 1
%46 = load i32, i32* @stderr
%47 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %50
48: ; preds = %40
%49 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
%51 = phi i32 [ %45, %44 ], [ %41, %48 ]
ret i32 %51
}