#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);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int /*<<< orphan*/, int /*<<< orphan*/, char *);
void *xcalloc(size_t n, size_t s) {
  void *p;
  if (n == 0 || s == 0)
    return NULL;
  p = calloc(n, s);
  if (p == NULL)
    error(EXIT_FAILURE, errno, "calloc");
  return p;
}


x86 assembly (clang, -O0):
<xcalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <xcalloc+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1153 <xcalloc+0x33>
movq   $0x0,-0x8(%rbp)
jmp    1195 <xcalloc+0x75>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118d <xcalloc+0x6d>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
lea    0xe78(%rip),%rdx
call   1040 <error@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xcalloc>:
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     1137 <xcalloc+0x17>
test   %rsi,%rsi
je     1137 <xcalloc+0x17>
call   1030 <calloc@plt>
test   %rax,%rax
je     1139 <xcalloc+0x19>
pop    %rcx
ret
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
mov    0x2e97(%rip),%rax
mov    (%rax),%esi
lea    0xeae(%rip),%rdx
call   1040 <error@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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