#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*/ exit(int);
int /*<<< orphan*/ free(void *);
void *malloc(int);
int /*<<< orphan*/ printf(char *);
int main() {
  void *p1, *p2, *p3, *p4, *p5, *p6;
  if ((p1 = malloc(8100)) == NULL || (p2 = malloc(16300)) == NULL ||
      (p3 = malloc(4000)) == NULL || (p4 = malloc(500)) == NULL ||
      (p5 = malloc(1023 * 1024)) == NULL ||
      (p6 = malloc(8191 * 1024)) == NULL) {
    printf("fail\n");
    exit(1);
  }
  free(p1);
  free(p2);
  free(p3);
  free(p4);
  free(p5);
  free(p6);
  p1 = malloc(64000);
  if (p1 == NULL) {
    printf("fail\n");
    exit(1);
  }
  free(p1);
  printf("pass\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1fa4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11df <main+0x9f>
mov    $0x3fac,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11df <main+0x9f>
mov    $0xfa0,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11df <main+0x9f>
mov    $0x1f4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11df <main+0x9f>
mov    $0xffc00,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     11df <main+0x9f>
mov    $0x7ffc00,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11f5 <main+0xb5>
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    $0xfa00,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    125a <main+0x11a>
lea    0xdb5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xd9c(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1fa4,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11fe <main+0xbe>
mov    %rax,%rbx
mov    $0x3fac,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11fe <main+0xbe>
mov    %rax,%r14
mov    $0xfa0,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11fe <main+0xbe>
mov    %rax,%r15
mov    $0x1f4,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11fe <main+0xbe>
mov    %rax,%r12
mov    $0xffc00,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11fe <main+0xbe>
mov    %rax,%r13
mov    $0x7ffc00,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11fe <main+0xbe>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0xfa00,%edi
call   1050 <malloc@plt>
test   %rax,%rax
jne    1214 <main+0xd4>
lea    0xe00(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    %rax,%rdi
call   1030 <free@plt>
lea    0xddd(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"fail\0A\00"
@.str.1 = [6 x i8] c"pass\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %1
%8 = call i8* @malloc(i32 8100)
store i8* %8, i8** %2
%9 = icmp eq i8* %8, null
br i1 %9, label %25, label %10
10: ; preds = %0
%11 = call i8* @malloc(i32 16300)
store i8* %11, i8** %3
%12 = icmp eq i8* %11, null
br i1 %12, label %25, label %13
13: ; preds = %10
%14 = call i8* @malloc(i32 4000)
store i8* %14, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = call i8* @malloc(i32 500)
store i8* %17, i8** %5
%18 = icmp eq i8* %17, null
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = call i8* @malloc(i32 1047552)
store i8* %20, i8** %6
%21 = icmp eq i8* %20, null
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = call i8* @malloc(i32 8387584)
store i8* %23, i8** %7
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %22, %19, %16, %13, %10, %0
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %22
%29 = load i8*, i8** %2
%30 = call i32 @free(i8* %29)
%31 = load i8*, i8** %3
%32 = call i32 @free(i8* %31)
%33 = load i8*, i8** %4
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %5
%36 = call i32 @free(i8* %35)
%37 = load i8*, i8** %6
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %7
%40 = call i32 @free(i8* %39)
%41 = call i8* @malloc(i32 64000)
store i8* %41, i8** %2
%42 = load i8*, i8** %2
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %47
44: ; preds = %28
%45 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %28
%48 = load i8*, i8** %2
%49 = call i32 @free(i8* %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%51 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@str = [5 x i8] c"pass\00"
@str.3 = [5 x i8] c"fail\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(8100) i8* @malloc(i32 8100)
%2 = icmp eq i8* %1, null
br i1 %2, label %18, label %3
3: ; preds = %0
%4 = tail call dereferenceable_or_null(16300) i8* @malloc(i32 16300)
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = tail call dereferenceable_or_null(4000) i8* @malloc(i32 4000)
%8 = icmp eq i8* %7, null
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = tail call dereferenceable_or_null(500) i8* @malloc(i32 500)
%11 = icmp eq i8* %10, null
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = tail call dereferenceable_or_null(1047552) i8* @malloc(i32 1047552)
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call dereferenceable_or_null(8387584) i8* @malloc(i32 8387584)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15, %12, %9, %6, %3, %0
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %15
%22 = tail call i32 @free(i8* %1)
%23 = tail call i32 @free(i8* %4)
%24 = tail call i32 @free(i8* %7)
%25 = tail call i32 @free(i8* %10)
%26 = tail call i32 @free(i8* %13)
%27 = tail call i32 @free(i8* %16)
%28 = tail call dereferenceable_or_null(64000) i8* @malloc(i32 64000)
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %33
30: ; preds = %21
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %21
%34 = tail call i32 @free(i8* %28)
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 @exit(i32 0)
unreachable
}