#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*/ _fatal(char const *, char const *, int, char *,
                          unsigned int);
void *malloc(unsigned int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, unsigned int);
void *_malloc(unsigned int size, const char *file, const char *function,
              int line) {
  void *addr;
  addr = malloc(size);
  if (!addr)
    _fatal(file, function, line, "No memory for %d bytes.\n", size);
  memset(addr, 0, size);
  return addr;
}


x86 assembly (clang, -O0):
<_malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1178 <_malloc+0x48>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x4(%rbp),%r8d
lea    0xe8d(%rip),%rcx
call   1030 <_fatal@plt>
mov    -0x28(%rbp),%rdi
mov    -0x4(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_malloc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebp
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1168 <_malloc+0x38>
lea    0xea9(%rip),%rcx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %ebp,%r8d
call   1030 <_fatal@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"No memory for %d bytes.\0A\00"
define i8* @_malloc(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = call i8* @malloc(i32 %10)
store i8* %11, i8** %9
%12 = load i8*, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %20, label %14
14: ; preds = %4
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = load i32, i32* %8
%18 = load i32, i32* %5
%19 = call i32 @_fatal(i8* %15, i8* %16, i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %14, %4
%21 = load i8*, i8** %9
%22 = load i32, i32* %5
%23 = call i32 @memset(i8* %21, i32 0, i32 %22)
%24 = load i8*, i8** %9
ret i8* %24
}

LLVM IR (-O2):
@.str = [25 x i8] c"No memory for %d bytes.\0A\00"
define i8* @_malloc(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i8* @malloc(i32 %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @_fatal(i8* %1, i8* %2, i32 %3, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %9
9: ; preds = %7, %4
%10 = tail call i32 @memset(i8* %5, i32 0, i32 %0)
ret i8* %5
}