#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t, char *, int);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
void *emalloc_(char *file, int line, size_t sz) {
  void *ptr;
  ptr = (void *)malloc(sz);
  if (ptr == 0x00) {
    fprintf(stderr,
            "SBA: memory allocation request for %zu bytes failed in file %s, "
            "line %d, exiting",
            sz, file, line);
    exit(1);
  }
  return ptr;
}


x86 assembly (clang, -O0):
<emalloc_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1186 <emalloc_+0x56>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%r8d
lea    0xe89(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emalloc_>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%rbp
mov    %rdx,%rdi
call   1040 <malloc@plt>
test   %rax,%rax
je     114f <emalloc_+0x1f>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %r14d,%r8d
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [81 x i8] c"SBA: memory allocation request for %zu bytes failed in file %s, line %d, exiting\00"
define i8* @emalloc_(i8* %0, i32 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = load i64, i64* %6
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0), i64 %15, i8* %16, i32 %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %3
%21 = load i8*, i8** %7
ret i8* %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [81 x i8] c"SBA: memory allocation request for %zu bytes failed in file %s, line %d, exiting\00"
define i8* @emalloc_(i8* %0, i32 %1, i64 %2) {
%4 = tail call i64 @malloc(i64 %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str, i64 0, i64 0), i64 %2, i8* %0, i32 %1)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = inttoptr i64 %4 to i8*
ret i8* %11
}