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


x86 assembly (clang, -O0):
<xcalloc_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x29(%rbp)
jl     1180 <xcalloc_d+0x30>
mov    $0x1,%al
mov    %al,-0x29(%rbp)
jmp    1180 <xcalloc_d+0x30>
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
jmp    1192 <xcalloc_d+0x42>
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x2a(%rbp)
je     11ac <xcalloc_d+0x5c>
mov    $0x1,%al
mov    %al,-0x2a(%rbp)
jmp    11ac <xcalloc_d+0x5c>
mov    -0x2a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
je     11cf <xcalloc_d+0x7f>
cmpq   $0x0,-0x10(%rbp)
jne    11f2 <xcalloc_d+0xa2>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe35(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1030 <calloc_d@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1231 <xcalloc_d+0xe1>
mov    0x2dc4(%rip),%rax
mov    (%rax),%esi
lea    0xe3d(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xcalloc_d>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %edx,%edi
not    %edi
shr    $0x1f,%edi
call   1060 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1060 <assert@plt>
test   %rbp,%rbp
je     11a8 <xcalloc_d+0x58>
test   %rbx,%rbx
je     11a8 <xcalloc_d+0x58>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r14,%rcx
call   1030 <calloc_d@plt>
test   %rax,%rax
je     11ca <xcalloc_d+0x7a>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
mov    %r15d,%edx
mov    %r14,%rcx
call   1070 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
lea    0xe6d(%rip),%rdi
call   1050 <fputs@plt>
xor    %eax,%eax
call   1040 <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 xcalloc.\0A\09Line: %i\0A\09File: %s\0AAborting now.\0A\00"
@.str.2 = [42 x i8] c"Out of memory for xcalloc.\0AAborting now.\0A\00"
define i8* @xcalloc_d(i64 %0, i64 %1, i32 %2, i8* %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
br label %10
10: ; preds = %4
%11 = load i32, i32* %7
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
br label %14
14: ; preds = %13, %10
%15 = phi i1 [ false, %10 ], [ true, %13 ]
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
br label %18
18: ; preds = %14
br label %19
19: ; preds = %18
%20 = load i8*, i8** %8
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %23
22: ; preds = %19
br label %23
23: ; preds = %22, %19
%24 = phi i1 [ false, %19 ], [ true, %22 ]
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
br label %27
27: ; preds = %23
%28 = load i64, i64* %5
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i64, i64* %6
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %30, %27
%34 = load i32, i32* @stderr
%35 = load i32, i32* %7
%36 = load i8*, i8** %8
%37 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %35, i8* %36)
%38 = call i32 (...) @abort()
unreachable
39: ; preds = %30
%40 = load i64, i64* %5
%41 = load i64, i64* %6
%42 = load i32, i32* %7
%43 = load i8*, i8** %8
%44 = call i8* @calloc_d(i64 %40, i64 %41, i32 %42, i8* %43)
store i8* %44, i8** %9
%45 = load i8*, i8** %9
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %51
47: ; preds = %39
%48 = load i32, i32* @stderr
%49 = call i32 @fputs(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%50 = call i32 (...) @abort()
unreachable
51: ; preds = %39
%52 = load i8*, i8** %9
ret i8* %52
}

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