#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 */
typedef scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *mkPmem(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char *pmem1, *pmem2, *pmem3, *pmem4, *pmem5, *pmem6, *pmemN;
  pmem1 = mkPmem("test0.txt");
  printf("Pmem is: %d\n", (int)(off_t)pmem1);
  printf("\n");
  pmem2 = mkPmem("test5.txt");
  printf("Pmem is: %d\n", (int)(off_t)pmem2);
  printf("\n");
  pmem3 = mkPmem("test6.txt");
  printf("Pmem is: %d\n", (int)(off_t)pmem3);
  printf("\n");
  pmem4 = mkPmem("test23.txt");
  printf("Pmem is: %d\n", (int)(off_t)pmem4);
  printf("\n");
  pmem5 = mkPmem("test100.txt");
  printf("Pmem is: %d\n", (int)(off_t)pmem5);
  printf("\n");
  pmem6 = mkPmem("basicprogramtest.txt");
  printf("Pmem is: %d\n", (int)(off_t)pmem6);
  printf("\n");
  pmemN = mkPmem("this file does not exist :(");
  printf("Pmem is: %d\n", (int)(off_t)pmemN);
  printf("\n");
  free(pmem1);
  free(pmem2);
  free(pmem3);
  free(pmem4);
  free(pmem5);
  free(pmem6);
  printf("Successfully freed all the memory\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1050 <mkPmem@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
call   1050 <mkPmem@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe60(%rip),%rdi
call   1050 <mkPmem@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe38(%rip),%rdi
call   1050 <mkPmem@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe11(%rip),%rdi
call   1050 <mkPmem@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,%esi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdeb(%rip),%rdi
call   1050 <mkPmem@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %eax,%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdce(%rip),%rdi
call   1050 <mkPmem@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %eax,%esi
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
call   1070 <mkPmem@plt>
mov    %rax,(%rsp)
lea    0xe88(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe78(%rip),%rdi
call   1070 <mkPmem@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe5c(%rip),%rdi
call   1070 <mkPmem@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe40(%rip),%rdi
call   1070 <mkPmem@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe25(%rip),%rdi
call   1070 <mkPmem@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe0c(%rip),%rdi
call   1070 <mkPmem@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xdfb(%rip),%rdi
call   1070 <mkPmem@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xdc4(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"test0.txt\00"
@.str.1 = [13 x i8] c"Pmem is: %d\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [10 x i8] c"test5.txt\00"
@.str.4 = [10 x i8] c"test6.txt\00"
@.str.5 = [11 x i8] c"test23.txt\00"
@.str.6 = [12 x i8] c"test100.txt\00"
@.str.7 = [21 x i8] c"basicprogramtest.txt\00"
@.str.8 = [28 x i8] c"this file does not exist :(\00"
@.str.9 = [35 x i8] c"Successfully freed all the memory\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i8* @mkPmem(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = ptrtoint i8* %14 to i64
%16 = trunc i64 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = call i8* @mkPmem(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = ptrtoint i8* %20 to i64
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = call i8* @mkPmem(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i8* %25, i8** %8
%26 = load i8*, i8** %8
%27 = ptrtoint i8* %26 to i64
%28 = trunc i64 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = call i8* @mkPmem(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
store i8* %31, i8** %9
%32 = load i8*, i8** %9
%33 = ptrtoint i8* %32 to i64
%34 = trunc i64 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = call i8* @mkPmem(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
store i8* %37, i8** %10
%38 = load i8*, i8** %10
%39 = ptrtoint i8* %38 to i64
%40 = trunc i64 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%43 = call i8* @mkPmem(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
store i8* %43, i8** %11
%44 = load i8*, i8** %11
%45 = ptrtoint i8* %44 to i64
%46 = trunc i64 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%49 = call i8* @mkPmem(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
store i8* %49, i8** %12
%50 = load i8*, i8** %12
%51 = ptrtoint i8* %50 to i64
%52 = trunc i64 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%55 = load i8*, i8** %6
%56 = call i32 @free(i8* %55)
%57 = load i8*, i8** %7
%58 = call i32 @free(i8* %57)
%59 = load i8*, i8** %8
%60 = call i32 @free(i8* %59)
%61 = load i8*, i8** %9
%62 = call i32 @free(i8* %61)
%63 = load i8*, i8** %10
%64 = call i32 @free(i8* %63)
%65 = load i8*, i8** %11
%66 = call i32 @free(i8* %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%68 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"test0.txt\00"
@.str.1 = [13 x i8] c"Pmem is: %d\0A\00"
@.str.3 = [10 x i8] c"test5.txt\00"
@.str.4 = [10 x i8] c"test6.txt\00"
@.str.5 = [11 x i8] c"test23.txt\00"
@.str.6 = [12 x i8] c"test100.txt\00"
@.str.7 = [21 x i8] c"basicprogramtest.txt\00"
@.str.8 = [28 x i8] c"this file does not exist :(\00"
@str = [34 x i8] c"Successfully freed all the memory\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @mkPmem(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = ptrtoint i8* %3 to i64
%5 = trunc i64 %4 to i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @putchar(i32 10)
%8 = tail call i8* @mkPmem(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%9 = ptrtoint i8* %8 to i64
%10 = trunc i64 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = tail call i32 @putchar(i32 10)
%13 = tail call i8* @mkPmem(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%14 = ptrtoint i8* %13 to i64
%15 = trunc i64 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 @putchar(i32 10)
%18 = tail call i8* @mkPmem(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%19 = ptrtoint i8* %18 to i64
%20 = trunc i64 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = tail call i32 @putchar(i32 10)
%23 = tail call i8* @mkPmem(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%24 = ptrtoint i8* %23 to i64
%25 = trunc i64 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = tail call i32 @putchar(i32 10)
%28 = tail call i8* @mkPmem(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%29 = ptrtoint i8* %28 to i64
%30 = trunc i64 %29 to i32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = tail call i32 @putchar(i32 10)
%33 = tail call i8* @mkPmem(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%34 = ptrtoint i8* %33 to i64
%35 = trunc i64 %34 to i32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = tail call i32 @putchar(i32 10)
%38 = tail call i32 @free(i8* %3)
%39 = tail call i32 @free(i8* %8)
%40 = tail call i32 @free(i8* %13)
%41 = tail call i32 @free(i8* %18)
%42 = tail call i32 @free(i8* %23)
%43 = tail call i32 @free(i8* %28)
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%45 = tail call i32 @exit(i32 0)
unreachable
}