#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*/ printf(char *, unsigned long, unsigned long);
void myfunc(unsigned long addr, unsigned long size) {
  unsigned long *buffer = (unsigned long *)addr;
  int i;
  printf("\nDump address at <%#08llx> of %lu entries\n\n", addr, size);
  for (i = 0; i < size * 2; i = i + 2) {
    printf("\tFound vpage <%#016llx> accessed %u times\n", buffer[i],
           buffer[i + 1]);
  }
}


x86 assembly (clang, -O0):
<myfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x1,%rcx
cmp    %rcx,%rax
jae    118f <myfunc+0x7f>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1143 <myfunc+0x33>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myfunc>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xedb(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
add    %r14,%r14
je     115a <myfunc+0x4a>
xor    %ebx,%ebx
lea    0xeee(%rip),%r15
xchg   %ax,%ax
mov    (%r12,%rbx,8),%rsi
mov    0x8(%r12,%rbx,8),%rdx
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x2,%rbx
cmp    %rbx,%r14
ja     1140 <myfunc+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"\0ADump address at <%llx> of %lu entries\0A\0A\00"
@.str.1 = [43 x i8] c"\09Found vpage <%llx> accessed %u times\0A\00"
define void @myfunc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i32
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %3
%8 = inttoptr i64 %7 to i64*
store i64* %8, i64** %5
%9 = load i64, i64* %3
%10 = load i64, i64* %4
%11 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %9, i64 %10)
store i32 0, i32* %6
br label %12
12: ; preds = %31, %2
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = load i64, i64* %4
%16 = mul i64 %15, 2
%17 = icmp ult i64 %14, %16
br i1 %17, label %18, label %34
18: ; preds = %12
%19 = load i64*, i64** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i64, i64* %19, i64 %21
%23 = load i64, i64* %22
%24 = load i64*, i64** %5
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i64, i64* %24, i64 %27
%29 = load i64, i64* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i64 %23, i64 %29)
br label %31
31: ; preds = %18
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 2
store i32 %33, i32* %6
br label %12
34: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [44 x i8] c"\0ADump address at <%llx> of %lu entries\0A\0A\00"
@.str.1 = [43 x i8] c"\09Found vpage <%llx> accessed %u times\0A\00"
define void @myfunc(i64 %0, i64 %1) {
%3 = inttoptr i64 %0 to i64*
%4 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %1)
%5 = shl i64 %1, 1
%6 = icmp eq i64 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %15, %7 ], [ 0, %2 ]
%9 = getelementptr inbounds i64, i64* %3, i64 %8
%10 = load i64, i64* %9
%11 = or i64 %8, 1
%12 = getelementptr inbounds i64, i64* %3, i64 %11
%13 = load i64, i64* %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i64 %10, i64 %13)
%15 = add nuw i64 %8, 2
%16 = icmp ugt i64 %5, %15
br i1 %16, label %7, label %17
17: ; preds = %7, %2
ret void
}