#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*/ Error(int, char *, char *);
void *Pmalloc(size_t);
scalar_t__ realloc(void *, size_t);
void *Prealloc(void *Present, size_t Bytes) {
  void *p = 0;
  if (!Bytes)
    return 0;
  if (!Present)
    return Pmalloc(Bytes);
  if ((p = (void *)realloc(Present, Bytes))) {
    return p;
  }
  Error(8, "", "");
  return 0;
}


x86 assembly (clang, -O0):
<Prealloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1160 <Prealloc+0x30>
movq   $0x0,-0x8(%rbp)
jmp    11c1 <Prealloc+0x91>
cmpq   $0x0,-0x10(%rbp)
jne    117d <Prealloc+0x4d>
mov    -0x18(%rbp),%rdi
call   1050 <Pmalloc@plt>
mov    %rax,-0x8(%rbp)
jmp    11c1 <Prealloc+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11a5 <Prealloc+0x75>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c1 <Prealloc+0x91>
mov    $0x8,%edi
lea    0xe4f(%rip),%rdx
mov    %rdx,%rsi
call   1030 <Error@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Prealloc>:
push   %rax
test   %rsi,%rsi
je     1164 <Prealloc+0x34>
test   %rdi,%rdi
je     1147 <Prealloc+0x17>
call   1040 <realloc@plt>
test   %rax,%rax
je     1150 <Prealloc+0x20>
pop    %rcx
ret
mov    %rsi,%rdi
pop    %rax
jmp    1050 <Pmalloc@plt>
lea    0xea9(%rip),%rdx
mov    $0x8,%edi
mov    %rdx,%rsi
call   1030 <Error@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @Prealloc(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* null, i8** %6
%7 = load i64, i64* %5
%8 = icmp ne i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %2
store i8* null, i8** %3
br label %26
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i64, i64* %5
%15 = call i8* @Pmalloc(i64 %14)
store i8* %15, i8** %3
br label %26
16: ; preds = %10
%17 = load i8*, i8** %4
%18 = load i64, i64* %5
%19 = call i64 @realloc(i8* %17, i64 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = load i8*, i8** %6
store i8* %23, i8** %3
br label %26
24: ; preds = %16
%25 = call i32 @Error(i32 8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %3
br label %26
26: ; preds = %24, %22, %13, %9
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @Prealloc(i8* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i8* @Pmalloc(i64 %1)
br label %15
8: ; preds = %4
%9 = tail call i64 @realloc(i8* %0, i64 %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = inttoptr i64 %9 to i8*
br label %15
13: ; preds = %8
%14 = tail call i32 @Error(i32 8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %2, %13, %11, %6
%16 = phi i8* [ %12, %11 ], [ null, %13 ], [ %7, %6 ], [ null, %2 ]
ret i8* %16
}