#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*/ fatal_util(char *);
void *realloc(void *, size_t);
void *realloc_util(void *ptr, size_t bytes) {
  void *ret = NULL;
  if (ptr == NULL)
    fatal_util("Call to realloc_util with a null pointer");
  else {
    if ((ret = realloc(ptr, bytes)) == NULL)
      fatal_util("realloc_util: out of memory");
  }
  return ret;
}


x86 assembly (clang, -O0):
<realloc_util>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1154 <realloc_util+0x34>
lea    0xeb6(%rip),%rdi
call   1030 <fatal_util@plt>
jmp    1180 <realloc_util+0x60>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    117b <realloc_util+0x5b>
lea    0xeb3(%rip),%rdi
call   1030 <fatal_util@plt>
jmp    1180 <realloc_util+0x60>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<realloc_util>:
push   %rax
test   %rdi,%rdi
je     1132 <realloc_util+0x12>
call   1040 <realloc@plt>
test   %rax,%rax
je     113b <realloc_util+0x1b>
pop    %rcx
ret
lea    0xec7(%rip),%rdi
jmp    1142 <realloc_util+0x22>
lea    0xee7(%rip),%rdi
call   1030 <fatal_util@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Call to realloc_util with a null pointer\00"
@.str.1 = [28 x i8] c"realloc_util: out of memory\00"
define i8* @realloc_util(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
store i8* null, i8** %5
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @fatal_util(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %18
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = load i64, i64* %4
%13 = call i8* @realloc(i8* %11, i64 %12)
store i8* %13, i8** %5
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @fatal_util(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %10
br label %18
18: ; preds = %17, %8
%19 = load i8*, i8** %5
ret i8* %19
}

LLVM IR (-O2):
@.str = [41 x i8] c"Call to realloc_util with a null pointer\00"
@.str.1 = [28 x i8] c"realloc_util: out of memory\00"
define noalias i8* @realloc_util(i8* %0, i64 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i8* @realloc(i8* %0, i64 %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4, %2
%8 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), %4 ]
%9 = tail call i32 @fatal_util(i8* %8)
br label %10
10: ; preds = %7, %4
%11 = phi i8* [ %5, %4 ], [ null, %7 ]
ret i8* %11
}