#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*/ abort();
void *calloc(int, unsigned long);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ stderr;
void *mem_alloc(unsigned long nbytes, const char *filename,
                unsigned long line) {
  void *ptr;
  ptr = calloc(1, nbytes);
  ((void)((ptr != NULL) ||
          (fprintf(stderr, "%s:%d Assertion failed: %s\n",
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/ajholanda/edu-C/refs/"
                   "heads/master/mem/mem.c",
                   10, "ptr != NULL"),
           abort(), 0)));
  return ptr;
}


x86 assembly (clang, -O0):
<mem_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1190 <mem_alloc+0x60>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
lea    0xea4(%rip),%rdx
mov    $0xa,%ecx
lea    0xf1e(%rip),%r8
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_alloc>:
push   %rax
mov    %rdi,%rsi
mov    $0x1,%edi
call   1040 <calloc@plt>
test   %rax,%rax
je     1145 <mem_alloc+0x15>
pop    %rcx
ret
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0xeab(%rip),%rsi
lea    0xec0(%rip),%rdx
lea    0xf3f(%rip),%r8
mov    $0xa,%ecx
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"%s:%d Assertion failed: %s\0A\00"
@.str.1 = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ajholanda/edu-C/refs/heads/master/mem/mem.c\00"
@.str.2 = [12 x i8] c"ptr != NULL\00"
define i8* @mem_alloc(i64 %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i64 %0, i64* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i64, i64* %4
%9 = call i8* @calloc(i32 1, i64 %8)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %17, label %12
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.1, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (...) @abort()
unreachable
16: ; No predecessors!
br label %17
17: ; preds = %16, %3
%18 = phi i1 [ true, %3 ], [ false, %16 ]
%19 = zext i1 %18 to i32
%20 = load i8*, i8** %7
ret i8* %20
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"%s:%d Assertion failed: %s\0A\00"
@.str.1 = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ajholanda/edu-C/refs/heads/master/mem/mem.c\00"
@.str.2 = [12 x i8] c"ptr != NULL\00"
define i8* @mem_alloc(i64 %0, i8* nocapture readnone %1, i64 %2) {
%4 = tail call i8* @calloc(i32 1, i64 %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.1, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %3
ret i8* %4
}