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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1fa4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0x3fac,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0xfa0,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0x1f4,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0xffc00,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0x7ffc00,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0x80000,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    $0xffc00,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0xffc00,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0x7ffc00,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     128b <main+0x13b>
mov    -0x10(%rbp),%rdi
mov    $0x80000,%esi
call   1060 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    12a1 <main+0x151>
lea    0xd6e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xd4c(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1fa4,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rdi
mov    $0x3fac,%esi
call   1060 <realloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rdi
mov    $0xfa0,%esi
call   1060 <realloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rdi
mov    $0x1f4,%esi
call   1060 <realloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rdi
mov    $0xffc00,%esi
call   1060 <realloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rdi
mov    $0x7ffc00,%esi
call   1060 <realloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rdi
mov    $0x80000,%esi
call   1060 <realloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rbx
mov    $0xffc00,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0xffc00,%esi
call   1060 <realloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rdi
mov    $0x7ffc00,%esi
call   1060 <realloc@plt>
test   %rax,%rax
je     122a <main+0xda>
mov    %rax,%rdi
mov    $0x80000,%esi
call   1060 <realloc@plt>
test   %rax,%rax
jne    1240 <main+0xf0>
lea    0xdd4(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rax,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xda9(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <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*
store i32 0, i32* %1
%4 = call i8* @malloc(i32 8100)
store i8* %4, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %45, label %6
6: ; preds = %0
%7 = load i8*, i8** %2
%8 = call i8* @realloc(i8* %7, i32 16300)
store i8* %8, i8** %2
%9 = icmp eq i8* %8, null
br i1 %9, label %45, label %10
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = call i8* @realloc(i8* %11, i32 4000)
store i8* %12, i8** %2
%13 = icmp eq i8* %12, null
br i1 %13, label %45, label %14
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = call i8* @realloc(i8* %15, i32 500)
store i8* %16, i8** %2
%17 = icmp eq i8* %16, null
br i1 %17, label %45, label %18
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = call i8* @realloc(i8* %19, i32 1047552)
store i8* %20, i8** %2
%21 = icmp eq i8* %20, null
br i1 %21, label %45, label %22
22: ; preds = %18
%23 = load i8*, i8** %2
%24 = call i8* @realloc(i8* %23, i32 8387584)
store i8* %24, i8** %2
%25 = icmp eq i8* %24, null
br i1 %25, label %45, label %26
26: ; preds = %22
%27 = load i8*, i8** %2
%28 = call i8* @realloc(i8* %27, i32 524288)
store i8* %28, i8** %2
%29 = icmp eq i8* %28, null
br i1 %29, label %45, label %30
30: ; preds = %26
%31 = call i8* @malloc(i32 1047552)
store i8* %31, i8** %3
%32 = icmp eq i8* %31, null
br i1 %32, label %45, label %33
33: ; preds = %30
%34 = load i8*, i8** %2
%35 = call i8* @realloc(i8* %34, i32 1047552)
store i8* %35, i8** %2
%36 = icmp eq i8* %35, null
br i1 %36, label %45, label %37
37: ; preds = %33
%38 = load i8*, i8** %2
%39 = call i8* @realloc(i8* %38, i32 8387584)
store i8* %39, i8** %2
%40 = icmp eq i8* %39, null
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = load i8*, i8** %2
%43 = call i8* @realloc(i8* %42, i32 524288)
store i8* %43, i8** %2
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %48
45: ; preds = %41, %37, %33, %30, %26, %22, %18, %14, %10, %6, %0
%46 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %41
%49 = load i8*, i8** %2
%50 = call i32 @free(i8* %49)
%51 = load i8*, i8** %3
%52 = call i32 @free(i8* %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%54 = call i32 @exit(i32 0)
unreachable
}

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