#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 */
scalar_t__ ENOMEM;
void *calloc(size_t, size_t);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t);
int /*<<< orphan*/ stderr;
void *reprompi_calloc(size_t count, size_t elem_size) {
  void *buf = NULL;
  errno = 0;
  buf = calloc(count, elem_size);
  if (errno == ENOMEM) {
    fprintf(stderr, "Cannot allocate memory with size %zu Bytes\n",
            count * elem_size);
    exit(1);
  }
  return buf;
}


x86 assembly (clang, -O0):
<reprompi_calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e81(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%rax
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%rax
jne    11a9 <reprompi_calloc+0x79>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
imul   -0x10(%rbp),%rdx
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reprompi_calloc>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e8f(%rip),%rax
movq   $0x0,(%rax)
call   1030 <calloc@plt>
mov    0x2e8c(%rip),%rcx
cmpq   $0x0,(%rcx)
je     1162 <reprompi_calloc+0x32>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
imul   %rbx,%r14
lea    0xe8a(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i64 0
@ENOMEM = global i64 0
@stderr = global i32 0
@.str = [44 x i8] c"Cannot allocate memory with size %zu Bytes\0A\00"
define i8* @reprompi_calloc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %3
store i64 %1, i64* %4
store i8* null, i8** %5
store i64 0, i64* @errno
%6 = load i64, i64* %3
%7 = load i64, i64* %4
%8 = call i8* @calloc(i64 %6, i64 %7)
store i8* %8, i8** %5
%9 = load i64, i64* @errno
%10 = load i64, i64* @ENOMEM
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i64, i64* %3
%15 = load i64, i64* %4
%16 = mul i64 %14, %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8*, i8** %5
ret i8* %20
}

LLVM IR (-O2):
@errno = global i64 0
@ENOMEM = global i64 0
@stderr = global i32 0
@.str = [44 x i8] c"Cannot allocate memory with size %zu Bytes\0A\00"
define noalias i8* @reprompi_calloc(i64 %0, i64 %1) {
store i64 0, i64* @errno
%3 = tail call i8* @calloc(i64 %0, i64 %1)
%4 = load i64, i64* @ENOMEM
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = mul i64 %1, %0
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
ret i8* %3
}