#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*/ func(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
main() {
  int *p;
  p = malloc(sizeof(*p));
  *p = 321;
  p = malloc(sizeof(*p));
  *p = 444;
  int *z;
  z = malloc(sizeof(*z));
  *z = 123;
  printf("*z= %d\n", *z);
  z = malloc(sizeof(*z));
  *z = 555;
  printf("*z= %d\n", *z);
  func(z);
  printf("*z= %d\n", *z);
}


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   $0x141,(%rax)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x1bc,(%rax)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x7b,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x22b,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <func@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
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    $0x4,%edi
call   1050 <malloc@plt>
mov    $0x4,%edi
call   1050 <malloc@plt>
lea    0xea7(%rip),%r14
mov    %r14,%rdi
mov    $0x7b,%esi
call   1030 <printf@plt>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movl   $0x22b,(%rax)
mov    %r14,%rdi
mov    $0x22b,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <func@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"*z= %d\0A\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 321, i32* %4
%5 = call i32* @malloc(i32 4)
store i32* %5, i32** %1
%6 = load i32*, i32** %1
store i32 444, i32* %6
%7 = call i32* @malloc(i32 4)
store i32* %7, i32** %2
%8 = load i32*, i32** %2
store i32 123, i32* %8
%9 = load i32*, i32** %2
%10 = load i32, i32* %9
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32* @malloc(i32 4)
store i32* %12, i32** %2
%13 = load i32*, i32** %2
store i32 555, i32* %13
%14 = load i32*, i32** %2
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %2
%18 = call i32 @func(i32* %17)
%19 = load i32*, i32** %2
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"*z= %d\0A\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 4)
%2 = tail call i32* @malloc(i32 4)
%3 = tail call i32* @malloc(i32 4)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 123)
%5 = tail call i32* @malloc(i32 4)
store i32 555, i32* %5
%6 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 555)
%7 = tail call i32 @func(i32* %5)
%8 = load i32, i32* %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8)
ret i32 0
}