#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ malloc(int);
scalar_t__ realloc(void *, int);
int /*<<< orphan*/ stderr;
void *recalloc_error(void *array, int elt_count, size_t elt_size,
                     const char *variable, const char *function) {
  if (array == (void *)NULL)
    array = (void *)malloc(elt_count * elt_size);
  else
    array = (void *)realloc(array, elt_count * elt_size);
  if (array == (void *)NULL) {
    fprintf(stderr, "Cannot recalloc space for \"%s\" in the ", variable);
    fprintf(stderr, "\"%s\" function.\n", function);
    exit(1);
  } else
    return (array);
}


x86 assembly (clang, -O0):
<recalloc_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117f <recalloc_error+0x3f>
movslq -0xc(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x8(%rbp)
jmp    1197 <recalloc_error+0x57>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11de <recalloc_error+0x9e>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe4a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe58(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recalloc_error>:
push   %r15
push   %r14
push   %rbx
mov    %r8,%r14
mov    %rcx,%rbx
imul   %esi,%edx
test   %rdi,%rdi
je     1165 <recalloc_error+0x25>
mov    %edx,%esi
call   1050 <realloc@plt>
test   %rax,%rax
je     1171 <recalloc_error+0x31>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %edx,%edi
call   1040 <malloc@plt>
test   %rax,%rax
jne    115f <recalloc_error+0x1f>
mov    0x2e68(%rip),%r15
mov    (%r15),%edi
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xe93(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Cannot recalloc space for \22%s\22 in the \00"
@.str.1 = [16 x i8] c"\22%s\22 function.\0A\00"
define i8* @recalloc_error(i8* %0, i32 %1, i64 %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%11 = load i8*, i8** %6
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %21
13: ; preds = %5
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = load i64, i64* %8
%17 = mul i64 %15, %16
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %6
br label %30
21: ; preds = %5
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = load i64, i64* %8
%26 = mul i64 %24, %25
%27 = trunc i64 %26 to i32
%28 = call i64 @realloc(i8* %22, i32 %27)
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %6
br label %30
30: ; preds = %21, %13
%31 = load i8*, i8** %6
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %41
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %9
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %10
%39 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %30
%42 = load i8*, i8** %6
ret i8* %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Cannot recalloc space for \22%s\22 in the \00"
@.str.1 = [16 x i8] c"\22%s\22 function.\0A\00"
define i8* @recalloc_error(i8* %0, i32 %1, i64 %2, i8* %3, i8* %4) {
%6 = icmp eq i8* %0, null
%7 = trunc i64 %2 to i32
%8 = mul i32 %7, %1
br i1 %6, label %9, label %11
9: ; preds = %5
%10 = tail call i64 @malloc(i32 %8)
br label %13
11: ; preds = %5
%12 = tail call i64 @realloc(i8* %0, i32 %8)
br label %13
13: ; preds = %11, %9
%14 = phi i64 [ %10, %9 ], [ %12, %11 ]
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %3)
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %13
%23 = inttoptr i64 %14 to i8*
ret i8* %23
}