#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*/ allocExitError(char *, size_t, size_t, char const *);
void *realloc(void *, size_t);
void *reallocOrExit4(void *ptr, size_t count, size_t size, const char *name) {
  void *p = realloc(ptr, count * size);
  if (p == 0 && count > 0)
    allocExitError("realloc", count, size, name);
  return p;
}


x86 assembly (clang, -O0):
<reallocOrExit4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
imul   -0x18(%rbp),%rsi
call   1040 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117c <reallocOrExit4+0x5c>
cmpq   $0x0,-0x10(%rbp)
jbe    117c <reallocOrExit4+0x5c>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe89(%rip),%rdi
call   1030 <allocExitError@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reallocOrExit4>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdx,%rsi
imul   %rbx,%rsi
call   1040 <realloc@plt>
mov    %rax,%r12
test   %rbx,%rbx
je     115f <reallocOrExit4+0x3f>
test   %r12,%r12
jne    115f <reallocOrExit4+0x3f>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <allocExitError@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"realloc\00"
define i8* @reallocOrExit4(i8* %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = load i64, i64* %7
%13 = mul i64 %11, %12
%14 = call i8* @realloc(i8* %10, i64 %13)
store i8* %14, i8** %9
%15 = load i8*, i8** %9
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %25
17: ; preds = %4
%18 = load i64, i64* %6
%19 = icmp ugt i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i64, i64* %6
%22 = load i64, i64* %7
%23 = load i8*, i8** %8
%24 = call i32 @allocExitError(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %21, i64 %22, i8* %23)
br label %25
25: ; preds = %20, %17, %4
%26 = load i8*, i8** %9
ret i8* %26
}

LLVM IR (-O2):
@.str = [8 x i8] c"realloc\00"
define noalias i8* @reallocOrExit4(i8* nocapture %0, i64 %1, i64 %2, i8* %3) {
%5 = mul i64 %2, %1
%6 = tail call i8* @realloc(i8* %0, i64 %5)
%7 = icmp eq i8* %6, null
%8 = icmp ne i64 %1, 0
%9 = and i1 %8, %7
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 @allocExitError(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %1, i64 %2, i8* %3)
br label %12
12: ; preds = %10, %4
ret i8* %6
}