#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 *, int, char *);
void *malloc(size_t);
int /*<<< orphan*/ stderr;
void *my_malloc(size_t size, char *file, int line) {
  void *ptr = NULL;
  ptr = malloc(size);
  if (size <= 0) {
    fprintf(stderr,
            "Erreur lors d'un malloc : la taille doit etre superieure a "
            "0\nLigne %d du fichier %s\n",
            line, file);
    exit(EXIT_FAILURE);
  }
  if (!ptr) {
    fprintf(stderr, "Erreur lors d'un malloc : ligne %d du fichier %s\n", line,
            file);
    exit(EXIT_FAILURE);
  }
  return (ptr);
}


x86 assembly (clang, -O0):
<my_malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
ja     118d <my_malloc+0x5d>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    0xe86(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
jne    11c2 <my_malloc+0x92>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    0xea6(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_malloc>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <malloc@plt>
test   %rbx,%rbx
je     1150 <my_malloc+0x20>
test   %rax,%rax
je     1162 <my_malloc+0x32>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
jmp    1172 <my_malloc+0x42>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xee3(%rip),%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1030 <fprintf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [85 x i8] c"Erreur lors d'un malloc : la taille doit etre superieure a 0\0ALigne %d du fichier %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [50 x i8] c"Erreur lors d'un malloc : ligne %d du fichier %s\0A\00"
define i8* @my_malloc(i64 %0, i8* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i64 %0, i64* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i8* null, i8** %7
%8 = load i64, i64* %4
%9 = call i8* @malloc(i64 %8)
store i8* %9, i8** %7
%10 = load i64, i64* %4
%11 = icmp ule i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = load i32, i32* %6
%15 = load i8*, i8** %5
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0), i32 %14, i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %3
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %29, label %22
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = load i32, i32* %6
%25 = load i8*, i8** %5
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %24, i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %19
%30 = load i8*, i8** %7
ret i8* %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [85 x i8] c"Erreur lors d'un malloc : la taille doit etre superieure a 0\0ALigne %d du fichier %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [50 x i8] c"Erreur lors d'un malloc : ligne %d du fichier %s\0A\00"
define noalias i8* @my_malloc(i64 %0, i8* %1, i32 %2) {
%4 = tail call i8* @malloc(i64 %0)
%5 = icmp eq i64 %0, 0
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 ([85 x i8], [85 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %1)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %3
%12 = icmp eq i8* %4, null
br i1 %12, label %13, label %18
13: ; preds = %11
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* %1)
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %11
ret i8* %4
}