#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*/ fatal_error(char *, size_t);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ warning(char *);
void *new (size_t size) {
  void *data;
  if (size == 0) {
    warning("new: requested zero bytes of memory, continuing...\n");
    return NULL;
  }
  data = (void *)malloc(size);
  if (data == NULL)
    fatal_error("new: could not allocate %d byte block\n", size);
  return data;
}


x86 assembly (clang, -O0):
<new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1160 <new+0x30>
lea    0xeb2(%rip),%rdi
call   1030 <warning@plt>
movq   $0x0,-0x8(%rbp)
jmp    1190 <new+0x60>
mov    -0x10(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <new+0x58>
mov    -0x10(%rbp),%rsi
lea    0xeb1(%rip),%rdi
call   1040 <fatal_error@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     115a <new+0x2a>
mov    %rdi,%rbx
call   1050 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1169 <new+0x39>
lea    0xee4(%rip),%rdi
mov    %rbx,%rsi
call   1040 <fatal_error@plt>
jmp    1169 <new+0x39>
lea    0xe9f(%rip),%rdi
call   1030 <warning@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [52 x i8] c"new: requested zero bytes of memory, continuing...\0A\00"
@.str.1 = [39 x i8] c"new: could not allocate %d byte block\0A\00"
define i8* @new(i64 %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @warning(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
br label %20
9: ; preds = %1
%10 = load i64, i64* %3
%11 = call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i64, i64* %3
%17 = call i32 @fatal_error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %16)
br label %18
18: ; preds = %15, %9
%19 = load i8*, i8** %4
store i8* %19, i8** %2
br label %20
20: ; preds = %18, %7
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [52 x i8] c"new: requested zero bytes of memory, continuing...\0A\00"
@.str.1 = [39 x i8] c"new: could not allocate %d byte block\0A\00"
define i8* @new(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @warning(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %11
5: ; preds = %1
%6 = tail call i64 @malloc(i64 %0)
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @fatal_error(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %0)
br label %11
11: ; preds = %5, %9, %3
%12 = phi i8* [ null, %3 ], [ %7, %9 ], [ %7, %5 ]
ret i8* %12
}