#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 /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char const *,
                           size_t);
int /*<<< orphan*/ stderr;
void mem_fail(size_t bytes, int line, const char *file) {
  do {
    assert(((line >= 0)) && ("assertion failed in ASSUME"));
  } while (0);
  do {
    assert(((file != NULL)) && ("assertion failed in ASSUME"));
  } while (0);
  fprintf(stderr, "Memory failure!\n\tLine: %i\n\tFile: %s\n\tBytes: %zu\n",
          line, file, bytes);
}


x86 assembly (clang, -O0):
<mem_fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x19(%rbp)
jl     114c <mem_fail+0x2c>
mov    $0x1,%al
mov    %al,-0x19(%rbp)
jmp    114c <mem_fail+0x2c>
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
jmp    115e <mem_fail+0x3e>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x1a(%rbp)
je     1178 <mem_fail+0x58>
mov    $0x1,%al
mov    %al,-0x1a(%rbp)
jmp    1178 <mem_fail+0x58>
mov    -0x1a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0xe7b(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_fail>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
mov    %r14,%r8
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"assertion failed in ASSUME\00"
@stderr = global i32 0
@.str.1 = [49 x i8] c"Memory failure!\0A\09Line: %i\0A\09File: %s\0A\09Bytes: %zu\0A\00"
define void @mem_fail(i64 %0, i32 %1, i8* %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8*
store i64 %0, i64* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
br label %7
7: ; preds = %3
%8 = load i32, i32* %5
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
br label %11
11: ; preds = %10, %7
%12 = phi i1 [ false, %7 ], [ true, %10 ]
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
br label %15
15: ; preds = %11
br label %16
16: ; preds = %15
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %16
br label %20
20: ; preds = %19, %16
%21 = phi i1 [ false, %16 ], [ true, %19 ]
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
br label %24
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = load i32, i32* %5
%27 = load i8*, i8** %6
%28 = load i64, i64* %4
%29 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %26, i8* %27, i64 %28)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [49 x i8] c"Memory failure!\0A\09Line: %i\0A\09File: %s\0A\09Bytes: %zu\0A\00"
define void @mem_fail(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 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %2, i64 %0)
ret void
}