#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*/ *Mem_Alloc(int);
scalar_t__ Mem_Free(void *);
scalar_t__ Mem_Init(int);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int main() {
  assert(Mem_Init(4096) == 0);
  void *ptr[5];
  ptr[0] = Mem_Alloc(600);
  assert(ptr[0] != NULL);
  ptr[1] = Mem_Alloc(600);
  assert(ptr[1] != NULL);
  ptr[2] = Mem_Alloc(600);
  assert(ptr[2] != NULL);
  ptr[3] = Mem_Alloc(600);
  assert(ptr[3] != NULL);
  ptr[4] = Mem_Alloc(600);
  assert(ptr[4] != NULL);
  while (Mem_Alloc(600) != NULL)
    ;
  assert(Mem_Free(ptr[1]) == 0);
  assert(Mem_Free(ptr[3]) == 0);
  assert(Mem_Free(ptr[2]) == 0);
  ptr[2] = Mem_Alloc(1800);
  assert(ptr[2] != NULL);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1000,%edi
call   1030 <Mem_Init@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
cmp    $0x0,%rax
je     1233 <main+0xe3>
jmp    121a <main+0xca>
mov    -0x28(%rbp),%rdi
call   1040 <Mem_Free@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1040 <Mem_Free@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1040 <Mem_Free@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x708,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1000,%edi
call   1030 <Mem_Init@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r15
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
xchg   %ax,%ax
mov    $0x258,%edi
call   1060 <Mem_Alloc@plt>
test   %rax,%rax
jne    11f0 <main+0xa0>
mov    %r15,%rdi
call   1040 <Mem_Free@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1040 <Mem_Free@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1040 <Mem_Free@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    $0x708,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8*]
store i32 0, i32* %1
%3 = call i64 @Mem_Init(i32 4096)
%4 = icmp eq i64 %3, 0
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = call i32* @Mem_Alloc(i32 600)
%8 = bitcast i32* %7 to i8*
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* %8, i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32* @Mem_Alloc(i32 600)
%16 = bitcast i32* %15 to i8*
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
store i8* %16, i8** %17
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32* @Mem_Alloc(i32 600)
%24 = bitcast i32* %23 to i8*
%25 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* %24, i8** %25
%26 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
%27 = load i8*, i8** %26
%28 = icmp ne i8* %27, null
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = call i32* @Mem_Alloc(i32 600)
%32 = bitcast i32* %31 to i8*
%33 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
store i8* %32, i8** %33
%34 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
%35 = load i8*, i8** %34
%36 = icmp ne i8* %35, null
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = call i32* @Mem_Alloc(i32 600)
%40 = bitcast i32* %39 to i8*
%41 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
store i8* %40, i8** %41
%42 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
%43 = load i8*, i8** %42
%44 = icmp ne i8* %43, null
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
br label %47
47: ; preds = %50, %0
%48 = call i32* @Mem_Alloc(i32 600)
%49 = icmp ne i32* %48, null
br i1 %49, label %50, label %51
50: ; preds = %47
br label %47
51: ; preds = %47
%52 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
%53 = load i8*, i8** %52
%54 = call i64 @Mem_Free(i8* %53)
%55 = icmp eq i64 %54, 0
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
%59 = load i8*, i8** %58
%60 = call i64 @Mem_Free(i8* %59)
%61 = icmp eq i64 %60, 0
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
%65 = load i8*, i8** %64
%66 = call i64 @Mem_Free(i8* %65)
%67 = icmp eq i64 %66, 0
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = call i32* @Mem_Alloc(i32 1800)
%71 = bitcast i32* %70 to i8*
%72 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* %71, i8** %72
%73 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
%74 = load i8*, i8** %73
%75 = icmp ne i8* %74, null
%76 = zext i1 %75 to i32
%77 = call i32 @assert(i32 %76)
%78 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @Mem_Init(i32 4096)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32* @Mem_Alloc(i32 600)
%6 = icmp ne i32* %5, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32* @Mem_Alloc(i32 600)
%10 = icmp ne i32* %9, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32* @Mem_Alloc(i32 600)
%14 = icmp ne i32* %13, null
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32* @Mem_Alloc(i32 600)
%18 = icmp ne i32* %17, null
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32* @Mem_Alloc(i32 600)
%22 = icmp ne i32* %21, null
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
br label %25
25: ; preds = %25, %0
%26 = tail call i32* @Mem_Alloc(i32 600)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %25
28: ; preds = %25
%29 = bitcast i32* %17 to i8*
%30 = bitcast i32* %13 to i8*
%31 = bitcast i32* %9 to i8*
%32 = tail call i64 @Mem_Free(i8* %31)
%33 = icmp eq i64 %32, 0
%34 = zext i1 %33 to i32
%35 = tail call i32 @assert(i32 %34)
%36 = tail call i64 @Mem_Free(i8* %29)
%37 = icmp eq i64 %36, 0
%38 = zext i1 %37 to i32
%39 = tail call i32 @assert(i32 %38)
%40 = tail call i64 @Mem_Free(i8* %30)
%41 = icmp eq i64 %40, 0
%42 = zext i1 %41 to i32
%43 = tail call i32 @assert(i32 %42)
%44 = tail call i32* @Mem_Alloc(i32 1800)
%45 = icmp ne i32* %44, null
%46 = zext i1 %45 to i32
%47 = tail call i32 @assert(i32 %46)
%48 = tail call i32 @exit(i32 0)
unreachable
}