#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(880);
  assert(ptr[0] != NULL);
  ptr[1] = Mem_Alloc(880);
  assert(ptr[1] != NULL);
  ptr[2] = Mem_Alloc(880);
  assert(ptr[2] != NULL);
  ptr[3] = Mem_Alloc(880);
  assert(ptr[3] != NULL);
  assert(Mem_Alloc(880) == NULL);
  int free = (4096 - (880 + (32)) * 4) - (32);
  assert(Mem_Free(ptr[3]) == 0);
  free += (880 + 32);
  ptr[2] = Mem_Alloc(free - (32));
  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    $0x370,%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    $0x370,%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    $0x370,%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    $0x370,%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    $0x370,%edi
call   1060 <Mem_Alloc@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x1a0,-0x34(%rbp)
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    -0x34(%rbp),%eax
add    $0x390,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
sub    $0x20,%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   %rbx
mov    $0x1000,%edi
call   1030 <Mem_Init@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    $0x370,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x370,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x370,%edi
call   1060 <Mem_Alloc@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x370,%edi
call   1060 <Mem_Alloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
mov    $0x370,%edi
call   1060 <Mem_Alloc@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    $0x510,%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*]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 @Mem_Init(i32 4096)
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i32* @Mem_Alloc(i32 880)
%9 = bitcast i32* %8 to i8*
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
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 = icmp ne i8* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32* @Mem_Alloc(i32 880)
%17 = bitcast i32* %16 to i8*
%18 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
store i8* %17, i8** %18
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%20 = load i8*, i8** %19
%21 = icmp ne i8* %20, null
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32* @Mem_Alloc(i32 880)
%25 = bitcast i32* %24 to i8*
%26 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
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 = icmp ne i8* %28, null
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = call i32* @Mem_Alloc(i32 880)
%33 = bitcast i32* %32 to i8*
%34 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
store i8* %33, i8** %34
%35 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%36 = load i8*, i8** %35
%37 = icmp ne i8* %36, null
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32* @Mem_Alloc(i32 880)
%41 = icmp eq i32* %40, null
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
store i32 416, i32* %3
%44 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%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 = load i32, i32* %3
%51 = add nsw i32 %50, 912
store i32 %51, i32* %3
%52 = load i32, i32* %3
%53 = sub nsw i32 %52, 32
%54 = call i32* @Mem_Alloc(i32 %53)
%55 = bitcast i32* %54 to i8*
%56 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
store i8* %55, i8** %56
%57 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%58 = load i8*, i8** %57
%59 = icmp ne i8* %58, null
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
%62 = 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 880)
%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 880)
%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 880)
%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 880)
%18 = bitcast i32* %17 to i8*
%19 = icmp ne i32* %17, null
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32* @Mem_Alloc(i32 880)
%23 = icmp eq i32* %22, null
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i64 @Mem_Free(i8* %18)
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
%30 = tail call i32* @Mem_Alloc(i32 1296)
%31 = icmp ne i32* %30, null
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = tail call i32 @exit(i32 0)
unreachable
}