#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(void *);
int /*<<< orphan*/ getchar();
void *malloc(int);
int /*<<< orphan*/ printf(char *, void *);
int main(int argc, char *argv[]) {
  void *ptr1 = malloc(64);
  void *ptr2 = malloc(64);
  printf("ptr1 = %p\n", ptr1);
  printf("ptr2 = %p\n", ptr1);
  getchar();
  free(ptr1);
  getchar();
  free(ptr1);
  getchar();
  free(ptr2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"ptr1 = %p\0A\00"
@.str.1 = [11 x i8] c"ptr2 = %p\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i8* @malloc(i32 64)
store i8* %7, i8** %5
%8 = call i8* @malloc(i32 64)
store i8* %8, i8** %6
%9 = load i8*, i8** %5
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %5
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i32 (...) @getchar()
%14 = load i8*, i8** %5
%15 = call i32 @free(i8* %14)
%16 = call i32 (...) @getchar()
%17 = load i8*, i8** %5
%18 = call i32 @free(i8* %17)
%19 = call i32 (...) @getchar()
%20 = load i8*, i8** %6
%21 = call i32 @free(i8* %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"ptr1 = %p\0A\00"
@.str.1 = [11 x i8] c"ptr2 = %p\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%4 = tail call dereferenceable_or_null(64) i8* @malloc(i32 64)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = tail call i32 (...) @getchar()
%8 = tail call i32 @free(i8* %3)
%9 = tail call i32 (...) @getchar()
%10 = tail call i32 @free(i8* %3)
%11 = tail call i32 (...) @getchar()
%12 = tail call i32 @free(i8* %4)
ret i32 0
}