#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*/ assert(int);
int /*<<< orphan*/ die_(char *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
void *malloc(size_t);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void *xmalloc(size_t size) {
  assert(size > 0);
  void *ptr = malloc(size);
  if (!ptr)
    die_("("
         "util.c"
         ":"
         "40"
         "): "
         "Cannot allocate %zu bytes"
         ": %s\n",
         size, strerror(errno));
  return ptr;
}


x86 assembly (clang, -O0):
<xmalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119e <xmalloc+0x5e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe67(%rip),%rdi
call   1050 <die_@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmalloc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1184 <xmalloc+0x44>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe86(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <die_@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [44 x i8] c"(util.c:40): Cannot allocate %zu bytes: %s\0A\00"
@errno = global i32 0
define i8* @xmalloc(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = icmp ugt i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i64, i64* %2
%9 = call i8* @malloc(i64 %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %1
%13 = load i64, i64* %2
%14 = load i32, i32* @errno
%15 = call i32 @strerror(i32 %14)
%16 = call i32 @die_(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %13, i32 %15)
br label %17
17: ; preds = %12, %1
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@.str = [44 x i8] c"(util.c:40): Cannot allocate %zu bytes: %s\0A\00"
@errno = global i32 0
define noalias i8* @xmalloc(i64 %0) {
%2 = icmp ne i64 %0, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i8* @malloc(i64 %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @errno
%9 = tail call i32 @strerror(i32 %8)
%10 = tail call i32 @die_(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %0, i32 %9)
br label %11
11: ; preds = %7, %1
ret i8* %5
}