#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(int, int);
int /*<<< orphan*/ zfatal(char *, int, int);
void *zmalloc_calloc(int nmemb, int size) {
  void *r;
  if (nmemb < 0) {
    nmemb = 0;
  }
  if (size < 0) {
    size = 0;
  }
  if ((r = calloc(nmemb, size)) == 0) {
    zfatal("FATAL zcalloc: insufficient memory for %dx%d bytes: %m", nmemb,
           size);
  }
  return r;
}


x86 assembly (clang, -O0):
<zmalloc_calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    113f <zmalloc_calloc+0x1f>
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1150 <zmalloc_calloc+0x30>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117b <zmalloc_calloc+0x5b>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe8a(%rip),%rdi
call   1030 <zfatal@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zmalloc_calloc>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %ebp,%ebp
test   %edi,%edi
cmovs  %ebp,%ebx
test   %esi,%esi
cmovns %esi,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1153 <zmalloc_calloc+0x33>
lea    0xeb6(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <zfatal@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"FATAL zcalloc: insufficient memory for %dx%d bytes: %m\00"
define i8* @zmalloc_calloc(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 0, i32* %3
br label %9
9: ; preds = %8, %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 0, i32* %4
br label %13
13: ; preds = %12, %9
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i8* @calloc(i32 %14, i32 %15)
store i8* %16, i8** %5
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i32 @zfatal(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20)
br label %22
22: ; preds = %18, %13
%23 = load i8*, i8** %5
ret i8* %23
}

LLVM IR (-O2):
@.str = [55 x i8] c"FATAL zcalloc: insufficient memory for %dx%d bytes: %m\00"
define noalias i8* @zmalloc_calloc(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 0
%4 = select i1 %3, i32 %0, i32 0
%5 = icmp sgt i32 %1, 0
%6 = select i1 %5, i32 %1, i32 0
%7 = tail call i8* @calloc(i32 %4, i32 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @zfatal(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
br label %11
11: ; preds = %9, %2
ret i8* %7
}