#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 */
unsigned long long cycles_per_ms();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
unsigned long measure_latency(unsigned long long);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  unsigned long delay_tlbmiss;
  unsigned long long cpms;
  cpms = cycles_per_ms();
  printf("%-20s %6s %8s %10s %12s %24s\n", "Test Name", "Stride", "NumOps",
         "Iterations", "Time/ms", "Cycles/Iteration");
  printf("%-20s %6s %8s %10s %12s %24s\n", "---------", "------", "------",
         "----------", "-------", "----------------");
  delay_tlbmiss = measure_latency(cpms);
  printf("Report\n------\n");
  printf("Delay from TLB Miss: %lu clockcycles\n", delay_tlbmiss);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <cycles_per_ms@plt>
mov    %rax,-0x18(%rbp)
lea    0xe9f(%rip),%rdi
lea    0xeb6(%rip),%rsi
lea    0xeb9(%rip),%rdx
lea    0xeb9(%rip),%rcx
lea    0xeb9(%rip),%r8
lea    0xebd(%rip),%r9
lea    0xebe(%rip),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    0xebd(%rip),%rsi
lea    0xeb9(%rip),%rcx
lea    0xeae(%rip),%r8
lea    0xeaa(%rip),%r9
lea    0xe9a(%rip),%rax
mov    %rcx,%rdx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <measure_latency@plt>
mov    %rax,-0x10(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <cycles_per_ms@plt>
mov    %rax,%rbx
lea    0xee4(%rip),%rax
mov    %rax,(%rsp)
lea    0xe90(%rip),%r14
lea    0xea7(%rip),%rsi
lea    0xeaa(%rip),%rdx
lea    0xeaa(%rip),%rcx
lea    0xeaa(%rip),%r8
lea    0xeae(%rip),%r9
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb6(%rip),%rax
mov    %rax,(%rsp)
lea    0xeb2(%rip),%rsi
lea    0xee2(%rip),%rcx
lea    0xea3(%rip),%r8
lea    0xe9f(%rip),%r9
mov    %r14,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <measure_latency@plt>
mov    %rax,%rbx
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"%-20s %6s %8s %10s %12s %24s\0A\00"
@.str.1 = [10 x i8] c"Test Name\00"
@.str.2 = [7 x i8] c"Stride\00"
@.str.3 = [7 x i8] c"NumOps\00"
@.str.4 = [11 x i8] c"Iterations\00"
@.str.5 = [8 x i8] c"Time/ms\00"
@.str.6 = [17 x i8] c"Cycles/Iteration\00"
@.str.7 = [10 x i8] c"---------\00"
@.str.8 = [7 x i8] c"------\00"
@.str.9 = [11 x i8] c"----------\00"
@.str.10 = [8 x i8] c"-------\00"
@.str.11 = [17 x i8] c"----------------\00"
@.str.12 = [15 x i8] c"Report\0A------\0A\00"
@.str.13 = [38 x i8] c"Delay from TLB Miss: %lu clockcycles\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i64 (...) @cycles_per_ms()
store i64 %4, i64* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
%7 = load i64, i64* %3
%8 = call i64 @measure_latency(i64 %7)
store i64 %8, i64* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0))
%10 = load i64, i64* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i64 %10)
%12 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [30 x i8] c"%-20s %6s %8s %10s %12s %24s\0A\00"
@.str.1 = [10 x i8] c"Test Name\00"
@.str.2 = [7 x i8] c"Stride\00"
@.str.3 = [7 x i8] c"NumOps\00"
@.str.4 = [11 x i8] c"Iterations\00"
@.str.5 = [8 x i8] c"Time/ms\00"
@.str.6 = [17 x i8] c"Cycles/Iteration\00"
@.str.7 = [10 x i8] c"---------\00"
@.str.8 = [7 x i8] c"------\00"
@.str.9 = [11 x i8] c"----------\00"
@.str.10 = [8 x i8] c"-------\00"
@.str.11 = [17 x i8] c"----------------\00"
@.str.13 = [38 x i8] c"Delay from TLB Miss: %lu clockcycles\0A\00"
@str = [14 x i8] c"Report\0A------\00"
define i32 @main() {
%1 = tail call i64 (...) @cycles_per_ms()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
%4 = tail call i64 @measure_latency(i64 %1)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i64 %4)
%7 = tail call i32 @exit(i32 0)
unreachable
}