#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, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned long,
                           unsigned long);
int /*<<< orphan*/ stderr;
void *__caryll_allocate_clean(size_t n, unsigned long line) {
  if (!n)
    return NULL;
  void *p = calloc(n, 1);
  if (!p) {
    fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n);
    exit(EXIT_FAILURE);
  }
  return p;
}


x86 assembly (clang, -O0):
<__caryll_allocate_clean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1158 <__caryll_allocate_clean+0x28>
movq   $0x0,-0x8(%rbp)
jmp    11a8 <__caryll_allocate_clean+0x78>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a0 <__caryll_allocate_clean+0x70>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe73(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__caryll_allocate_clean>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1177 <__caryll_allocate_clean+0x47>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%esi
call   1030 <calloc@plt>
test   %rax,%rax
jne    1179 <__caryll_allocate_clean+0x49>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"[%ld]Out of memory(%ld bytes)\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @__caryll_allocate_clean(i64 %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
store i64 %0, i64* %4
store i64 %1, i64* %5
%7 = load i64, i64* %4
%8 = icmp ne i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %2
store i8* null, i8** %3
br label %24
10: ; preds = %2
%11 = load i64, i64* %4
%12 = call i8* @calloc(i64 %11, i32 1)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %22, label %15
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i64, i64* %5
%18 = load i64, i64* %4
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %17, i64 %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %10
%23 = load i8*, i8** %6
store i8* %23, i8** %3
br label %24
24: ; preds = %22, %9
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"[%ld]Out of memory(%ld bytes)\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @__caryll_allocate_clean(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = tail call i8* @calloc(i64 %0, i32 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 ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %1, i64 %0)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %4, %2
%13 = phi i8* [ null, %2 ], [ %5, %4 ]
ret i8* %13
}