#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*/ SIGSEGV;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ kill(int /*<<< orphan*/, int /*<<< orphan*/);
void *realloc(void *, unsigned int);
int /*<<< orphan*/ stderr;
void *Tcl_Realloc(void *ptr, unsigned int size) {
  void *result;
  result = realloc(ptr, size);
  if (result == NULL) {
    fprintf(stderr, "unable to realloc %d bytes", size);
    kill(getpid(), SIGSEGV);
  }
  return result;
}


x86 assembly (clang, -O0):
<Tcl_Realloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1199 <Tcl_Realloc+0x59>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe83(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
call   1050 <kill@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Tcl_Realloc>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1060 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <Tcl_Realloc+0x40>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
mov    %ebp,%edx
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    0x2e71(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1050 <kill@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"unable to realloc %d bytes\00"
@SIGSEGV = global i32 0
define i8* @Tcl_Realloc(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = call i8* @realloc(i8* %6, i32 %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i32, i32* %4
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 (...) @getpid()
%16 = load i32, i32* @SIGSEGV
%17 = call i32 @kill(i32 %15, i32 %16)
br label %18
18: ; preds = %11, %2
%19 = load i8*, i8** %5
ret i8* %19
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"unable to realloc %d bytes\00"
@SIGSEGV = global i32 0
define i8* @Tcl_Realloc(i8* %0, i32 %1) {
%3 = tail call i8* @realloc(i8* %0, i32 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %1)
%8 = tail call i32 (...) @getpid()
%9 = load i32, i32* @SIGSEGV
%10 = tail call i32 @kill(i32 %8, i32 %9)
br label %11
11: ; preds = %5, %2
ret i8* %3
}