#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *, int);
char *mallocMem(int bufferLen) {
  char *buffer = (char *)malloc(bufferLen);
  if (NULL == buffer) {
    printf("\n%s,%d:malloc not successful!",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/Sunfe/sas/refs/heads/master/source/"
           "sas_common.c",
           51);
    return NULL;
  }
  memset(buffer, 0, bufferLen);
  return buffer;
}


x86 assembly (clang, -O0):
<mallocMem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1178 <mallocMem+0x48>
lea    0xea6(%rip),%rdi
lea    0xebd(%rip),%rsi
mov    $0x33,%edx
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    118e <mallocMem+0x5e>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mallocMem>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1050 <malloc@plt>
test   %rax,%rax
je     1150 <mallocMem+0x20>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
jmp    116a <mallocMem+0x3a>
lea    0xea9(%rip),%rdi
lea    0xec0(%rip),%rsi
mov    $0x33,%edx
call   1030 <printf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0A%s,%d:malloc not successful!\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Sunfe/sas/refs/heads/master/source/sas_common.c\00"
define i8* @mallocMem(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* null, %8
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 51)
store i8* null, i8** %2
br label %17
12: ; preds = %1
%13 = load i8*, i8** %4
%14 = load i32, i32* %3
%15 = call i32 @memset(i8* %13, i32 0, i32 %14)
%16 = load i8*, i8** %4
store i8* %16, i8** %2
br label %17
17: ; preds = %12, %10
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@.str = [30 x i8] c"\0A%s,%d:malloc not successful!\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Sunfe/sas/refs/heads/master/source/sas_common.c\00"
define i8* @mallocMem(i32 %0) {
%2 = tail call i64 @malloc(i32 %0)
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i64 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 51)
br label %9
7: ; preds = %1
%8 = tail call i32 @memset(i8* %3, i32 0, i32 %0)
br label %9
9: ; preds = %7, %5
%10 = phi i8* [ null, %5 ], [ %3, %7 ]
ret i8* %10
}