#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*/ assert(int);
scalar_t__ memcmp(char *, void *, int);
int /*<<< orphan*/ sprintf(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *tlcalloc(int, char *, int, int);
int /*<<< orphan*/ tlfree(int, char *, char *);
int /*<<< orphan*/ tlinit();
char *tlmalloc(int, char *, int);
char *tlrealloc(int, char *, char *, int);
int tlstats();
int main(void) {
  char *b1;
  char *b2;
  char *b3;
  size_t null = 0;
  void *nullptr = &null;
  tlinit();
  b1 = tlmalloc(16,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/"
                "master/source/tracelib2/tracelib2_test.c",
                512);
  b2 = tlmalloc(17,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/"
                "master/source/tracelib2/tracelib2_test.c",
                1012);
  tlfree(18,
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/master/source/"
         "tracelib2/tracelib2_test.c",
         b2);
  sprintf(b1, "hello world");
  b3 = tlmalloc(20,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/"
                "master/source/tracelib2/tracelib2_test.c",
                strlen(b1));
  strcpy(b3, b1);
  b2 = tlrealloc(23,
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/"
                 "master/source/tracelib2/tracelib2_test.c",
                 b1, 1024);
  assert(b2 != b1);
  tlfree(26,
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/master/source/"
         "tracelib2/tracelib2_test.c",
         b1);
  assert(strcmp(b3, b2) == 0);
  tlfree(28,
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/master/source/"
         "tracelib2/tracelib2_test.c",
         b2);
  b2 = tlcalloc(30,
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/"
                "master/source/tracelib2/tracelib2_test.c",
                1, sizeof(void *));
  assert(memcmp(b2, nullptr, sizeof(void *)) == 0);
  return tlstats();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   10a0 <tlinit@plt>
mov    $0x10,%edi
lea    0xe0e(%rip),%rsi
mov    $0x200,%edx
call   1080 <tlmalloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x11,%edi
lea    0xdf4(%rip),%rsi
mov    $0x3f4,%edx
call   1080 <tlmalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
mov    $0x12,%edi
lea    0xdd6(%rip),%rsi
call   10b0 <tlfree@plt>
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edx
mov    $0x14,%edi
lea    0xdaa(%rip),%rsi
call   1080 <tlmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdx
mov    $0x17,%edi
lea    0xd84(%rip),%rsi
mov    $0x400,%ecx
call   1050 <tlrealloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x10(%rbp),%rdx
mov    $0x1a,%edi
lea    0xd51(%rip),%rsi
call   10b0 <tlfree@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x18(%rbp),%rdx
mov    $0x1c,%edi
lea    0xd1e(%rip),%rsi
call   10b0 <tlfree@plt>
mov    $0x1e,%edi
lea    0xd0d(%rip),%rsi
mov    $0x1,%edx
mov    $0x8,%ecx
call   10e0 <tlcalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    $0x8,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    $0x0,%al
call   10c0 <tlstats@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
xor    %eax,%eax
call   10a0 <tlinit@plt>
lea    0xe32(%rip),%r14
mov    $0x10,%edi
mov    %r14,%rsi
mov    $0x200,%edx
call   1080 <tlmalloc@plt>
mov    %rax,%rbx
mov    $0x11,%edi
mov    %r14,%rsi
mov    $0x3f4,%edx
call   1080 <tlmalloc@plt>
mov    $0x12,%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   10b0 <tlfree@plt>
movabs $0x6f77206f6c6c6568,%rax
20 77 6f
mov    %rax,(%rbx)
movl   $0x646c72,0x8(%rbx)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x14,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1080 <tlmalloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0x17,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x400,%ecx
call   1050 <tlrealloc@plt>
mov    %rax,%r15
xor    %edi,%edi
cmp    %rbx,%rax
setne  %dil
call   1090 <assert@plt>
mov    $0x1a,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10b0 <tlfree@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    $0x1c,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10b0 <tlfree@plt>
mov    $0x1e,%edi
mov    %r14,%rsi
mov    $0x1,%edx
mov    $0x8,%ecx
call   10d0 <tlcalloc@plt>
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0x8,%edx
call   1060 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
xor    %eax,%eax
call   10c0 <tlstats@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/master/source/tracelib2/tracelib2_test.c\00"
@.str.1 = [12 x i8] c"hello world\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i32 0, i32* %1
store i64 0, i64* %5
%7 = bitcast i64* %5 to i8*
store i8* %7, i8** %6
%8 = call i32 (...) @tlinit()
%9 = call i8* @tlmalloc(i32 16, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 512)
store i8* %9, i8** %2
%10 = call i8* @tlmalloc(i32 17, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 1012)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @tlfree(i32 18, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %2
%14 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = call i8* @tlmalloc(i32 20, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 %16)
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = load i8*, i8** %2
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = load i8*, i8** %2
%22 = call i8* @tlrealloc(i32 23, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %21, i32 1024)
store i8* %22, i8** %3
%23 = load i8*, i8** %3
%24 = load i8*, i8** %2
%25 = icmp ne i8* %23, %24
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i8*, i8** %2
%29 = call i32 @tlfree(i32 26, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %4
%31 = load i8*, i8** %3
%32 = call i64 @strcmp(i8* %30, i8* %31)
%33 = icmp eq i64 %32, 0
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i8*, i8** %3
%37 = call i32 @tlfree(i32 28, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = call i8* @tlcalloc(i32 30, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 1, i32 8)
store i8* %38, i8** %3
%39 = load i8*, i8** %3
%40 = load i8*, i8** %6
%41 = call i64 @memcmp(i8* %39, i8* %40, i32 8)
%42 = icmp eq i64 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = call i32 (...) @tlstats()
ret i32 %45
}

LLVM IR (-O2):
@.str = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lantus/openbor/refs/heads/master/source/tracelib2/tracelib2_test.c\00"
@.str.1 = [12 x i8] c"hello world\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = tail call i32 (...) @tlinit()
%4 = tail call i8* @tlmalloc(i32 16, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 512)
%5 = tail call i8* @tlmalloc(i32 17, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 1012)
%6 = tail call i32 @tlfree(i32 18, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %5)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %4, i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 12, i1 false)
%7 = tail call i32 @strlen(i8* %4)
%8 = tail call i8* @tlmalloc(i32 20, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 @strcpy(i8* %8, i8* %4)
%10 = tail call i8* @tlrealloc(i32 23, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %4, i32 1024)
%11 = icmp ne i8* %10, %4
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @tlfree(i32 26, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %4)
%15 = tail call i64 @strcmp(i8* %8, i8* %10)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = tail call i32 @tlfree(i32 28, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* %10)
%20 = tail call i8* @tlcalloc(i32 30, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 1, i32 8)
%21 = call i64 @memcmp(i8* %20, i8* %2, i32 8)
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i32 (...) @tlstats()
ret i32 %25
}