#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 main(void) {
  int *p = malloc(sizeof(int));
  printf("O endereço alocado foi: %p\n", p);
  *p = 1500;
  printf("Valor: %i\n", *p);
  free(p);
  printf("Valor: %i\n", *p);
}


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),%rsi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movl   $0x5dc,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xeb8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x5dc,(%rbx)
lea    0xebe(%rip),%r14
mov    %r14,%rdi
mov    $0x5dc,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"O endere\C3\A7o alocado foi: %p\0A\00"
@.str.1 = [11 x i8] c"Valor: %i\0A\00"
define void @main() {
%1 = alloca i32*
%2 = call i32* @malloc(i32 4)
store i32* %2, i32** %1
%3 = load i32*, i32** %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32* %3)
%5 = load i32*, i32** %1
store i32 1500, i32* %5
%6 = load i32*, i32** %1
%7 = load i32, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32*, i32** %1
%10 = call i32 @free(i32* %9)
%11 = load i32*, i32** %1
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"O endere\C3\A7o alocado foi: %p\0A\00"
@.str.1 = [11 x i8] c"Valor: %i\0A\00"
define void @main() {
%1 = tail call i32* @malloc(i32 4)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32* %1)
store i32 1500, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 1500)
%4 = tail call i32 @free(i32* %1)
%5 = load i32, i32* %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %5)
ret void
}