#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ m5_dump_stats(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ m5_reset_stats(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  printf("test program start\n");
  int *p = (int *)malloc(sizeof(int) * 16 * 1024);
  int i = 0;
  if (0) {
    printf("Virtual address pointer vaddr: %lu\n", p);
    exit(0);
  }
  m5_reset_stats(0, 0);
  for (i = 0; i < 16 * 1024; i++) {
    p[i] = i;
  }
  m5_dump_stats(0, 0);
  printf("test program finish\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x10000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1050 <m5_reset_stats@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4000,-0x1c(%rbp)
jge    11b2 <main+0x72>
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1189 <main+0x49>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <m5_dump_stats@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xf45(%rip),%rdi
call   1040 <puts@plt>
mov    $0x10000,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xor    %edi,%edi
xor    %esi,%esi
call   1050 <m5_reset_stats@plt>
movdqa 0xe90(%rip),%xmm0
movdqa 0xe97(%rip),%xmm8
movdqa 0xe9e(%rip),%xmm9
movdqa 0xea5(%rip),%xmm10
movdqa 0xead(%rip),%xmm4
movdqa 0xeb5(%rip),%xmm5
movdqa 0xebd(%rip),%xmm6
movdqa 0xec5(%rip),%xmm7
movdqa 0xecd(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqu %xmm0,(%r14,%rbx,4)
movdqu %xmm2,0x10(%r14,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqu %xmm2,0x20(%r14,%rbx,4)
movdqu %xmm3,0x30(%r14,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqu %xmm2,0x40(%r14,%rbx,4)
movdqu %xmm3,0x50(%r14,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqu %xmm2,0x60(%r14,%rbx,4)
movdqu %xmm3,0x70(%r14,%rbx,4)
add    $0x20,%rbx
paddd  %xmm1,%xmm0
cmp    $0x4000,%rbx
jne    11c0 <main+0x80>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <m5_dump_stats@plt>
lea    0xe4c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"test program start\0A\00"
@.str.1 = [21 x i8] c"test program finish\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @malloc(i32 65536)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %6
store i32 0, i32* %7
%11 = call i32 @m5_reset_stats(i32 0, i32 0)
store i32 0, i32* %7
br label %12
12: ; preds = %21, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 16384
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %7
%17 = load i32*, i32** %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 %16, i32* %20
br label %21
21: ; preds = %15
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %12
24: ; preds = %12
%25 = call i32 @m5_dump_stats(i32 0, i32 0)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@str = [19 x i8] c"test program start\00"
@str.2 = [20 x i8] c"test program finish\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%4 = tail call i64 @malloc(i32 65536)
%5 = inttoptr i64 %4 to i32*
%6 = tail call i32 @m5_reset_stats(i32 0, i32 0)
br label %7
7: ; preds = %7, %2
%8 = phi i64 [ 0, %2 ], [ %36, %7 ]
%9 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %2 ], [ %37, %7 ]
%10 = add <4 x i32> %9, <i32 4, i32 4, i32 4, i32 4>
%11 = getelementptr inbounds i32, i32* %5, i64 %8
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> %9, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %11, i64 4
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> %10, <4 x i32>* %14
%15 = or i64 %8, 8
%16 = add <4 x i32> %9, <i32 8, i32 8, i32 8, i32 8>
%17 = add <4 x i32> %9, <i32 12, i32 12, i32 12, i32 12>
%18 = getelementptr inbounds i32, i32* %5, i64 %15
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %19
%20 = getelementptr inbounds i32, i32* %18, i64 4
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %21
%22 = or i64 %8, 16
%23 = add <4 x i32> %9, <i32 16, i32 16, i32 16, i32 16>
%24 = add <4 x i32> %9, <i32 20, i32 20, i32 20, i32 20>
%25 = getelementptr inbounds i32, i32* %5, i64 %22
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> %23, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %25, i64 4
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> %24, <4 x i32>* %28
%29 = or i64 %8, 24
%30 = add <4 x i32> %9, <i32 24, i32 24, i32 24, i32 24>
%31 = add <4 x i32> %9, <i32 28, i32 28, i32 28, i32 28>
%32 = getelementptr inbounds i32, i32* %5, i64 %29
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %33
%34 = getelementptr inbounds i32, i32* %32, i64 4
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %35
%36 = add nuw nsw i64 %8, 32
%37 = add <4 x i32> %9, <i32 32, i32 32, i32 32, i32 32>
%38 = icmp eq i64 %36, 16384
br i1 %38, label %39, label %7
39: ; preds = %7
%40 = tail call i32 @m5_dump_stats(i32 0, i32 0)
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.2, i64 0, i64 0))
ret i32 0
}