#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*/ abort();
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
void *malloc(size_t);
int /*<<< orphan*/ stderr;
void *xmalloc(size_t n) {
  void *ptr;
  do {
    assert(((n > 0)) && ("assertion failed in ASSUME"));
  } while (0);
  ptr = malloc(n);
  if ((!!(ptr == NULL))) {
    fputs("Out of memory for xmalloc.\nAborting now.\n", stderr);
    abort();
  }
  return ptr;
}


x86 assembly (clang, -O0):
<xmalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jbe    1166 <xmalloc+0x26>
mov    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1166 <xmalloc+0x26>
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a7 <xmalloc+0x67>
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
lea    0xe80(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmalloc>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     1161 <xmalloc+0x21>
pop    %rbx
ret
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
lea    0xe8f(%rip),%rdi
call   1040 <fputs@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"assertion failed in ASSUME\00"
@.str.1 = [42 x i8] c"Out of memory for xmalloc.\0AAborting now.\0A\00"
@stderr = global i32 0
define i8* @xmalloc(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
br label %4
4: ; preds = %1
%5 = load i64, i64* %2
%6 = icmp ugt i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %4
br label %8
8: ; preds = %7, %4
%9 = phi i1 [ false, %4 ], [ true, %7 ]
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
br label %12
12: ; preds = %8
%13 = load i64, i64* %2
%14 = call i8* @malloc(i64 %13)
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %12
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str.1 = [42 x i8] c"Out of memory for xmalloc.\0AAborting now.\0A\00"
@stderr = 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* @stderr
%9 = tail call i32 @fputs(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %1
ret i8* %5
}