#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*/ EXIT_FAILURE;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, size_t,
                           int, char const *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void memError(const char *caller, const char *file, int line, size_t size) {
  printf("\n");
  fprintf(stderr,
          "Error (%s) : Allocation of %zu bytes failed. [ line %d file %s ]\n",
          caller, size, line, file);
  if (errno)
    perror("System error message ");
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<memError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    -0x10(%rbp),%r9
lea    0xe7d(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e49(%rip),%rax
cmpq   $0x0,(%rax)
je     11a5 <memError+0x65>
lea    0xea2(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<memError>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %ebp,%r8d
mov    %r14,%r9
call   1040 <fprintf@plt>
mov    0x2e54(%rip),%rax
cmpq   $0x0,(%rax)
je     1196 <memError+0x56>
lea    0xeb1(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.1 = [66 x i8] c"Error (%s) : Allocation of %zu bytes failed. [ line %d file %s ]\0A\00"
@errno = global i64 0
@.str.2 = [22 x i8] c"System error message \00"
@EXIT_FAILURE = global i32 0
define void @memError(i8* %0, i8* %1, i32 %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i64 %3, i64* %8
%9 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %5
%12 = load i64, i64* %8
%13 = load i32, i32* %7
%14 = load i8*, i8** %6
%15 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i8* %11, i64 %12, i32 %13, i8* %14)
%16 = load i64, i64* @errno
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %4
%19 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %4
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [66 x i8] c"Error (%s) : Allocation of %zu bytes failed. [ line %d file %s ]\0A\00"
@errno = global i64 0
@.str.2 = [22 x i8] c"System error message \00"
@EXIT_FAILURE = global i32 0
define void @memError(i8* %0, i8* %1, i32 %2, i64 %3) {
%5 = tail call i32 @putchar(i32 10)
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i8* %0, i64 %3, i32 %2, i8* %1)
%8 = load i64, i64* @errno
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %4
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
}