#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*/ EX_OSERR;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, int, char *);
int /*<<< orphan*/ pgp_show_stacktrace();
int /*<<< orphan*/ stderr;
char *strerror(int);
void __pgp_malloc(const char *_function_name, const char *_file_name,
                  int _line_number, int _errno) {
  fprintf(stderr, "malloc failed: file=%s, function=%s, line=%d (%s)\n",
          _file_name, _function_name, _line_number, strerror(_errno));
  pgp_show_stacktrace();
  exit(EX_OSERR);
}


x86 assembly (clang, -O0):
<__pgp_malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    %rax,%r9
lea    0xe67(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1040 <pgp_show_stacktrace@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<__pgp_malloc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    0x2e89(%rip),%rax
mov    (%rax),%ebx
mov    %ecx,%edi
call   1060 <strerror@plt>
lea    0xe99(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %r14d,%r8d
mov    %rax,%r9
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1040 <pgp_show_stacktrace@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"malloc failed: file=%s, function=%s, line=%d (%s)\0A\00"
@EX_OSERR = global i32 0
define void @__pgp_malloc(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %6
%11 = load i8*, i8** %5
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i32 %12, i8* %14)
%16 = call i32 (...) @pgp_show_stacktrace()
%17 = load i32, i32* @EX_OSERR
%18 = call i32 @exit(i32 %17)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"malloc failed: file=%s, function=%s, line=%d (%s)\0A\00"
@EX_OSERR = global i32 0
define void @__pgp_malloc(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = load i32, i32* @stderr
%6 = tail call i8* @strerror(i32 %3)
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0, i32 %2, i8* %6)
%8 = tail call i32 (...) @pgp_show_stacktrace()
%9 = load i32, i32* @EX_OSERR
%10 = tail call i32 @exit(i32 %9)
unreachable
}