#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(int, char *, int);
scalar_t__ my_malloc(int, char *, int);
int /*<<< orphan*/ printf(char *);
void freeing_pointers_not_returned_from_malloc() {
  printf("\n--------------------------------");
  printf("\nBegin **freeing pointers not returned from malloc** test. \n\n");
  printf("You should expect to see a denied free.\n\n");
  int p = (char *)my_malloc(
      200,
      "/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",
      27);
  my_free(
      p + 10,
      "/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",
      28);
  printf("\nEnd **freeing pointers not returned from malloc** test.");
  printf("\n------------------------------\n\n");
}


x86 assembly (clang, -O0):
<freeing_pointers_not_returned_from_malloc>:
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    0xf09(%rip),%rdi
call   1040 <printf@plt>
mov    $0xc8,%edi
lea    0xf22(%rip),%rsi
mov    $0x1b,%edx
call   1030 <my_malloc@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
add    $0xa,%edi
lea    0xf08(%rip),%rsi
mov    $0x1c,%edx
call   1050 <my_free@plt>
lea    0xfa2(%rip),%rdi
call   1040 <printf@plt>
lea    0xfcf(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freeing_pointers_not_returned_from_malloc>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1050 <printf@plt>
lea    0xfb2(%rip),%rdi
call   1040 <puts@plt>
lea    0xfe3(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb6(%rip),%rbx
mov    $0xc8,%edi
mov    %rbx,%rsi
mov    $0x1b,%edx
call   1030 <my_malloc@plt>
lea    0xa(%rax),%edi
mov    %rbx,%rsi
mov    $0x1c,%edx
call   1060 <my_free@plt>
lea    0xf38(%rip),%rdi
call   1050 <printf@plt>
lea    0xfcb(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"\0A--------------------------------\00"
@.str.1 = [62 x i8] c"\0ABegin **freeing pointers not returned from malloc** test. \0A\0A\00"
@.str.2 = [42 x i8] c"You should expect to see a denied free.\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 = [57 x i8] c"\0AEnd **freeing pointers not returned from malloc** test.\00"
@.str.5 = [34 x i8] c"\0A------------------------------\0A\0A\00"
define void @freeing_pointers_not_returned_from_malloc() {
%1 = alloca i32
%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 ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%5 = call i64 @my_malloc(i32 200, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 27)
%6 = inttoptr i64 %5 to i8*
%7 = ptrtoint i8* %6 to i32
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = add nsw i32 %8, 10
%10 = call i32 @my_free(i32 %9, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 28)
%11 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%12 = 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 = [57 x i8] c"\0AEnd **freeing pointers not returned from malloc** test.\00"
@str = [61 x i8] c"\0ABegin **freeing pointers not returned from malloc** test. \0A\00"
@str.6 = [41 x i8] c"You should expect to see a denied free.\0A\00"
@str.7 = [33 x i8] c"\0A------------------------------\0A\00"
define void @freeing_pointers_not_returned_from_malloc() {
%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 ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.6, i64 0, i64 0))
%4 = tail call i64 @my_malloc(i32 200, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 27)
%5 = trunc i64 %4 to i32
%6 = add nsw i32 %5, 10
%7 = tail call i32 @my_free(i32 %6, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 28)
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
ret void
}