#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(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
void fun(void) {
  char *p = (char *)malloc(69);
  printf("%d-%d-%d-%d\n", p[0], p[1], p[2], p[3]);
  p[0] = 1;
  p[1] = 2;
  p[2] = 3;
  p[3] = 4;
  printf("%#x\n", (int)p);
  free(p);
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x45,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edx
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%ecx
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%r8d
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movb   $0x1,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x2,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x3,0x2(%rax)
mov    -0x8(%rbp),%rax
movb   $0x4,0x3(%rax)
mov    -0x8(%rbp),%rax
mov    %eax,%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbx
mov    $0x45,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movsbl (%rax),%esi
movsbl 0x1(%rax),%edx
movsbl 0x2(%rax),%ecx
movsbl 0x3(%rax),%r8d
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x4030201,(%rbx)
lea    0xea4(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%d-%d-%d-%d\0A\00"
@.str.1 = [5 x i8] c"%#x\0A\00"
define void @fun() {
%1 = alloca i8*
%2 = call i64 @malloc(i32 69)
%3 = inttoptr i64 %2 to i8*
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = load i8*, i8** %1
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = load i8*, i8** %1
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = load i8*, i8** %1
%17 = getelementptr inbounds i8, i8* %16, i64 3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %11, i32 %15, i32 %19)
%21 = load i8*, i8** %1
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 1, i8* %22
%23 = load i8*, i8** %1
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8 2, i8* %24
%25 = load i8*, i8** %1
%26 = getelementptr inbounds i8, i8* %25, i64 2
store i8 3, i8* %26
%27 = load i8*, i8** %1
%28 = getelementptr inbounds i8, i8* %27, i64 3
store i8 4, i8* %28
%29 = load i8*, i8** %1
%30 = ptrtoint i8* %29 to i32
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i8*, i8** %1
%33 = call i32 @free(i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d-%d-%d-%d\0A\00"
@.str.1 = [5 x i8] c"%#x\0A\00"
define void @fun() {
%1 = tail call i64 @malloc(i32 69)
%2 = inttoptr i64 %1 to i8*
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = getelementptr inbounds i8, i8* %2, i64 2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = getelementptr inbounds i8, i8* %2, i64 3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %7, i32 %10, i32 %13)
store i8 1, i8* %2
store i8 2, i8* %5
store i8 3, i8* %8
store i8 4, i8* %11
%15 = trunc i64 %1 to i32
%16 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = tail call i32 @free(i8* %2)
ret void
}