#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*/ assert(int);
void *calloc(long long, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int,
                           long long);
int /*<<< orphan*/ stderr;
void *c_memory_alloc_zero(long long nbytes, const char *file, int line) {
  void *result;
  assert(nbytes > 0);
  result = calloc(nbytes, 1);
  if (NULL == result) {
    fprintf(stderr, "%s:%d ERROR Failed to allocate nbytes=%llu.\n", file, line,
            nbytes);
  }
  return result;
}


x86 assembly (clang, -O0):
<c_memory_alloc_zero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1193 <c_memory_alloc_zero+0x63>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%r8
lea    0xe72(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_memory_alloc_zero>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setg   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1181 <c_memory_alloc_zero+0x51>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
mov    %rbx,%r8
call   1050 <fprintf@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [45 x i8] c"%s:%d ERROR Failed to allocate nbytes=%llu.\0A\00"
define i8* @c_memory_alloc_zero(i64 %0, i8* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i64 %0, i64* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i64, i64* %4
%9 = icmp sgt i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i64, i64* %4
%13 = call i8* @calloc(i64 %12, i32 1)
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = icmp eq i8* null, %14
br i1 %15, label %16, label %22
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = load i64, i64* %4
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19, i64 %20)
br label %22
22: ; preds = %16, %3
%23 = load i8*, i8** %7
ret i8* %23
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [45 x i8] c"%s:%d ERROR Failed to allocate nbytes=%llu.\0A\00"
define i8* @c_memory_alloc_zero(i64 %0, i8* %1, i32 %2) {
%4 = icmp sgt i64 %0, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i8* @calloc(i64 %0, i32 1)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2, i64 %0)
br label %12
12: ; preds = %9, %3
ret i8* %7
}