#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 */
void *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(4);
  ptr[1] = Mem_Alloc(8);
  assert(Mem_Free(ptr[0]) == 0);
  assert(Mem_Free(ptr[1]) == 0);
  ptr[2] = Mem_Alloc(16);
  ptr[3] = Mem_Alloc(4);
  assert(Mem_Free(ptr[2]) == 0);
  assert(Mem_Free(ptr[3]) == 0);
  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    $0x4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x8,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x28(%rbp)
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    -0x28(%rbp),%rdi
call   1040 <Mem_Free@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x10,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,-0x18(%rbp)
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    -0x18(%rbp),%rdi
call   1040 <Mem_Free@plt>
cmp    $0x0,%rax
sete   %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    $0x4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%rbx
mov    $0x8,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r14
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    $0x10,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%r14
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>
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 i8* @Mem_Alloc(i32 4)
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
store i8* %7, i8** %8
%9 = call i8* @Mem_Alloc(i32 8)
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
store i8* %9, i8** %10
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%12 = load i8*, i8** %11
%13 = call i64 @Mem_Free(i8* %12)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @Mem_Free(i8* %18)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i8* @Mem_Alloc(i32 16)
%24 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
store i8* %23, i8** %24
%25 = call i8* @Mem_Alloc(i32 4)
%26 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
store i8* %25, i8** %26
%27 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%28 = load i8*, i8** %27
%29 = call i64 @Mem_Free(i8* %28)
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%34 = load i8*, i8** %33
%35 = call i64 @Mem_Free(i8* %34)
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = 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 i8* @Mem_Alloc(i32 4)
%6 = tail call i8* @Mem_Alloc(i32 8)
%7 = tail call i64 @Mem_Free(i8* %5)
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i64 @Mem_Free(i8* %6)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i8* @Mem_Alloc(i32 16)
%16 = tail call i8* @Mem_Alloc(i32 4)
%17 = tail call i64 @Mem_Free(i8* %15)
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i64 @Mem_Free(i8* %16)
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i32 @exit(i32 0)
unreachable
}