#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*/ Mzero(void *, size_t);
int /*<<< orphan*/ Sys_failure(char *);
int /*<<< orphan*/ assert(int);
void *calloc(size_t, size_t);
void *Calloc(size_t nmemb, size_t size) {
  void *retval;
  assert(nmemb > 0);
  assert(size > 0);
  retval = calloc(nmemb, size);
  if (retval == NULL)
    Sys_failure("calloc");
  Mzero(retval, nmemb * size);
  return retval;
}


x86 assembly (clang, -O0):
<Calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119c <Calloc+0x5c>
lea    0xe69(%rip),%rdi
call   1050 <Sys_failure@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
imul   -0x10(%rbp),%rsi
call   1060 <Mzero@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Calloc>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <calloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1186 <Calloc+0x46>
lea    0xe7f(%rip),%rdi
call   1050 <Sys_failure@plt>
imul   %r14,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <Mzero@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"calloc\00"
define i8* @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 = icmp ugt i64 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i64, i64* %4
%11 = icmp ugt i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i64, i64* %3
%15 = load i64, i64* %4
%16 = call i8* @calloc(i64 %14, i64 %15)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @Sys_failure(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %2
%22 = load i8*, i8** %5
%23 = load i64, i64* %3
%24 = load i64, i64* %4
%25 = mul i64 %23, %24
%26 = call i32 @Mzero(i8* %22, i64 %25)
%27 = load i8*, i8** %5
ret i8* %27
}

LLVM IR (-O2):
@.str = [7 x i8] c"calloc\00"
define i8* @Calloc(i64 %0, i64 %1) {
%3 = icmp ne i64 %0, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i64 %1, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i8* @calloc(i64 %0, i64 %1)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @Sys_failure(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = mul i64 %1, %0
%15 = tail call i32 @Mzero(i8* %9, i64 %14)
ret i8* %9
}