#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[4];
  ptr[0] = Mem_Alloc(800);
  assert(ptr[0] != NULL);
  ptr[1] = Mem_Alloc(800);
  assert(ptr[1] != NULL);
  ptr[2] = Mem_Alloc(800);
  assert(ptr[2] != NULL);
  ptr[3] = Mem_Alloc(800);
  assert(ptr[3] != NULL);
  while (Mem_Alloc(800) != NULL)
    ;
  assert(Mem_Free(ptr[1]) == 0);
  assert(Mem_Free(ptr[2]) == 0);
  ptr[2] = Mem_Alloc(1600);
  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    $0x320,%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    $0x320,%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    $0x320,%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    $0x320,%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    $0x320,%edi
call   1060 <Mem_Alloc@plt>
cmp    $0x0,%rax
je     1213 <main+0xc3>
jmp    11fa <main+0xaa>
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    -0x20(%rbp),%rdi
call   1040 <Mem_Free@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x640,%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   %r14
push   %rbx
push   %rax
mov    $0x1000,%edi
call   1030 <Mem_Init@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    $0x320,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x320,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x320,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x320,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x320,%edi
call   1060 <Mem_Alloc@plt>
test   %rax,%rax
jne    11e0 <main+0x90>
mov    %r14,%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    $0x640,%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 [4 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 800)
%8 = bitcast i32* %7 to i8*
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
store i8* %8, i8** %9
%10 = getelementptr inbounds [4 x i8*], [4 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 800)
%16 = bitcast i32* %15 to i8*
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
store i8* %16, i8** %17
%18 = getelementptr inbounds [4 x i8*], [4 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 800)
%24 = bitcast i32* %23 to i8*
%25 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
store i8* %24, i8** %25
%26 = getelementptr inbounds [4 x i8*], [4 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 800)
%32 = bitcast i32* %31 to i8*
%33 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
store i8* %32, i8** %33
%34 = getelementptr inbounds [4 x i8*], [4 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)
br label %39
39: ; preds = %42, %0
%40 = call i32* @Mem_Alloc(i32 800)
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %43
42: ; preds = %39
br label %39
43: ; preds = %39
%44 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%45 = load i8*, i8** %44
%46 = call i64 @Mem_Free(i8* %45)
%47 = icmp eq i64 %46, 0
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%51 = load i8*, i8** %50
%52 = call i64 @Mem_Free(i8* %51)
%53 = icmp eq i64 %52, 0
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = call i32* @Mem_Alloc(i32 1600)
%57 = bitcast i32* %56 to i8*
%58 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
store i8* %57, i8** %58
%59 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%60 = load i8*, i8** %59
%61 = icmp ne i8* %60, null
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = 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 800)
%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 800)
%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 800)
%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 800)
%18 = icmp ne i32* %17, null
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
br label %21
21: ; preds = %21, %0
%22 = tail call i32* @Mem_Alloc(i32 800)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %21
24: ; preds = %21
%25 = bitcast i32* %13 to i8*
%26 = bitcast i32* %9 to i8*
%27 = tail call i64 @Mem_Free(i8* %26)
%28 = icmp eq i64 %27, 0
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = tail call i64 @Mem_Free(i8* %25)
%32 = icmp eq i64 %31, 0
%33 = zext i1 %32 to i32
%34 = tail call i32 @assert(i32 %33)
%35 = tail call i32* @Mem_Alloc(i32 1600)
%36 = icmp ne i32* %35, null
%37 = zext i1 %36 to i32
%38 = tail call i32 @assert(i32 %37)
%39 = tail call i32 @exit(i32 0)
unreachable
}