#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*/ abort();
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char const *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
void *realloc_d(void *, size_t, int, char const *);
int /*<<< orphan*/ stderr;
void *xrealloc_d(void *ptr, size_t n, int line, const char *file) {
  do {
    assert(((line >= 0)) && ("assertion failed in ASSUME"));
  } while (0);
  do {
    assert(((file != NULL)) && ("assertion failed in ASSUME"));
  } while (0);
  if ((!!(n == 0))) {
    fprintf(stderr,
            "Cannot allocate 0 bytes in xrealloc.\n\tLine: %i\n"
            "\tFile: %s\nAborting now.\n",
            line, file);
    abort();
    do {
      assert((0) && ("assertion failed in ASSUME_UNREACHABLE"));
    } while (0);
  }
  ptr = realloc_d(ptr, n, line, file);
  if ((!!(ptr == NULL))) {
    fputs("Out of memory for xrealloc.\nAborting now.\n", stderr);
    abort();
    do {
      assert((0) && ("assertion failed in ASSUME_UNREACHABLE"));
    } while (0);
  }
  return ptr;
}


x86 assembly (clang, -O0):
<xrealloc_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x21(%rbp)
jl     1180 <xrealloc_d+0x30>
mov    $0x1,%al
mov    %al,-0x21(%rbp)
jmp    1180 <xrealloc_d+0x30>
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
jmp    1192 <xrealloc_d+0x42>
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x22(%rbp)
je     11ac <xrealloc_d+0x5c>
mov    $0x1,%al
mov    %al,-0x22(%rbp)
jmp    11ac <xrealloc_d+0x5c>
mov    -0x22(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11e7 <xrealloc_d+0x97>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe40(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1070 <realloc_d@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1226 <xrealloc_d+0xd6>
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
lea    0xe49(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrealloc_d>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %edx,%edi
not    %edi
shr    $0x1f,%edi
call   1050 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
test   %rbx,%rbx
je     11a1 <xrealloc_d+0x51>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1070 <realloc_d@plt>
test   %rax,%rax
je     11c2 <xrealloc_d+0x72>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
lea    0xe76(%rip),%rdi
call   1040 <fputs@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"assertion failed in ASSUME\00"
@stderr = global i32 0
@.str.1 = [72 x i8] c"Cannot allocate 0 bytes in xrealloc.\0A\09Line: %i\0A\09File: %s\0AAborting now.\0A\00"
@.str.2 = [43 x i8] c"Out of memory for xrealloc.\0AAborting now.\0A\00"
define i8* @xrealloc_d(i8* %0, i64 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
br label %9
9: ; preds = %4
%10 = load i32, i32* %7
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
br label %13
13: ; preds = %12, %9
%14 = phi i1 [ false, %9 ], [ true, %12 ]
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
br label %17
17: ; preds = %13
br label %18
18: ; preds = %17
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18
br label %22
22: ; preds = %21, %18
%23 = phi i1 [ false, %18 ], [ true, %21 ]
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
br label %26
26: ; preds = %22
%27 = load i64, i64* %6
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = load i32, i32* %7
%32 = load i8*, i8** %8
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i32 %31, i8* %32)
%34 = call i32 (...) @abort()
unreachable
35: ; preds = %26
%36 = load i8*, i8** %5
%37 = load i64, i64* %6
%38 = load i32, i32* %7
%39 = load i8*, i8** %8
%40 = call i8* @realloc_d(i8* %36, i64 %37, i32 %38, i8* %39)
store i8* %40, i8** %5
%41 = load i8*, i8** %5
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %47
43: ; preds = %35
%44 = load i32, i32* @stderr
%45 = call i32 @fputs(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = call i32 (...) @abort()
unreachable
47: ; preds = %35
%48 = load i8*, i8** %5
ret i8* %48
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [72 x i8] c"Cannot allocate 0 bytes in xrealloc.\0A\09Line: %i\0A\09File: %s\0AAborting now.\0A\00"
@.str.2 = [43 x i8] c"Out of memory for xrealloc.\0AAborting now.\0A\00"
define i8* @xrealloc_d(i8* %0, i64 %1, i32 %2, i8* %3) {
%5 = xor i32 %2, -1
%6 = lshr i32 %5, 31
%7 = tail call i32 @assert(i32 %6)
%8 = icmp ne i8* %3, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = icmp eq i64 %1, 0
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* %3)
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %4
%17 = tail call i8* @realloc_d(i8* %0, i64 %1, i32 %2, i8* %3)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 @fputs(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = tail call i32 (...) @abort()
unreachable
23: ; preds = %16
ret i8* %17
}