void *myrealloc(void *oldp, int new_size) {
  void *newp = realloc(oldp, new_size);
  if (!newp)
    error_exit_(
        1, 1,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/flok99/multitail/refs/heads/master/mem.c",
        __PRETTY_FUNCTION__, 36,
        "Failed to reallocate a memory block to %d bytes.\n", new_size);
  return newp;
}


x86 assembly (clang, -O0):
<myrealloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rsi
call   1030 <realloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117a <myrealloc+0x5a>
mov    -0xc(%rbp),%eax
mov    $0x1,%esi
lea    0xea6(%rip),%rdx
lea    0xf22(%rip),%rcx
mov    $0x24,%r8d
lea    0xf32(%rip),%r9
mov    %esi,%edi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <error_exit_@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myrealloc>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
movslq %esi,%rsi
call   1030 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1164 <myrealloc+0x44>
mov    %ebp,(%rsp)
lea    0xec1(%rip),%rdx
lea    0xf3d(%rip),%rcx
lea    0xf53(%rip),%r9
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x24,%r8d
xor    %eax,%eax
call   1040 <error_exit_@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/flok99/multitail/refs/heads/master/mem.c\00"
@__PRETTY_FUNCTION__.myrealloc = [29 x i8] c"void *myrealloc(void *, int)\00"
@.str.1 = [50 x i8] c"Failed to reallocate a memory block to %d bytes.\0A\00"
define i8* @myrealloc(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = call i8* @realloc(i8* %6, i64 %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i32 (i32, i32, i8*, i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @error_exit_ to i32 (i32, i32, i8*, i8*, i32, i8*, i32, ...)*)(i32 1, i32 1, i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @__PRETTY_FUNCTION__.myrealloc, i64 0, i64 0), i32 36, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %2
%16 = load i8*, i8** %5
ret i8* %16
}

LLVM IR (-O2):
@.str = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/flok99/multitail/refs/heads/master/mem.c\00"
@__PRETTY_FUNCTION__.myrealloc = [29 x i8] c"void *myrealloc(void *, int)\00"
@.str.1 = [50 x i8] c"Failed to reallocate a memory block to %d bytes.\0A\00"
define i8* @myrealloc(i8* nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = tail call i8* @realloc(i8* %0, i64 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i32, i32, i8*, i8*, i32, i8*, i32, ...) bitcast (i32 (...)* @error_exit_ to i32 (i32, i32, i8*, i8*, i32, i8*, i32, ...)*)(i32 1, i32 1, i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @__PRETTY_FUNCTION__.myrealloc, i64 0, i64 0), i32 36, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %8
8: ; preds = %6, %2
ret i8* %4
}