#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);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, char *, int);
void *_mymalloc(size_t size, int line, char *message) {
  char *temp;
  if (size == 0)
    return NULL;
  temp = (char *)malloc(size);
  if (temp == NULL) {
    printf("\nmemory allocation failure in file: %s at line number: %d\n",
           message, line);
    exit(-1);
  }
  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    115b <_mymalloc+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    1198 <_mymalloc+0x68>
mov    -0x10(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1190 <_mymalloc+0x60>
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
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     1163 <_mymalloc+0x33>
mov    %rdx,%r14
mov    %esi,%ebx
call   1040 <malloc@plt>
test   %rax,%rax
jne    1165 <_mymalloc+0x35>
lea    0xeb1(%rip),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.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 i8*, i8** %7
%20 = load i32, i32* %6
%21 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %20)
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %12
%24 = load i8*, i8** %8
store i8* %24, i8** %4
br label %25
25: ; preds = %23, %11
%26 = load i8*, i8** %4
ret i8* %26
}

LLVM IR (-O2):
@.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 = tail call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1)
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %5
%12 = inttoptr i64 %6 to i8*
br label %13
13: ; preds = %3, %11
%14 = phi i8* [ %12, %11 ], [ null, %3 ]
ret i8* %14
}