#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 */
typedef int /*<<< orphan*/ frames;

/* Variables and functions */
int /*<<< orphan*/ STDERR_FILENO;
int backtrace(void **, int);
int /*<<< orphan*/ backtrace_symbols_fd(void **, int, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int exit_on_no_memory(int size) {
  fprintf(stderr, "ERROR: not enough memory to allocate %d bytes of memory\n",
          size);
  void *frames[64];
  int nframes = backtrace(frames, sizeof(frames) / sizeof(frames[0]));
  backtrace_symbols_fd(frames, nframes, STDERR_FILENO);
  exit(-1);
  return 0;
}


x86 assembly (clang, -O0):
<exit_on_no_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe9f(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x210(%rbp),%rdi
mov    $0x40,%esi
call   1040 <backtrace@plt>
mov    %eax,-0x214(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x214(%rbp),%esi
mov    0x2e47(%rip),%rax
mov    (%rax),%edx
call   1030 <backtrace_symbols_fd@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<exit_on_no_memory>:
push   %rbx
sub    $0x200,%rsp
mov    %edi,%edx
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1040 <backtrace@plt>
mov    0x2e62(%rip),%rcx
mov    (%rcx),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <backtrace_symbols_fd@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [57 x i8] c"ERROR: not enough memory to allocate %d bytes of memory\0A\00"
@STDERR_FILENO = global i32 0
define i32 @exit_on_no_memory(i32 %0) {
%2 = alloca i32
%3 = alloca [64 x i8*]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* @stderr
%6 = load i32, i32* %2
%7 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [64 x i8*], [64 x i8*]* %3, i64 0, i64 0
%9 = call i32 @backtrace(i8** %8, i32 64)
store i32 %9, i32* %4
%10 = getelementptr inbounds [64 x i8*], [64 x i8*]* %3, i64 0, i64 0
%11 = load i32, i32* %4
%12 = load i32, i32* @STDERR_FILENO
%13 = call i32 @backtrace_symbols_fd(i8** %10, i32 %11, i32 %12)
%14 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [57 x i8] c"ERROR: not enough memory to allocate %d bytes of memory\0A\00"
@STDERR_FILENO = global i32 0
define i32 @exit_on_no_memory(i32 %0) {
%2 = alloca [64 x i8*]
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = bitcast [64 x i8*]* %2 to i8*
%6 = getelementptr inbounds [64 x i8*], [64 x i8*]* %2, i64 0, i64 0
%7 = call i32 @backtrace(i8** %6, i32 64)
%8 = load i32, i32* @STDERR_FILENO
%9 = call i32 @backtrace_symbols_fd(i8** %6, i32 %7, i32 %8)
%10 = call i32 @exit(i32 -1)
unreachable
}