#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*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
void *realloc(void *, size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ update_entry(void *, void *, size_t);
void *safe_realloc_internal(void *ptr, size_t size, char *file, int line) {
  void *ret = realloc(ptr, size);
  if (!ret) {
    {
      fprintf(
          stderr, "Unrecoverable error in %s(%d): %s\n\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/iagox86/nbtool/refs/heads/master/memory.c",
          135, "Out of memory.");
      abort();
    };
  };
  update_entry(ptr, ret, size);
  return ret;
}


x86 assembly (clang, -O0):
<safe_realloc_internal>:
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   1050 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a2 <safe_realloc_internal+0x62>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
lea    0xe9a(%rip),%rdx
mov    $0x87,%ecx
lea    0xf12(%rip),%r8
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <update_entry@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_realloc_internal>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <realloc@plt>
test   %rax,%rax
je     116f <safe_realloc_internal+0x2f>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1060 <update_entry@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
lea    0xe9e(%rip),%rdx
lea    0xf1b(%rip),%r8
mov    $0x87,%ecx
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Unrecoverable error in %s(%d): %s\0A\0A\00"
@.str.1 = [132 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/iagox86/nbtool/refs/heads/master/memory.c\00"
@.str.2 = [15 x i8] c"Out of memory.\00"
define i8* @safe_realloc_internal(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 %19, label %15
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.1, i64 0, i64 0), i32 135, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (...) @abort()
unreachable
19: ; preds = %4
%20 = load i8*, i8** %5
%21 = load i8*, i8** %9
%22 = load i64, i64* %6
%23 = call i32 @update_entry(i8* %20, i8* %21, i64 %22)
%24 = load i8*, i8** %9
ret i8* %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Unrecoverable error in %s(%d): %s\0A\0A\00"
@.str.1 = [132 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/iagox86/nbtool/refs/heads/master/memory.c\00"
@.str.2 = [15 x i8] c"Out of memory.\00"
define i8* @safe_realloc_internal(i8* %0, i64 %1, i8* nocapture readnone %2, i32 %3) {
%5 = tail call i8* @realloc(i8* %0, i64 %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([132 x i8], [132 x i8]* @.str.1, i64 0, i64 0), i32 135, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %4
%12 = tail call i32 @update_entry(i8* %0, i8* %5, i64 %1)
ret i8* %5
}