#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(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, void *, void *, int, int);
int main(void) {
  int *ponteiro1 = malloc(sizeof(int));
  *ponteiro1 = 5;
  int *ponteiro2 = ponteiro1;
  printf("%p == %p, %d == %d\n", (void *)ponteiro1, (void *)ponteiro2,
         *ponteiro1, *ponteiro2);
  free(ponteiro2);
  printf("%p == %p, %d == %d", (void *)ponteiro1, (void *)ponteiro2, *ponteiro1,
         *ponteiro2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movl   $0x5,(%rax)
lea    0xeb5(%rip),%rdi
mov    %rax,%rsi
mov    %rax,%rdx
mov    $0x5,%ecx
mov    $0x5,%r8d
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%rbx),%ecx
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
mov    %ecx,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"%p == %p, %d == %d\0A\00"
@.str.1 = [19 x i8] c"%p == %p, %d == %d\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 4)
store i32 5, i32* %1
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %2, i32 5, i32 5)
%4 = tail call i32 @free(i32* %1)
%5 = load i32, i32* %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %2, i32 %5, i32 %5)
ret i32 0
}