#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 *__real_calloc(size_t, size_t);
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void *__wrap_calloc(size_t nmemb, size_t size) {
  void *ret = __real_calloc(nmemb, size);
  if (size && nmemb && !ret) {
    fputs("Out of memory!\n", stderr);
    abort();
  }
  return ret;
}


x86 assembly (clang, -O0):
<__wrap_calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <__real_calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118e <__wrap_calloc+0x5e>
cmpq   $0x0,-0x8(%rbp)
je     118e <__wrap_calloc+0x5e>
cmpq   $0x0,-0x18(%rbp)
jne    118e <__wrap_calloc+0x5e>
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
lea    0xe7e(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__wrap_calloc>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <__real_calloc@plt>
test   %rbx,%rbx
je     114e <__wrap_calloc+0x1e>
test   %r14,%r14
je     114e <__wrap_calloc+0x1e>
test   %rax,%rax
je     1156 <__wrap_calloc+0x26>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1050 <fputs@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"Out of memory!\0A\00"
@stderr = global i32 0
define i8* @__wrap_calloc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %3
%7 = load i64, i64* %4
%8 = call i8* @__real_calloc(i64 %6, i64 %7)
store i8* %8, i8** %5
%9 = load i64, i64* %4
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = load i64, i64* %3
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %14, %11, %2
%22 = load i8*, i8** %5
ret i8* %22
}

LLVM IR (-O2):
@.str = [16 x i8] c"Out of memory!\0A\00"
@stderr = global i32 0
define i8* @__wrap_calloc(i64 %0, i64 %1) {
%3 = tail call i8* @__real_calloc(i64 %0, i64 %1)
%4 = icmp eq i64 %1, 0
%5 = icmp eq i64 %0, 0
%6 = or i1 %5, %4
%7 = icmp ne i8* %3, null
%8 = select i1 %6, i1 true, i1 %7
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = tail call i32 (...) @abort()
unreachable
13: ; preds = %2
ret i8* %3
}