#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int,
                           size_t, size_t);
int /*<<< orphan*/ stderr;
void *calloc_or_quit(size_t num, size_t size, const char *src_file,
                     int src_line) {
  void *mem;
  if ((mem = calloc(num, size)) == NULL) {
    fprintf(stderr, "file: '%s' at line: %d failed to calloc [%zu x %zu] bytes",
            src_file, src_line, num, size);
    exit(EXIT_FAILURE);
  } else {
    return mem;
  }
}


x86 assembly (clang, -O0):
<calloc_or_quit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1194 <calloc_or_quit+0x64>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%r8
mov    -0x10(%rbp),%r9
lea    0xe7f(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calloc_or_quit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <calloc@plt>
test   %rax,%rax
je     1158 <calloc_or_quit+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
mov    %rbp,%r8
mov    %rbx,%r9
call   1040 <fprintf@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [58 x i8] c"file: '%s' at line: %d failed to calloc [%zu x %zu] bytes\00"
@EXIT_FAILURE = global i32 0
define i8* @calloc_or_quit(i64 %0, i64 %1, i8* %2, i32 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i64 %0, i64* %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i64, i64* %5
%11 = load i64, i64* %6
%12 = call i8* @calloc(i64 %10, i64 %11)
store i8* %12, i8** %9
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %23
14: ; preds = %4
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %7
%17 = load i32, i32* %8
%18 = load i64, i64* %5
%19 = load i64, i64* %6
%20 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %16, i32 %17, i64 %18, i64 %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %4
%24 = load i8*, i8** %9
ret i8* %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [58 x i8] c"file: '%s' at line: %d failed to calloc [%zu x %zu] bytes\00"
@EXIT_FAILURE = global i32 0
define noalias i8* @calloc_or_quit(i64 %0, i64 %1, i8* %2, i32 %3) {
%5 = tail call i8* @calloc(i64 %0, i64 %1)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %3, i64 %0, i64 %1)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %4
ret i8* %5
}