#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();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
void *realloc(void *, unsigned long);
int /*<<< orphan*/ stderr;
void *mem_resize(void *ptr, unsigned long nbytes, const char *filename,
                 unsigned long line) {
  ((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",
                   29, "ptr != NULL"),
           abort(), 0)));
  ptr = realloc(ptr, 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",
                   32, "ptr != NULL"),
           abort(), 0)));
  return ptr;
}


x86 assembly (clang, -O0):
<mem_resize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1182 <mem_resize+0x52>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
lea    0xeb2(%rip),%rdx
mov    $0x1d,%ecx
lea    0xf2c(%rip),%r8
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11cd <mem_resize+0x9d>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
lea    0xe67(%rip),%rdx
mov    $0x20,%ecx
lea    0xee1(%rip),%r8
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_resize>:
push   %rax
test   %rdi,%rdi
je     1142 <mem_resize+0x12>
call   1050 <realloc@plt>
test   %rax,%rax
je     1167 <mem_resize+0x37>
pop    %rcx
ret
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
lea    0xec3(%rip),%rdx
lea    0xf42(%rip),%r8
mov    $0x1d,%ecx
jmp    118a <mem_resize+0x5a>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
lea    0xe9e(%rip),%rdx
lea    0xf1d(%rip),%r8
mov    $0x20,%ecx
call   1040 <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_resize(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %16, label %11
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, 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 29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (...) @abort()
unreachable
15: ; No predecessors!
br label %16
16: ; preds = %15, %4
%17 = phi i1 [ true, %4 ], [ false, %15 ]
%18 = zext i1 %17 to i32
%19 = load i8*, i8** %5
%20 = load i64, i64* %6
%21 = call i8* @realloc(i8* %19, i64 %20)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = icmp ne i8* %22, null
br i1 %23, label %29, label %24
24: ; preds = %16
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, 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 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (...) @abort()
unreachable
28: ; No predecessors!
br label %29
29: ; preds = %28, %16
%30 = phi i1 [ true, %16 ], [ false, %28 ]
%31 = zext i1 %30 to i32
%32 = load i8*, i8** %5
ret i8* %32
}

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 noalias i8* @mem_resize(i8* %0, i64 %1, i8* nocapture readnone %2, i64 %3) {
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %10
6: ; preds = %4
%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 29, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %4
%11 = tail call i8* @realloc(i8* %0, i64 %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, 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 32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 (...) @abort()
unreachable
17: ; preds = %10
ret i8* %11
}