#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*/ redcheck(int);
int /*<<< orphan*/ redfree(char *);
char *redmalloc(int, char *, int);
int /*<<< orphan*/ redmallocinit();
int main() {
  redmallocinit();
  char *ptr1 = redmalloc((5),
                         "/scratch/repos/new/home/jordi_armengol_estape/"
                         "c-scraper/outputs/2022-01-22/02-19-57/repos/flipk/"
                         "pfkutils/refs/heads/main/misc/redmalloc/c/test.c",
                         10);
  char *ptr2 = redmalloc((254),
                         "/scratch/repos/new/home/jordi_armengol_estape/"
                         "c-scraper/outputs/2022-01-22/02-19-57/repos/flipk/"
                         "pfkutils/refs/heads/main/misc/redmalloc/c/test.c",
                         11);
  char *ptr3 = redmalloc((120),
                         "/scratch/repos/new/home/jordi_armengol_estape/"
                         "c-scraper/outputs/2022-01-22/02-19-57/repos/flipk/"
                         "pfkutils/refs/heads/main/misc/redmalloc/c/test.c",
                         12);
  redcheck(1);
  redfree(ptr3);
  redcheck(0);
  redfree(ptr1);
  redcheck(0);
  redfree(ptr2);
  redcheck(0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <redmallocinit@plt>
mov    $0x5,%edi
lea    0xe9e(%rip),%rsi
mov    $0xa,%edx
call   1050 <redmalloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0xfe,%edi
lea    0xe84(%rip),%rsi
mov    $0xb,%edx
call   1050 <redmalloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x78,%edi
lea    0xe6a(%rip),%rsi
mov    $0xc,%edx
call   1050 <redmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
call   1060 <redcheck@plt>
mov    -0x20(%rbp),%rdi
call   1040 <redfree@plt>
xor    %edi,%edi
call   1060 <redcheck@plt>
mov    -0x10(%rbp),%rdi
call   1040 <redfree@plt>
xor    %edi,%edi
call   1060 <redcheck@plt>
mov    -0x18(%rbp),%rdi
call   1040 <redfree@plt>
xor    %edi,%edi
call   1060 <redcheck@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <redmallocinit@plt>
lea    0xead(%rip),%rbx
mov    $0x5,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1050 <redmalloc@plt>
mov    %rax,%r14
mov    $0xfe,%edi
mov    %rbx,%rsi
mov    $0xb,%edx
call   1050 <redmalloc@plt>
mov    %rax,%r15
mov    $0x78,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1050 <redmalloc@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   1060 <redcheck@plt>
mov    %rbx,%rdi
call   1040 <redfree@plt>
xor    %edi,%edi
call   1060 <redcheck@plt>
mov    %r14,%rdi
call   1040 <redfree@plt>
xor    %edi,%edi
call   1060 <redcheck@plt>
mov    %r15,%rdi
call   1040 <redfree@plt>
xor    %edi,%edi
call   1060 <redcheck@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/flipk/pfkutils/refs/heads/main/misc/redmalloc/c/test.c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32 (...) @redmallocinit()
%6 = call i8* @redmalloc(i32 5, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 10)
store i8* %6, i8** %2
%7 = call i8* @redmalloc(i32 254, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 11)
store i8* %7, i8** %3
%8 = call i8* @redmalloc(i32 120, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 12)
store i8* %8, i8** %4
%9 = call i32 @redcheck(i32 1)
%10 = load i8*, i8** %4
%11 = call i32 @redfree(i8* %10)
%12 = call i32 @redcheck(i32 0)
%13 = load i8*, i8** %2
%14 = call i32 @redfree(i8* %13)
%15 = call i32 @redcheck(i32 0)
%16 = load i8*, i8** %3
%17 = call i32 @redfree(i8* %16)
%18 = call i32 @redcheck(i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/flipk/pfkutils/refs/heads/main/misc/redmalloc/c/test.c\00"
define i32 @main() {
%1 = tail call i32 (...) @redmallocinit()
%2 = tail call i8* @redmalloc(i32 5, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 10)
%3 = tail call i8* @redmalloc(i32 254, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 11)
%4 = tail call i8* @redmalloc(i32 120, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 12)
%5 = tail call i32 @redcheck(i32 1)
%6 = tail call i32 @redfree(i8* %4)
%7 = tail call i32 @redcheck(i32 0)
%8 = tail call i32 @redfree(i8* %2)
%9 = tail call i32 @redcheck(i32 0)
%10 = tail call i32 @redfree(i8* %3)
%11 = tail call i32 @redcheck(i32 0)
ret i32 0
}