#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*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
void *CCutil_allocrus(size_t size) {
  void *mem = (void *)NULL;
  if (size == 0) {
    fprintf(stderr, "Warning: 0 bytes allocated\n");
  }
  mem = (void *)malloc(size);
  if (mem == (void *)NULL) {
    fprintf(stderr, "Out of memory. Asked for %d bytes\n", (int)size);
  }
  return mem;
}


x86 assembly (clang, -O0):
<CCutil_allocrus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1156 <CCutil_allocrus+0x36>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118b <CCutil_allocrus+0x6b>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    %eax,%edx
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CCutil_allocrus>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdi,%rdi
jne    1143 <CCutil_allocrus+0x23>
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
lea    0xec4(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116d <CCutil_allocrus+0x4d>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Warning: 0 bytes allocated\0A\00"
@.str.1 = [35 x i8] c"Out of memory. Asked for %d bytes\0A\00"
define i8* @CCutil_allocrus(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
store i8* null, i8** %3
%4 = load i64, i64* %2
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %6, %1
%10 = load i64, i64* %2
%11 = call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = load i32, i32* @stderr
%17 = load i64, i64* %2
%18 = trunc i64 %17 to i32
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %15, %9
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Warning: 0 bytes allocated\0A\00"
@.str.1 = [35 x i8] c"Out of memory. Asked for %d bytes\0A\00"
define i8* @CCutil_allocrus(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %3, %1
%7 = tail call i64 @malloc(i64 %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = trunc i64 %0 to i32
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %9, %6
%14 = inttoptr i64 %7 to i8*
ret i8* %14
}