#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[7];
  ptr[0] = Mem_Alloc(500);
  assert(ptr[0] != NULL);
  ptr[1] = Mem_Alloc(500);
  assert(ptr[1] != NULL);
  ptr[2] = Mem_Alloc(500);
  assert(ptr[2] != NULL);
  ptr[3] = Mem_Alloc(500);
  assert(ptr[3] != NULL);
  ptr[4] = Mem_Alloc(500);
  assert(ptr[4] != NULL);
  ptr[5] = Mem_Alloc(500);
  assert(ptr[5] != NULL);
  ptr[6] = Mem_Alloc(500);
  assert(ptr[6] != NULL);
  while (Mem_Alloc(500) != NULL)
    ;
  assert(Mem_Free(ptr[1]) == 0);
  assert(Mem_Free(ptr[5]) == 0);
  assert(Mem_Free(ptr[2]) == 0);
  assert(Mem_Free(ptr[4]) == 0);
  assert(Mem_Free(ptr[3]) == 0);
  ptr[2] = Mem_Alloc(2500);
  assert(ptr[2] != NULL);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x1f4,%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    $0x1f4,%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    $0x1f4,%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    $0x1f4,%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    $0x1f4,%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    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
cmp    $0x0,%rax
je     1273 <main+0x123>
jmp    125a <main+0x10a>
mov    -0x38(%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    -0x30(%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    -0x28(%rbp),%rdi
call   1040 <Mem_Free@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x9c4,%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>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x1000,%edi
call   1030 <Mem_Init@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r12
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r15
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r13
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x1f4,%edi
call   1060 <Mem_Alloc@plt>
test   %rax,%rax
jne    1230 <main+0xe0>
mov    %r12,%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    %r15,%rdi
call   1040 <Mem_Free@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %r13,%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    $0x9c4,%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 [7 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 500)
%8 = bitcast i32* %7 to i8*
%9 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 0
store i8* %8, i8** %9
%10 = getelementptr inbounds [7 x i8*], [7 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 500)
%16 = bitcast i32* %15 to i8*
%17 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 1
store i8* %16, i8** %17
%18 = getelementptr inbounds [7 x i8*], [7 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 500)
%24 = bitcast i32* %23 to i8*
%25 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 2
store i8* %24, i8** %25
%26 = getelementptr inbounds [7 x i8*], [7 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 500)
%32 = bitcast i32* %31 to i8*
%33 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 3
store i8* %32, i8** %33
%34 = getelementptr inbounds [7 x i8*], [7 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 500)
%40 = bitcast i32* %39 to i8*
%41 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 4
store i8* %40, i8** %41
%42 = getelementptr inbounds [7 x i8*], [7 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)
%47 = call i32* @Mem_Alloc(i32 500)
%48 = bitcast i32* %47 to i8*
%49 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 5
store i8* %48, i8** %49
%50 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 5
%51 = load i8*, i8** %50
%52 = icmp ne i8* %51, null
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = call i32* @Mem_Alloc(i32 500)
%56 = bitcast i32* %55 to i8*
%57 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 6
store i8* %56, i8** %57
%58 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 6
%59 = load i8*, i8** %58
%60 = icmp ne i8* %59, null
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
br label %63
63: ; preds = %66, %0
%64 = call i32* @Mem_Alloc(i32 500)
%65 = icmp ne i32* %64, null
br i1 %65, label %66, label %67
66: ; preds = %63
br label %63
67: ; preds = %63
%68 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 1
%69 = load i8*, i8** %68
%70 = call i64 @Mem_Free(i8* %69)
%71 = icmp eq i64 %70, 0
%72 = zext i1 %71 to i32
%73 = call i32 @assert(i32 %72)
%74 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 5
%75 = load i8*, i8** %74
%76 = call i64 @Mem_Free(i8* %75)
%77 = icmp eq i64 %76, 0
%78 = zext i1 %77 to i32
%79 = call i32 @assert(i32 %78)
%80 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 2
%81 = load i8*, i8** %80
%82 = call i64 @Mem_Free(i8* %81)
%83 = icmp eq i64 %82, 0
%84 = zext i1 %83 to i32
%85 = call i32 @assert(i32 %84)
%86 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 4
%87 = load i8*, i8** %86
%88 = call i64 @Mem_Free(i8* %87)
%89 = icmp eq i64 %88, 0
%90 = zext i1 %89 to i32
%91 = call i32 @assert(i32 %90)
%92 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 3
%93 = load i8*, i8** %92
%94 = call i64 @Mem_Free(i8* %93)
%95 = icmp eq i64 %94, 0
%96 = zext i1 %95 to i32
%97 = call i32 @assert(i32 %96)
%98 = call i32* @Mem_Alloc(i32 2500)
%99 = bitcast i32* %98 to i8*
%100 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 2
store i8* %99, i8** %100
%101 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 2
%102 = load i8*, i8** %101
%103 = icmp ne i8* %102, null
%104 = zext i1 %103 to i32
%105 = call i32 @assert(i32 %104)
%106 = 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 500)
%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 500)
%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 500)
%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 500)
%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 500)
%22 = icmp ne i32* %21, null
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i32* @Mem_Alloc(i32 500)
%26 = icmp ne i32* %25, null
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = tail call i32* @Mem_Alloc(i32 500)
%30 = icmp ne i32* %29, null
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
br label %33
33: ; preds = %33, %0
%34 = tail call i32* @Mem_Alloc(i32 500)
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %33
36: ; preds = %33
%37 = bitcast i32* %25 to i8*
%38 = bitcast i32* %21 to i8*
%39 = bitcast i32* %17 to i8*
%40 = bitcast i32* %13 to i8*
%41 = bitcast i32* %9 to i8*
%42 = tail call i64 @Mem_Free(i8* %41)
%43 = icmp eq i64 %42, 0
%44 = zext i1 %43 to i32
%45 = tail call i32 @assert(i32 %44)
%46 = tail call i64 @Mem_Free(i8* %37)
%47 = icmp eq i64 %46, 0
%48 = zext i1 %47 to i32
%49 = tail call i32 @assert(i32 %48)
%50 = tail call i64 @Mem_Free(i8* %40)
%51 = icmp eq i64 %50, 0
%52 = zext i1 %51 to i32
%53 = tail call i32 @assert(i32 %52)
%54 = tail call i64 @Mem_Free(i8* %38)
%55 = icmp eq i64 %54, 0
%56 = zext i1 %55 to i32
%57 = tail call i32 @assert(i32 %56)
%58 = tail call i64 @Mem_Free(i8* %39)
%59 = icmp eq i64 %58, 0
%60 = zext i1 %59 to i32
%61 = tail call i32 @assert(i32 %60)
%62 = tail call i32* @Mem_Alloc(i32 2500)
%63 = icmp ne i32* %62, null
%64 = zext i1 %63 to i32
%65 = tail call i32 @assert(i32 %64)
%66 = tail call i32 @exit(i32 0)
unreachable
}