#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void usage() {
  fprintf(stderr, " rndm_walker requires 6 arguments and has a seventh "
                  "optional argument\n");
  fprintf(stderr, " -iN  -i signifies intialization N indicates the core on "
                  "which the buffer should be initialized\n");
  fprintf(stderr, " -rM  -r signifies run M indicates which core the pointer "
                  "walker should be executed on\n");
  fprintf(stderr, " -lN  -l signifies lines N indicates the number of lines "
                  "used in the pointer chase loop, this size controls in which "
                  "level of cache/memory the buffer will reside\n");
  fprintf(stderr, " -sN  -s signifies stride N indicates the number of pages "
                  "in the stride. thus the stride = N*page_size + 64. N should "
                  "be 0 to avoid DTLB effects\n");
  fprintf(stderr, " -SN  -S signifies segments N indicates the number of "
                  "segments that the buffer will be divided into.\n");
  fprintf(stderr, "         The number of segments must be greater than the "
                  "number of memory access streams the HW prefetcher can track "
                  "for the randomization to defeat the HW prefetcher.\n");
  fprintf(stderr, "          if it is set to 1 then the linked list will walk "
                  "through the buffer in order. \n");
  fprintf(
      stderr,
      "          This will yield an open page latency if the HW prefetchers "
      "are completely disabled and the buffer is much larger than the LLC.\n");
  fprintf(stderr, "          if it is set to a reasonably large value (32/64)  "
                  "then the linked list will walk through the segments of the "
                  "buffer in randomized order.\n");
  fprintf(
      stderr,
      "          This will yield a closed dram latency if the HW prefetchers "
      "are enabled or disabled and the buffer is much larger than the LLC.\n");
  fprintf(stderr,
          "          The line count must be a multiple of this value\n");
  fprintf(stderr, " -mN  -m signifies multiplier N indicates the multiplying "
                  "factor applied to the outer loop tripcount. \n");
  fprintf(stderr, "           By default a total of 1.024 Billion iterations "
                  "of the cacheline walk are executed. N >= 1\n");
  fprintf(stderr, " -L   -L signifies that mmap should be invoked with "
                  "HUGE_PAGE option. For this to work the machine must have "
                  "been booted with a hugepages option\n");
  fprintf(stderr, "           locking down some number of contiguous memory "
                  "for allocation as huge pages. This option changes the "
                  "page_size used by the stride evaluation\n");
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
lea    0xf0e(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
lea    0xf5a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xf9d(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0x102b(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0x10a8(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0x10f9(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0x118d(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0x11d2(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0x1247(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    0x12c6(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0x133c(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0x1362(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    0x13b5(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0x1406(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0x1483(%rip),%rsi
call   1030 <fprintf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rbx
mov    0x2ec8(%rip),%rbx
mov    (%rbx),%edi
lea    0xedf(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf18(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf6b(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xfb5(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x104a(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x10ce(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1126(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x11c1(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x120d(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1289(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x130f(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x138c(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x13b9(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1413(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x146b(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x14ef(%rip),%rsi
pop    %rbx
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [71 x i8] c" rndm_walker requires 6 arguments and has a seventh optional argument\0A\00"
@.str.1 = [97 x i8] c" -iN -i signifies intialization N indicates the core on which the buffer should be initialized\0A\00"
@.str.2 = [88 x i8] c" -rM -r signifies run M indicates which core the pointer walker should be executed on\0A\00"
@.str.3 = [163 x i8] c" -lN -l signifies lines N indicates the number of lines used in the pointer chase loop, this size controls in which level of cache/memory the buffer will reside\0A\00"
@.str.4 = [146 x i8] c" -sN -s signifies stride N indicates the number of pages in the stride. thus the stride = N*page_size + 64. N should be 0 to avoid DTLB effects\0A\00"
@.str.5 = [102 x i8] c" -SN -S signifies segments N indicates the number of segments that the buffer will be divided into.\0A\00"
@.str.6 = [169 x i8] c" The number of segments must be greater than the number of memory access streams the HW prefetcher can track for the randomization to defeat the HW prefetcher.\0A\00"
@.str.7 = [90 x i8] c" if it is set to 1 then the linked list will walk through the buffer in order. \0A\00"
@.str.8 = [138 x i8] c" This will yield an open page latency if the HW prefetchers are completely disabled and the buffer is much larger than the LLC.\0A\00"
@.str.9 = [148 x i8] c" if it is set to a reasonably large value (32/64) then the linked list will walk through the segments of the buffer in randomized order.\0A\00"
@.str.10 = [139 x i8] c" This will yield a closed dram latency if the HW prefetchers are enabled or disabled and the buffer is much larger than the LLC.\0A\00"
@.str.11 = [59 x i8] c" The line count must be a multiple of this value\0A\00"
@.str.12 = [104 x i8] c" -mN -m signifies multiplier N indicates the multiplying factor applied to the outer loop tripcount. \0A\00"
@.str.13 = [102 x i8] c" By default a total of 1.024 Billion iterations of the cacheline walk are executed. N >= 1\0A\00"
@.str.14 = [146 x i8] c" -L -L signifies that mmap should be invoked with HUGE_PAGE option. For this to work the machine must have been booted with a hugepages option\0A\00"
@.str.15 = [152 x i8] c" locking down some number of contiguous memory for allocation as huge pages. This option changes the page_size used by the stride evaluation\0A\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stderr
%4 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.5, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str.6, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.7, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.8, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.9, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.10, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.11, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.12, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.13, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.14, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.15, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [71 x i8] c" rndm_walker requires 6 arguments and has a seventh optional argument\0A\00"
@.str.1 = [97 x i8] c" -iN -i signifies intialization N indicates the core on which the buffer should be initialized\0A\00"
@.str.2 = [88 x i8] c" -rM -r signifies run M indicates which core the pointer walker should be executed on\0A\00"
@.str.3 = [163 x i8] c" -lN -l signifies lines N indicates the number of lines used in the pointer chase loop, this size controls in which level of cache/memory the buffer will reside\0A\00"
@.str.4 = [146 x i8] c" -sN -s signifies stride N indicates the number of pages in the stride. thus the stride = N*page_size + 64. N should be 0 to avoid DTLB effects\0A\00"
@.str.5 = [102 x i8] c" -SN -S signifies segments N indicates the number of segments that the buffer will be divided into.\0A\00"
@.str.6 = [169 x i8] c" The number of segments must be greater than the number of memory access streams the HW prefetcher can track for the randomization to defeat the HW prefetcher.\0A\00"
@.str.7 = [90 x i8] c" if it is set to 1 then the linked list will walk through the buffer in order. \0A\00"
@.str.8 = [138 x i8] c" This will yield an open page latency if the HW prefetchers are completely disabled and the buffer is much larger than the LLC.\0A\00"
@.str.9 = [148 x i8] c" if it is set to a reasonably large value (32/64) then the linked list will walk through the segments of the buffer in randomized order.\0A\00"
@.str.10 = [139 x i8] c" This will yield a closed dram latency if the HW prefetchers are enabled or disabled and the buffer is much larger than the LLC.\0A\00"
@.str.11 = [59 x i8] c" The line count must be a multiple of this value\0A\00"
@.str.12 = [104 x i8] c" -mN -m signifies multiplier N indicates the multiplying factor applied to the outer loop tripcount. \0A\00"
@.str.13 = [102 x i8] c" By default a total of 1.024 Billion iterations of the cacheline walk are executed. N >= 1\0A\00"
@.str.14 = [146 x i8] c" -L -L signifies that mmap should be invoked with HUGE_PAGE option. For this to work the machine must have been booted with a hugepages option\0A\00"
@.str.15 = [152 x i8] c" locking down some number of contiguous memory for allocation as huge pages. This option changes the page_size used by the stride evaluation\0A\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.5, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str.6, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.7, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.8, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.9, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.10, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.11, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.12, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.13, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.14, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([152 x i8], [152 x i8]* @.str.15, i64 0, i64 0))
ret void
}