#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*/ free(char *);
int /*<<< orphan*/ freeMemory(char **);
int getpid();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char *buf = NULL;
  printf("My process ID is %d\n", getpid());
  buf = (char *)malloc(10000);
  strcpy(buf, "aljgelgje");
  freeMemory(&buf);
  if (buf == NULL) {
    printf("Free memory success in other scope.\n");
  } else {
    printf("failure!\n");
    free(buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x2710,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x10(%rbp),%rdi
call   1050 <freeMemory@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11d3 <main+0x73>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    11ea <main+0x8a>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xe81(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x2710,%edi
call   1090 <malloc@plt>
mov    %rax,(%rsp)
lea    0xe78(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %rsp,%rdi
call   1060 <freeMemory@plt>
cmpq   $0x0,(%rsp)
je     11cb <main+0x5b>
lea    0xe64(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
jmp    11d7 <main+0x67>
lea    0xe56(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"My process ID is %d\0A\00"
@.str.1 = [10 x i8] c"aljgelgje\00"
@.str.2 = [37 x i8] c"Free memory success in other scope.\0A\00"
@.str.3 = [10 x i8] c"failure!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
%3 = call i32 (...) @getpid()
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i64 @malloc(i32 10000)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @freeMemory(i8** %2)
%10 = load i8*, i8** %2
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %18
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%16 = load i8*, i8** %2
%17 = call i32 @free(i8* %16)
br label %18
18: ; preds = %14, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"My process ID is %d\0A\00"
@.str.1 = [10 x i8] c"aljgelgje\00"
@str = [9 x i8] c"failure!\00"
@str.4 = [36 x i8] c"Free memory success in other scope.\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i64 @malloc(i32 10000)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %1
%7 = tail call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @freeMemory(i8** %1)
%9 = load i8*, i8** %1
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.4, i64 0, i64 0))
br label %17
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%15 = load i8*, i8** %1
%16 = call i32 @free(i8* %15)
br label %17
17: ; preds = %13, %11
ret i32 0
}