#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*/ fprintf(int /*<<< orphan*/, char *, int, char const *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
void *malloc_d(size_t, int, char const *);
int /*<<< orphan*/ stderr;
void *xmalloc_d(size_t n, int line, const char *file) {
  void *ptr;
  do {
    assert(((line >= 0)) && ("assertion failed in ASSUME"));
  } while (0);
  do {
    assert(((file != NULL)) && ("assertion failed in ASSUME"));
  } while (0);
  if ((!!(n == 0))) {
    fprintf(stderr,
            "Cannot allocate 0 bytes in xmalloc.\n\tLine: %i\n"
            "\tFile: %s\nAborting now.\n",
            line, file);
    abort();
    do {
      assert((0) && ("assertion failed in ASSUME_UNREACHABLE"));
    } while (0);
  }
  ptr = malloc_d(n, line, file);
  if ((!!(ptr == NULL))) {
    fputs("Out of memory for xmalloc.\nAborting now.\n", stderr);
    abort();
    do {
      assert((0) && ("assertion failed in ASSUME_UNREACHABLE"));
    } while (0);
  }
  return ptr;
}


x86 assembly (clang, -O0):
<xmalloc_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x21(%rbp)
jl     117c <xmalloc_d+0x2c>
mov    $0x1,%al
mov    %al,-0x21(%rbp)
jmp    117c <xmalloc_d+0x2c>
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
jmp    118e <xmalloc_d+0x3e>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x22(%rbp)
je     11a8 <xmalloc_d+0x58>
mov    $0x1,%al
mov    %al,-0x22(%rbp)
jmp    11a8 <xmalloc_d+0x58>
mov    -0x22(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
jne    11e3 <xmalloc_d+0x93>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xe44(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1050 <malloc_d@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    121e <xmalloc_d+0xce>
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
lea    0xe50(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmalloc_d>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
not    %edi
shr    $0x1f,%edi
call   1060 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1060 <assert@plt>
test   %rbx,%rbx
je     1192 <xmalloc_d+0x42>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1050 <malloc_d@plt>
test   %rax,%rax
je     11b3 <xmalloc_d+0x63>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1070 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
lea    0xe84(%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"
@stderr = global i32 0
@.str.1 = [71 x i8] c"Cannot allocate 0 bytes in xmalloc.\0A\09Line: %i\0A\09File: %s\0AAborting now.\0A\00"
@.str.2 = [42 x i8] c"Out of memory for xmalloc.\0AAborting now.\0A\00"
define i8* @xmalloc_d(i64 %0, i32 %1, i8* %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i64 %0, i64* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
br label %8
8: ; preds = %3
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %12
12: ; preds = %11, %8
%13 = phi i1 [ false, %8 ], [ true, %11 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
br label %16
16: ; preds = %12
br label %17
17: ; preds = %16
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %17
br label %21
21: ; preds = %20, %17
%22 = phi i1 [ false, %17 ], [ true, %20 ]
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
br label %25
25: ; preds = %21
%26 = load i64, i64* %4
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = load i32, i32* %5
%31 = load i8*, i8** %6
%32 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* %31)
%33 = call i32 (...) @abort()
unreachable
34: ; preds = %25
%35 = load i64, i64* %4
%36 = load i32, i32* %5
%37 = load i8*, i8** %6
%38 = call i8* @malloc_d(i64 %35, i32 %36, i8* %37)
store i8* %38, i8** %7
%39 = load i8*, i8** %7
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %45
41: ; preds = %34
%42 = load i32, i32* @stderr
%43 = call i32 @fputs(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = call i32 (...) @abort()
unreachable
45: ; preds = %34
%46 = load i8*, i8** %7
ret i8* %46
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [71 x i8] c"Cannot allocate 0 bytes in xmalloc.\0A\09Line: %i\0A\09File: %s\0AAborting now.\0A\00"
@.str.2 = [42 x i8] c"Out of memory for xmalloc.\0AAborting now.\0A\00"
define i8* @xmalloc_d(i64 %0, i32 %1, i8* %2) {
%4 = xor i32 %1, -1
%5 = lshr i32 %4, 31
%6 = tail call i32 @assert(i32 %5)
%7 = icmp ne i8* %2, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp eq i64 %0, 0
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %2)
%14 = tail call i32 (...) @abort()
unreachable
15: ; preds = %3
%16 = tail call i8* @malloc_d(i64 %0, i32 %1, i8* %2)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fputs(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = tail call i32 (...) @abort()
unreachable
22: ; preds = %15
ret i8* %16
}