#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*/ mm_free(int *);
scalar_t__ mm_malloc(int);
int /*<<< orphan*/ printf(char *, int *, int);
int main() {
  int i = 0;
  int *p = (int *)mm_malloc(10 * sizeof(int));
  for (i = 0; i < 10; ++i) {
    p[i] = i + 1;
  }
  for (i = 0; i < 10; ++i) {
    printf("Addr : Val = 0x%p : %d\n", p + i, p[i]);
  }
  mm_free(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x28,%edi
call   1030 <mm_malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1184 <main+0x54>
mov    -0x8(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <main+0x2b>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11c9 <main+0x99>
mov    -0x10(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118b <main+0x5b>
mov    -0x10(%rbp),%rdi
call   1050 <mm_free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x28,%edi
call   1030 <mm_malloc@plt>
mov    %rax,%rbx
lea    0x4(%rax),%r14
lea    0x8(%rax),%rbp
lea    0xc(%rax),%r13
movaps 0xea2(%rip),%xmm0
movups %xmm0,(%rax)
lea    0x10(%rax),%r12
add    $0x14,%rax
mov    %rax,(%rsp)
lea    0x18(%rbx),%rax
mov    %rax,0x8(%rsp)
lea    0x1c(%rbx),%rax
mov    %rax,0x10(%rsp)
movaps 0xe8a(%rip),%xmm0
movups %xmm0,0x10(%rbx)
lea    0x20(%rbx),%rax
mov    %rax,0x18(%rsp)
movabs $0xa00000009,%rax
mov    %rax,0x20(%rbx)
lea    0x24(%rbx),%rax
mov    %rax,0x20(%rsp)
lea    0xe6f(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <printf@plt>
mov    0x4(%rbx),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    0x8(%rbx),%edx
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    0xc(%rbx),%edx
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
mov    0x10(%rbx),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
mov    0x14(%rbx),%edx
mov    %r15,%rdi
mov    (%rsp),%rsi
call   1040 <printf@plt>
mov    0x18(%rbx),%edx
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
call   1040 <printf@plt>
mov    0x1c(%rbx),%edx
mov    %r15,%rdi
mov    0x10(%rsp),%rsi
call   1040 <printf@plt>
mov    0x20(%rbx),%edx
mov    %r15,%rdi
mov    0x18(%rsp),%rsi
call   1040 <printf@plt>
mov    0x24(%rbx),%edx
mov    %r15,%rdi
mov    0x20(%rsp),%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <mm_free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Addr : Val = 0x%p : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i64 @mm_malloc(i32 40)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %3
store i32 0, i32* %2
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = load i32*, i32** %3
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
store i32 %11, i32* %15
br label %16
16: ; preds = %9
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %6
19: ; preds = %6
store i32 0, i32* %2
br label %20
20: ; preds = %34, %19
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %37
23: ; preds = %20
%24 = load i32*, i32** %3
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32*, i32** %3
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %27, i32 %32)
br label %34
34: ; preds = %23
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %20
37: ; preds = %20
%38 = load i32*, i32** %3
%39 = call i32 @mm_free(i32* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Addr : Val = 0x%p : %d\0A\00"
define i32 @main() {
%1 = tail call i64 @mm_malloc(i32 40)
%2 = inttoptr i64 %1 to i32*
%3 = getelementptr inbounds i32, i32* %2, i64 1
%4 = getelementptr inbounds i32, i32* %2, i64 2
%5 = getelementptr inbounds i32, i32* %2, i64 3
%6 = inttoptr i64 %1 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %2, i64 4
%8 = getelementptr inbounds i32, i32* %2, i64 5
%9 = getelementptr inbounds i32, i32* %2, i64 6
%10 = getelementptr inbounds i32, i32* %2, i64 7
%11 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, <4 x i32>* %11
%12 = getelementptr inbounds i32, i32* %2, i64 8
store i32 9, i32* %12
%13 = getelementptr inbounds i32, i32* %2, i64 9
store i32 10, i32* %13
%14 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %2, i32 1)
%15 = load i32, i32* %3
%16 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %3, i32 %15)
%17 = load i32, i32* %4
%18 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %4, i32 %17)
%19 = load i32, i32* %5
%20 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %5, i32 %19)
%21 = load i32, i32* %7
%22 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %7, i32 %21)
%23 = load i32, i32* %8
%24 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %8, i32 %23)
%25 = load i32, i32* %9
%26 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %9, i32 %25)
%27 = load i32, i32* %10
%28 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %10, i32 %27)
%29 = load i32, i32* %12
%30 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %12, i32 %29)
%31 = load i32, i32* %13
%32 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %13, i32 %31)
%33 = tail call i32 @mm_free(i32* %2)
ret i32 0
}