#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_FAILURE;
void *calloc(size_t, size_t);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
void *util_Calloc(size_t count, size_t esize) {
  void *p;
  errno = 0;
  p = calloc(count, esize);
  if (p == NULL) {
    fprintf(stderr, "\ncalloc failed: %s\n\n", strerror(errno));
    exit(EXIT_FAILURE);
    return NULL;
  } else
    return p;
}


x86 assembly (clang, -O0):
<util_Calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e81(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <util_Calloc+0x75>
mov    0x2e5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe5e(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_Calloc>:
push   %rbx
mov    0x2e90(%rip),%rax
movq   $0x0,(%rax)
call   1030 <calloc@plt>
test   %rax,%rax
je     115b <util_Calloc+0x1b>
pop    %rbx
ret
mov    0x2e7e(%rip),%rax
mov    (%rax),%ebx
xor    %edi,%edi
call   1060 <strerror@plt>
lea    0xe8e(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@stderr = global i32 0
@.str = [21 x i8] c"\0Acalloc failed: %s\0A\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @util_Calloc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %3
store i64 %1, i64* %4
store i64 0, i64* @errno
%6 = load i64, i64* %3
%7 = load i64, i64* %4
%8 = call i8* @calloc(i64 %6, i64 %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 i64, i64* @errno
%14 = call i8* @strerror(i64 %13)
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i8*, i8** %5
ret i8* %19
}

LLVM IR (-O2):
@errno = global i64 0
@stderr = global i32 0
@.str = [21 x i8] c"\0Acalloc failed: %s\0A\0A\00"
@EXIT_FAILURE = global i32 0
define noalias i8* @util_Calloc(i64 %0, i64 %1) {
store i64 0, i64* @errno
%3 = tail call i8* @calloc(i64 %0, i64 %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 i8* @strerror(i64 0)
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
ret i8* %3
}