#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*/ my_free(char *, char *, int);
scalar_t__ my_malloc(int, char *, int);
int /*<<< orphan*/ printf(char *);
void perfectly_valid() {
  printf("\n--------------------------------");
  printf("\nBegin **perfectly valid** test. \n\n");
  printf("You should expect to see normal allocations.\n\n");
  char *p = (char *)my_malloc(
      100,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/PLJNS/Rutgers-Systems-Programming-Fall-2013/"
      "refs/heads/master/Malloc/testcases.c",
      59);
  my_free(
      p,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/PLJNS/Rutgers-Systems-Programming-Fall-2013/"
      "refs/heads/master/Malloc/testcases.c",
      60);
  p = (char *)my_malloc(
      100,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/PLJNS/Rutgers-Systems-Programming-Fall-2013/"
      "refs/heads/master/Malloc/testcases.c",
      61);
  my_free(
      p,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/PLJNS/Rutgers-Systems-Programming-Fall-2013/"
      "refs/heads/master/Malloc/testcases.c",
      62);
  printf("\nEnd **perfectly valid** test.");
  printf("\n------------------------------\n\n");
}


x86 assembly (clang, -O0):
<perfectly_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
call   1040 <printf@plt>
lea    0xeef(%rip),%rdi
call   1040 <printf@plt>
mov    $0x64,%edi
lea    0xf0d(%rip),%rsi
mov    $0x3b,%edx
call   1030 <my_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xef4(%rip),%rsi
mov    $0x3c,%edx
call   1050 <my_free@plt>
mov    $0x64,%edi
lea    0xede(%rip),%rsi
mov    $0x3d,%edx
call   1030 <my_malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
mov    $0x3e,%edx
call   1050 <my_free@plt>
lea    0xf5f(%rip),%rdi
call   1040 <printf@plt>
lea    0xf72(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perfectly_valid>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1050 <printf@plt>
lea    0xf98(%rip),%rdi
call   1040 <puts@plt>
lea    0xfaf(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb6(%rip),%rbx
mov    $0x64,%edi
mov    %rbx,%rsi
mov    $0x3b,%edx
call   1030 <my_malloc@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    $0x3c,%edx
call   1060 <my_free@plt>
mov    $0x64,%edi
mov    %rbx,%rsi
mov    $0x3d,%edx
call   1030 <my_malloc@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    $0x3e,%edx
call   1060 <my_free@plt>
lea    0xf16(%rip),%rdi
call   1050 <printf@plt>
lea    0xf7a(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"\0A--------------------------------\00"
@.str.1 = [36 x i8] c"\0ABegin **perfectly valid** test. \0A\0A\00"
@.str.2 = [47 x i8] c"You should expect to see normal allocations.\0A\0A\00"
@.str.3 = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/PLJNS/Rutgers-Systems-Programming-Fall-2013/refs/heads/master/Malloc/testcases.c\00"
@.str.4 = [31 x i8] c"\0AEnd **perfectly valid** test.\00"
@.str.5 = [34 x i8] c"\0A------------------------------\0A\0A\00"
define void @perfectly_valid() {
%1 = alloca i8*
%2 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%5 = call i64 @my_malloc(i32 100, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 59)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %1
%7 = load i8*, i8** %1
%8 = call i32 @my_free(i8* %7, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 60)
%9 = call i64 @my_malloc(i32 100, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 61)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %1
%11 = load i8*, i8** %1
%12 = call i32 @my_free(i8* %11, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 62)
%13 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"\0A--------------------------------\00"
@.str.3 = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/PLJNS/Rutgers-Systems-Programming-Fall-2013/refs/heads/master/Malloc/testcases.c\00"
@.str.4 = [31 x i8] c"\0AEnd **perfectly valid** test.\00"
@str = [35 x i8] c"\0ABegin **perfectly valid** test. \0A\00"
@str.6 = [46 x i8] c"You should expect to see normal allocations.\0A\00"
@str.7 = [33 x i8] c"\0A------------------------------\0A\00"
define void @perfectly_valid() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.6, i64 0, i64 0))
%4 = tail call i64 @my_malloc(i32 100, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 59)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @my_free(i8* %5, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 60)
%7 = tail call i64 @my_malloc(i32 100, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 61)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @my_free(i8* %8, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 62)
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
ret void
}