#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__ n_assert_fail(char *, char *, int);
int /*<<< orphan*/ nomem();
void *realloc(void *, size_t);
void *n_realloc(void *ptr, size_t size) {
  ((void)((size > 0)
              ? 0
              : (n_assert_fail("size > 0",
                               "/scratch/repos/new/home/jordi_armengol_estape/"
                               "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                               "megabajt/trurlib/refs/heads/master/nmalloc.c",
                               80),
                 0)));
  if ((ptr = realloc(ptr, size)) == NULL)
    nomem();
  return ptr;
}


x86 assembly (clang, -O0):
<n_realloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jbe    1150 <n_realloc+0x20>
jmp    1168 <n_realloc+0x38>
lea    0xea9(%rip),%rdi
lea    0xeab(%rip),%rsi
mov    $0x50,%edx
call   1050 <n_assert_fail@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    118a <n_realloc+0x5a>
mov    $0x0,%al
call   1030 <nomem@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<n_realloc>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rsi,%rsi
jne    1157 <n_realloc+0x27>
lea    0xeba(%rip),%rdi
lea    0xebc(%rip),%rsi
mov    $0x50,%edx
call   1050 <n_assert_fail@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1171 <n_realloc+0x41>
xor    %eax,%eax
call   1030 <nomem@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"size > 0\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/megabajt/trurlib/refs/heads/master/nmalloc.c\00"
define i8* @n_realloc(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = icmp ugt i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
br label %10
8: ; preds = %2
%9 = call i64 @n_assert_fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 80)
br label %10
10: ; preds = %8, %7
%11 = phi i32 [ 0, %7 ], [ 0, %8 ]
%12 = load i8*, i8** %3
%13 = load i64, i64* %4
%14 = call i8* @realloc(i8* %12, i64 %13)
store i8* %14, i8** %3
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 (...) @nomem()
br label %18
18: ; preds = %16, %10
%19 = load i8*, i8** %3
ret i8* %19
}

LLVM IR (-O2):
@.str = [9 x i8] c"size > 0\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/megabajt/trurlib/refs/heads/master/nmalloc.c\00"
define noalias i8* @n_realloc(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i64 @n_assert_fail(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 80)
br label %6
6: ; preds = %2, %4
%7 = tail call i8* @realloc(i8* %0, i64 %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (...) @nomem()
br label %11
11: ; preds = %9, %6
ret i8* %7
}