#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 */
void *calloc(size_t, size_t);
int /*<<< orphan*/ cdiAbortC(int /*<<< orphan*/ *, char const *, char const *,
                             int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void *cdiXcalloc(size_t nmemb, size_t size, const char *filename,
                 const char *functionname, int line) {
  void *value = calloc(nmemb, size);
  if (size == 0 || value != NULL)
    ;
  else
    cdiAbortC(NULL, (filename), (functionname), (line), "calloc failed: %s",
              strerror(errno));
  return value;
}


x86 assembly (clang, -O0):
<cdiXcalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <calloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1173 <cdiXcalloc+0x43>
cmpq   $0x0,-0x30(%rbp)
je     1178 <cdiXcalloc+0x48>
jmp    11ba <cdiXcalloc+0x8a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    %eax,%r9d
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4b(%rip),%r8
call   1030 <cdiAbortC@plt>
mov    -0x30(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdiXcalloc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
call   1040 <calloc@plt>
mov    %rax,%rbp
test   %rbx,%rbx
je     117e <cdiXcalloc+0x4e>
test   %rbp,%rbp
jne    117e <cdiXcalloc+0x4e>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe95(%rip),%r8
xor    %edi,%edi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
mov    %eax,%r9d
call   1030 <cdiAbortC@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"calloc failed: %s\00"
@errno = global i32 0
define noalias i8* @cdiXcalloc(i64 %0, i64 %1, i8* %2, i8* %3, i32 %4) {
%6 = tail call i8* @calloc(i64 %0, i64 %1)
%7 = icmp eq i64 %1, 0
%8 = icmp ne i8* %6, null
%9 = or i1 %7, %8
br i1 %9, label %14, label %10
10: ; preds = %5
%11 = load i32, i32* @errno
%12 = tail call i32 @strerror(i32 %11)
%13 = tail call i32 @cdiAbortC(i32* null, i8* %2, i8* %3, i32 %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %5, %10
ret i8* %6
}