#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*/ fprintf(int /*<<< orphan*/, char *, char const *, int);
scalar_t__ malloc(long);
int /*<<< orphan*/ stderr;
void *_mymalloc(long size, int line, const char *message) {
  char *temp;
  if (size == 0)
    return NULL;
  temp = (char *)malloc(size);
  if (temp == NULL) {
    fprintf(stderr,
            "\nmemory allocation failure in file: %s at line number: %d\n",
            message, line);
    return NULL;
  }
  return (void *)temp;
}


x86 assembly (clang, -O0):
<_mymalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114b <_mymalloc+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    1194 <_mymalloc+0x74>
mov    -0x10(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118c <_mymalloc+0x6c>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe86(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1194 <_mymalloc+0x74>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mymalloc>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1152 <_mymalloc+0x32>
mov    %rdx,%r14
mov    %esi,%ebx
call   1040 <malloc@plt>
test   %rax,%rax
jne    1154 <_mymalloc+0x34>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [59 x i8] c"\0Amemory allocation failure in file: %s at line number: %d\0A\00"
define i8* @_mymalloc(i64 %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i64 %0, i64* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = load i64, i64* %5
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
store i8* null, i8** %4
br label %25
12: ; preds = %3
%13 = load i64, i64* %5
%14 = call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %8
%16 = load i8*, i8** %8
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %7
%21 = load i32, i32* %6
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %21)
store i8* null, i8** %4
br label %25
23: ; preds = %12
%24 = load i8*, i8** %8
store i8* %24, i8** %4
br label %25
25: ; preds = %23, %18, %11
%26 = load i8*, i8** %4
ret i8* %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"\0Amemory allocation failure in file: %s at line number: %d\0A\00"
define i8* @_mymalloc(i64 %0, i32 %1, i8* %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %13, label %5
5: ; preds = %3
%6 = tail call i64 @malloc(i64 %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1)
br label %13
11: ; preds = %5
%12 = inttoptr i64 %6 to i8*
br label %13
13: ; preds = %3, %11, %8
%14 = phi i8* [ null, %8 ], [ %12, %11 ], [ null, %3 ]
ret i8* %14
}