#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_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned long, char *,
                           int const);
void *realloc(void *, size_t const);
int /*<<< orphan*/ stderr;
void *Ptngc_warnrealloc_x(void *old, const size_t size, char *file,
                          const int line) {
  void *mem = realloc(old, size);
  if (!mem) {
    fprintf(stderr,
            "TRAJNG ERROR: Could not allocate memory of size %lu at %s:%d\n",
            (unsigned long)size, file, line);
    exit(EXIT_FAILURE);
  }
  return mem;
}


x86 assembly (clang, -O0):
<Ptngc_warnrealloc_x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1192 <Ptngc_warnrealloc_x+0x62>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
lea    0xe81(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ptngc_warnrealloc_x>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%rbp
call   1040 <realloc@plt>
test   %rax,%rax
je     114c <Ptngc_warnrealloc_x+0x1c>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r14d,%r8d
call   1030 <fprintf@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [62 x i8] c"TRAJNG ERROR: Could not allocate memory of size %lu at %s:%d\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @Ptngc_warnrealloc_x(i8* %0, i64 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = call i8* @realloc(i8* %10, i64 %11)
store i8* %12, i8** %9
%13 = load i8*, i8** %9
%14 = icmp ne i8* %13, null
br i1 %14, label %23, label %15
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = load i64, i64* %6
%18 = load i8*, i8** %7
%19 = load i32, i32* %8
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i64 %17, i8* %18, i32 %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %4
%24 = load i8*, i8** %9
ret i8* %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [62 x i8] c"TRAJNG ERROR: Could not allocate memory of size %lu at %s:%d\0A\00"
@EXIT_FAILURE = global i32 0
define noalias i8* @Ptngc_warnrealloc_x(i8* nocapture %0, i64 %1, i8* %2, i32 %3) {
%5 = tail call i8* @realloc(i8* %0, i64 %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i64 %1, i8* %2, i32 %3)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %4
ret i8* %5
}