#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 */
struct world_allocator {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ assert(struct world_allocator *);
int /*<<< orphan*/ perror(char *);
void *realloc(void *, size_t);
void *world_allocator_realloc(struct world_allocator *restrict a,
                              void *restrict ptr, size_t size) {
  assert(a);
  void *p = realloc(ptr, size);
  if (p == NULL) {
    perror("realloc");
    abort();
  }
  return p;
}


x86 assembly (clang, -O0):
<world_allocator_realloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118c <world_allocator_realloc+0x4c>
lea    0xe80(%rip),%rdi
call   1060 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<world_allocator_realloc>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <realloc@plt>
test   %rax,%rax
je     1167 <world_allocator_realloc+0x27>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe92(%rip),%rdi
call   1060 <perror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.world_allocator = type { i32 }
@.str = [8 x i8] c"realloc\00"
define i8* @world_allocator_realloc(%struct.world_allocator* noalias %0, i8* noalias %1, i64 %2) {
%4 = alloca %struct.world_allocator*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store %struct.world_allocator* %0, %struct.world_allocator** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load %struct.world_allocator*, %struct.world_allocator** %4
%9 = call i32 @assert(%struct.world_allocator* %8)
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = call i8* @realloc(i8* %10, i64 %11)
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %3
%19 = load i8*, i8** %7
ret i8* %19
}

LLVM IR (-O2):
%struct.world_allocator = type { i32 }
@.str = [8 x i8] c"realloc\00"
define noalias i8* @world_allocator_realloc(%struct.world_allocator* noalias %0, i8* noalias nocapture %1, i64 %2) {
%4 = tail call i32 @assert(%struct.world_allocator* %0)
%5 = tail call i8* @realloc(i8* %1, i64 %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %3
ret i8* %5
}