#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 read M indicates which core the reader "
                  "thread should be executed on\n");
  fprintf(stderr, " -wM  -w signifies \"writer\" indicates which core the "
                  "\"writer\" thread should be executed on\n");
  fprintf(stderr, "      the -s option will change this thread to only read "
                  "the lines without modifying them\n");
  fprintf(stderr, " -LN  -L signifies lines, N indicates the number of lines "
                  "used in the full buffer\n");
  fprintf(stderr, "     thus the size controls in which level of cache/memory "
                  "the full buffer will reside\n");
  fprintf(stderr, " -ln  -l signifies lines, n indicates the number of lines "
                  "used in the pointer chase loop\n");
  fprintf(stderr,
          "      this size controls in which level of cache/memory the partial "
          "buffer, which is exchanged between the threads, will reside\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, " -s    indicates that the lines accessed as \"shared\" and "
                  "thus the w thread will not modify the line\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    0xfe4(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0x102a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0x1068(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0x10ab(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0x10f0(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0x115c(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    0x11ad(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0x1241(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0x1286(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    0x12fb(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0x137a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0x13f0(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0x1416(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
lea    0x1469(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
lea    0x14ba(%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    0x1003(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1050(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1095(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x10df(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x112b(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x119e(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x11f6(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1291(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x12dd(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1359(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x13df(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x145c(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1489(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x14e3(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x153b(%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 read M indicates which core the reader thread should be executed on\0A\00"
@.str.3 = [92 x i8] c" -wM -w signifies \22writer\22 indicates which core the \22writer\22 thread should be executed on\0A\00"
@.str.4 = [91 x i8] c" the -s option will change this thread to only read the lines without modifying them\0A\00"
@.str.5 = [83 x i8] c" -LN -L signifies lines, N indicates the number of lines used in the full buffer\0A\00"
@.str.6 = [88 x i8] c" thus the size controls in which level of cache/memory the full buffer will reside\0A\00"
@.str.7 = [90 x i8] c" -ln -l signifies lines, n indicates the number of lines used in the pointer chase loop\0A\00"
@.str.8 = [129 x i8] c" this size controls in which level of cache/memory the partial buffer, which is exchanged between the threads, will reside\0A\00"
@.str.9 = [102 x i8] c" -SN -S signifies segments N indicates the number of segments that the buffer will be divided into.\0A\00"
@.str.10 = [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.11 = [90 x i8] c" if it is set to 1 then the linked list will walk through the buffer in order. \0A\00"
@.str.12 = [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.13 = [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.14 = [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.15 = [59 x i8] c" The line count must be a multiple of this value\0A\00"
@.str.16 = [104 x i8] c" -mN -m signifies multiplier N indicates the multiplying factor applied to the outer loop tripcount. \0A\00"
@.str.17 = [102 x i8] c" By default a total of 1.024 Billion iterations of the cacheline walk are executed. N >= 1\0A\00"
@.str.18 = [101 x i8] c" -s indicates that the lines accessed as \22shared\22 and thus the w thread will not modify the line\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 ([92 x i8], [92 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.5, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([88 x i8], [88 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 ([129 x i8], [129 x i8]* @.str.8, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.9, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str.10, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.11, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.12, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.13, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.14, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.15, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.16, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.17, i64 0, i64 0))
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.18, 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 read M indicates which core the reader thread should be executed on\0A\00"
@.str.3 = [92 x i8] c" -wM -w signifies \22writer\22 indicates which core the \22writer\22 thread should be executed on\0A\00"
@.str.4 = [91 x i8] c" the -s option will change this thread to only read the lines without modifying them\0A\00"
@.str.5 = [83 x i8] c" -LN -L signifies lines, N indicates the number of lines used in the full buffer\0A\00"
@.str.6 = [88 x i8] c" thus the size controls in which level of cache/memory the full buffer will reside\0A\00"
@.str.7 = [90 x i8] c" -ln -l signifies lines, n indicates the number of lines used in the pointer chase loop\0A\00"
@.str.8 = [129 x i8] c" this size controls in which level of cache/memory the partial buffer, which is exchanged between the threads, will reside\0A\00"
@.str.9 = [102 x i8] c" -SN -S signifies segments N indicates the number of segments that the buffer will be divided into.\0A\00"
@.str.10 = [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.11 = [90 x i8] c" if it is set to 1 then the linked list will walk through the buffer in order. \0A\00"
@.str.12 = [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.13 = [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.14 = [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.15 = [59 x i8] c" The line count must be a multiple of this value\0A\00"
@.str.16 = [104 x i8] c" -mN -m signifies multiplier N indicates the multiplying factor applied to the outer loop tripcount. \0A\00"
@.str.17 = [102 x i8] c" By default a total of 1.024 Billion iterations of the cacheline walk are executed. N >= 1\0A\00"
@.str.18 = [101 x i8] c" -s indicates that the lines accessed as \22shared\22 and thus the w thread will not modify the line\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 ([92 x i8], [92 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.5, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([88 x i8], [88 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 ([129 x i8], [129 x i8]* @.str.8, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.9, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str.10, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.11, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.12, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.13, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.14, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.15, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.16, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.17, i64 0, i64 0))
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.18, i64 0, i64 0))
ret void
}