#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(struct foo *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  struct foo {
    int num;
  };
  struct foo *pfoo;
  pfoo = (struct foo *)malloc(sizeof(struct foo));
  pfoo->num = 2323;
  printf("%p=%d\n", pfoo, pfoo->num);
  free(pfoo);
  printf("%d\n", pfoo->num);
  struct foo bar, *pbar;
  bar.num = 33;
  pbar = &bar;
  printf("%d\n", pbar->num);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x913,(%rax)
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe9f(%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    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x21,-0x10(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

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

LLVM IR (-O2):
%struct.foo = type { i32 }
%struct.foo.0 = type opaque
@.str = [7 x i8] c"%p=%d\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to %struct.foo*
%3 = getelementptr inbounds %struct.foo, %struct.foo* %2, i64 0, i32 0
store i32 2323, i32* %3
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %struct.foo* %2, i32 2323)
%5 = inttoptr i64 %1 to %struct.foo.0*
%6 = tail call i32 @free(%struct.foo.0* %5)
%7 = load i32, i32* %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 33)
ret i32 0
}