#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned long);
scalar_t__ malloc(unsigned long);
int /*<<< orphan*/ stderr;
void *HTsmalloc(unsigned long size) {
  void *retval;
  if (size == 0)
    return NULL;
  retval = (void *)malloc(size);
  if (!retval) {
    fprintf(stderr, "HTsmalloc: Unable to allocate %lu bytes of memory\n",
            size);
    exit(1);
  }
  return retval;
}


x86 assembly (clang, -O0):
<HTsmalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <HTsmalloc+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1197 <HTsmalloc+0x67>
mov    -0x10(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118f <HTsmalloc+0x5f>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe80(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HTsmalloc>:
push   %rbx
test   %rdi,%rdi
je     1145 <HTsmalloc+0x15>
mov    %rdi,%rbx
call   1040 <malloc@plt>
test   %rax,%rax
je     1149 <HTsmalloc+0x19>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"HTsmalloc: Unable to allocate %lu bytes of memory\0A\00"
define i8* @HTsmalloc(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 %8
7: ; preds = %1
store i8* null, i8** %2
br label %21
8: ; preds = %1
%9 = load i64, i64* %3
%10 = call i64 @malloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %19, label %14
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i64, i64* %3
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %8
%20 = load i8*, i8** %4
store i8* %20, i8** %2
br label %21
21: ; preds = %19, %7
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"HTsmalloc: Unable to allocate %lu bytes of memory\0A\00"
define i8* @HTsmalloc(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = tail call i64 @malloc(i64 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i64 %0)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = inttoptr i64 %4 to i8*
br label %12
12: ; preds = %1, %10
%13 = phi i8* [ %11, %10 ], [ null, %1 ]
ret i8* %13
}