#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;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t, char const *,
                           long);
void *malloc(size_t);
int /*<<< orphan*/ stderr;
void *fgls_malloc_impl(const char *file, long line, size_t size) {
  void *buf;
  if ((buf = malloc(size)) == NULL) {
    fprintf(stderr, "Couldn't allocate %ld bytes of memory in %s:%ld\n", size,
            file, line);
    exit(EXIT_FAILURE);
  }
  return buf;
}


x86 assembly (clang, -O0):
<fgls_malloc_impl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    118a <fgls_malloc_impl+0x5a>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe89(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgls_malloc_impl>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
call   1040 <malloc@plt>
test   %rax,%rax
je     1151 <fgls_malloc_impl+0x21>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <fprintf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"Couldn't allocate %ld bytes of memory in %s:%ld\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @fgls_malloc_impl(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = call i8* @malloc(i64 %8)
store i8* %9, i8** %7
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %19
11: ; preds = %3
%12 = load i32, i32* @stderr
%13 = load i64, i64* %6
%14 = load i8*, i8** %4
%15 = load i64, i64* %5
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i64 %13, i8* %14, i64 %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %3
%20 = load i8*, i8** %7
ret i8* %20
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"Couldn't allocate %ld bytes of memory in %s:%ld\0A\00"
@EXIT_FAILURE = global i32 0
define noalias i8* @fgls_malloc_impl(i8* %0, i64 %1, i64 %2) {
%4 = tail call i8* @malloc(i64 %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i64 %2, i8* %0, i64 %1)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %3
ret i8* %4
}