#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 */
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct timespec {
  int dummy;
};
typedef int /*<<< orphan*/ off_t;
typedef int /*<<< orphan*/ cpu_set_t;
typedef int /*<<< orphan*/ __pid_t;

/* Variables and functions */
int MAP_ANON;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
size_t _loc_freq();
size_t _rdtsc();
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ err(int, char *, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int getopt(int, char **, char *);
int gettimeofday(struct timeval *, int /*<<< orphan*/ *);
size_t matrix_mult(int, double *, double *, double *);
scalar_t__ mmap(int /*<<< orphan*/ *, size_t, int, int, int,
                int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int pin_cpu(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
void main(int argc, char **argv) {
  double *a, *b, *c, xx = 0.01, bw, avg_bw, best_bw = -1.0;
  char *buf1, *buf2, *buf3;
  int i, j, k, offset_a = 0, offset_b = 0, offset_c = 0, mult = 1, iter = 1,
               c_val;
  int len, mem_level, level_size[4], cpu, cpu_run, scale;
  __pid_t pid = 0;
  int cpu_setsize;
  cpu_set_t mask;
  size_t start, stop, run_time, call_start, call_stop, call_run_time,
      total_flops = 0, flops_per;
  size_t sum_run_time = 0, run_time_k = 0, init_start, init_end, init_run;
  struct timespec start_t, stop_t;
  size_t total = 0;
  struct timeval start_time, stop_time;
  int ret_int, fd = -1;
  size_t gotten_time, freq_val;
  off_t offset = 0;
  size_t buf_size;
  if (argc < 3) {
    printf("triad driver needs at least 3 arguments, cpu_init, cpu_run, "
           "cache_level, [call count multiplier  def = 1], [offset a, "
           "offset_b, offset_c  defaults = 0] \n");
    printf(" argc = %d\n", argc);
    usage();
    err(1, "bad arguments");
  }
  len = 2048;
  while ((c_val = getopt(argc, argv, "i:r:l:m:a:b:c")) != -1) {
    switch (c_val) {
    case 'i':
      cpu = atoi(optarg);
      break;
    case 'r':
      cpu_run = atoi(optarg);
      break;
    case 'm':
      mult = atoi(optarg);
      break;
    default:
      err(1, "unknown option %c", c_val);
    }
  }
  iter = iter * mult;
  if (pin_cpu(pid, cpu) == -1) {
    err(1, "failed to set affinity");
  } else {
    fprintf(stderr, " process pinned to core %d for initialization\n", cpu);
  }
  buf_size = (len + 8) * (len + 8) * 8;
  fprintf(stderr, "len = %d, buf_szie = %zd, iter = %d, mult = %d\n", len,
          buf_size, iter, mult);
  buf1 = (char *)mmap(NULL, buf_size, PROT_READ | PROT_WRITE,
                      MAP_PRIVATE | MAP_ANON, fd, offset);
  buf2 = (char *)mmap(NULL, buf_size, PROT_READ | PROT_WRITE,
                      MAP_PRIVATE | MAP_ANON, fd, offset);
  buf3 = (char *)mmap(NULL, buf_size, PROT_READ | PROT_WRITE,
                      MAP_PRIVATE | MAP_ANON, fd, offset);
  a = (double *)buf1;
  b = (double *)buf2;
  c = (double *)buf3;
  for (i = 0; i < len; i++) {
    for (k = 0; k < len; k++) {
      a[i * len + k] = 0.;
      b[i * len + k] = 1.1;
      c[i * len + k] = 1.1;
    }
  }
  if (pin_cpu(pid, cpu_run) == -1) {
    err(1, "failed to set affinity");
  } else {
    fprintf(stderr, " process pinned to core %d for triad run\n", cpu_run);
  }
  printf(" calling matrix_mult %d times with dimension len = %d\n", iter, len);
  ret_int = gettimeofday(&start_time, NULL);
  call_start = _rdtsc();
  for (i = 0; i < iter; i++) {
    start = _rdtsc();
    flops_per = matrix_mult(len, a, b, c);
    stop = _rdtsc();
    run_time = stop - start;
    xx += 0.01;
    total_flops += flops_per;
    bw = (double)(flops_per) / (double)run_time;
    if (bw > best_bw)
      best_bw = bw;
  }
  call_stop = _rdtsc();
  freq_val = _loc_freq();
  ret_int = gettimeofday(&stop_time, NULL);
  gotten_time = (size_t)(stop_time.tv_sec - start_time.tv_sec) * 1000000;
  gotten_time += (size_t)(stop_time.tv_usec - start_time.tv_usec);
  call_run_time = call_stop - call_start;
  avg_bw = (double)(total_flops) / (double)call_run_time;
  printf(" total %zd flops %d took %zd cycles/call and a total of %zd\n",
         total_flops, mem_level, run_time, call_run_time);
  printf(" run time = %zd\n", call_run_time);
  printf(" gettimeofday_run time = %zd\n", gotten_time);
  printf("frequency = %zd\n", freq_val);
  printf(" average flops/cycle = %f\n", avg_bw);
  printf(" best flops/cycle = %f\n", best_bw);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xe2e(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe19(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x1,-0x7c(%rbp)
movl   $0x1,-0x80(%rbp)
movl   $0x0,-0xb0(%rbp)
movq   $0x0,-0xf0(%rbp)
movq   $0x0,-0x100(%rbp)
movq   $0x0,-0x108(%rbp)
movq   $0x0,-0x138(%rbp)
movl   $0xffffffff,-0x160(%rbp)
ff ff ff
movl   $0x0,-0x174(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    129c <main+0xdc>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10b0 <usage@plt>
mov    $0x1,%edi
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1090 <err@plt>
movl   $0x800,-0x88(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe40(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x84(%rbp)
cmp    $0xffffffff,%eax
je     1370 <main+0x1b0>
mov    -0x84(%rbp),%eax
mov    %eax,-0x184(%rbp)
sub    $0x69,%eax
je     130a <main+0x14a>
jmp    12e2 <main+0x122>
mov    -0x184(%rbp),%eax
sub    $0x6d,%eax
je     133c <main+0x17c>
jmp    12f6 <main+0x136>
mov    -0x184(%rbp),%eax
sub    $0x72,%eax
je     1323 <main+0x163>
jmp    1352 <main+0x192>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
call   10d0 <atoi@plt>
mov    %eax,-0xa4(%rbp)
jmp    136b <main+0x1ab>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
call   10d0 <atoi@plt>
mov    %eax,-0xa8(%rbp)
jmp    136b <main+0x1ab>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
call   10d0 <atoi@plt>
mov    %eax,-0x7c(%rbp)
jmp    136b <main+0x1ab>
mov    -0x84(%rbp),%edx
mov    $0x1,%edi
lea    0xd9e(%rip),%rsi
mov    $0x0,%al
call   1090 <err@plt>
jmp    12a6 <main+0xe6>
mov    -0x80(%rbp),%eax
imul   -0x7c(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0xb0(%rbp),%edi
mov    -0xa4(%rbp),%esi
call   1060 <pin_cpu@plt>
cmp    $0xffffffff,%eax
jne    13ac <main+0x1ec>
mov    $0x1,%edi
lea    0xd74(%rip),%rsi
mov    $0x0,%al
call   1090 <err@plt>
jmp    13c9 <main+0x209>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
mov    -0xa4(%rbp),%edx
lea    0xd69(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x88(%rbp),%eax
add    $0x8,%eax
mov    -0x88(%rbp),%ecx
add    $0x8,%ecx
imul   %ecx,%eax
shl    $0x3,%eax
cltq
mov    %rax,-0x180(%rbp)
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
mov    -0x88(%rbp),%edx
mov    -0x180(%rbp),%rcx
mov    -0x80(%rbp),%r8d
mov    -0x7c(%rbp),%r9d
lea    0xd4b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x180(%rbp),%rsi
mov    0x2bcc(%rip),%rax
mov    (%rax),%edx
mov    0x2b9b(%rip),%rax
or     (%rax),%edx
mov    0x2b82(%rip),%rax
mov    (%rax),%ecx
mov    0x2b81(%rip),%rax
or     (%rax),%ecx
mov    -0x160(%rbp),%r8d
mov    -0x174(%rbp),%r9d
xor    %eax,%eax
mov    %eax,%edi
call   1030 <mmap@plt>
mov    %rax,-0x50(%rbp)
mov    -0x180(%rbp),%rsi
mov    0x2b86(%rip),%rax
mov    (%rax),%edx
mov    0x2b55(%rip),%rax
or     (%rax),%edx
mov    0x2b3c(%rip),%rax
mov    (%rax),%ecx
mov    0x2b3b(%rip),%rax
or     (%rax),%ecx
mov    -0x160(%rbp),%r8d
mov    -0x174(%rbp),%r9d
xor    %eax,%eax
mov    %eax,%edi
call   1030 <mmap@plt>
mov    %rax,-0x58(%rbp)
mov    -0x180(%rbp),%rsi
mov    0x2b40(%rip),%rax
mov    (%rax),%edx
mov    0x2b0f(%rip),%rax
or     (%rax),%edx
mov    0x2af6(%rip),%rax
mov    (%rax),%ecx
mov    0x2af5(%rip),%rax
or     (%rax),%ecx
mov    -0x160(%rbp),%r8d
mov    -0x174(%rbp),%r9d
xor    %eax,%eax
mov    %eax,%edi
call   1030 <mmap@plt>
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x88(%rbp),%eax
jge    15ab <main+0x3eb>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x88(%rbp),%eax
jge    1598 <main+0x3d8>
mov    -0x18(%rbp),%rax
mov    -0x64(%rbp),%ecx
imul   -0x88(%rbp),%ecx
add    -0x6c(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    -0x64(%rbp),%ecx
imul   -0x88(%rbp),%ecx
add    -0x6c(%rbp),%ecx
movslq %ecx,%rcx
movsd  0xaac(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x64(%rbp),%ecx
imul   -0x88(%rbp),%ecx
add    -0x6c(%rbp),%ecx
movslq %ecx,%rcx
movsd  0xa8b(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    151d <main+0x35d>
jmp    159d <main+0x3dd>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1507 <main+0x347>
mov    -0xb0(%rbp),%edi
mov    -0xa8(%rbp),%esi
call   1060 <pin_cpu@plt>
cmp    $0xffffffff,%eax
jne    15dd <main+0x41d>
mov    $0x1,%edi
lea    0xb43(%rip),%rsi
mov    $0x0,%al
call   1090 <err@plt>
jmp    15fa <main+0x43a>
mov    0x29ec(%rip),%rax
mov    (%rax),%edi
mov    -0xa8(%rbp),%edx
lea    0xb97(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x80(%rbp),%esi
mov    -0x88(%rbp),%edx
lea    0xbaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x148(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    %eax,-0x15c(%rbp)
mov    $0x0,%al
call   10a0 <_rdtsc@plt>
mov    %rax,-0xd8(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x80(%rbp),%eax
jge    1750 <main+0x590>
xor    %eax,%eax
mov    %al,-0x185(%rbp)
call   10a0 <_rdtsc@plt>
mov    %rax,-0xc0(%rbp)
mov    -0x88(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1080 <matrix_mult@plt>
mov    %rax,%rcx
mov    -0x185(%rbp),%al
mov    %rcx,-0xf8(%rbp)
call   10a0 <_rdtsc@plt>
mov    %rax,-0xc8(%rbp)
mov    -0xc8(%rbp),%rax
mov    -0xc0(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0xd0(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0x954(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xf8(%rbp),%rcx
mov    -0xf0(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0xf0(%rbp)
movaps 0x944(%rip),%xmm3
movq   -0xf8(%rbp),%xmm0
ff
punpckldq %xmm3,%xmm0
movapd 0x940(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movq   -0xd0(%rbp),%xmm1
ff
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    173d <main+0x57d>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1742 <main+0x582>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    163c <main+0x47c>
xor    %eax,%eax
mov    %eax,-0x18c(%rbp)
mov    %al,-0x18d(%rbp)
call   10a0 <_rdtsc@plt>
mov    %rax,%rcx
mov    -0x18d(%rbp),%al
mov    %rcx,-0xe0(%rbp)
call   10e0 <_loc_freq@plt>
mov    %rax,%rcx
mov    -0x18c(%rbp),%eax
mov    %rcx,-0x170(%rbp)
mov    %eax,%esi
lea    -0x158(%rbp),%rdi
call   1050 <gettimeofday@plt>
mov    %eax,-0x15c(%rbp)
mov    -0x150(%rbp),%rax
mov    -0x140(%rbp),%rcx
sub    %rcx,%rax
imul   $0xf4240,%rax,%rax
mov    %rax,-0x168(%rbp)
mov    -0x158(%rbp),%rcx
mov    -0x148(%rbp),%rax
sub    %rax,%rcx
mov    -0x168(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x168(%rbp)
mov    -0xe0(%rbp),%rax
mov    -0xd8(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0xe8(%rbp)
movaps 0x824(%rip),%xmm3
movq   -0xf0(%rbp),%xmm0
ff
punpckldq %xmm3,%xmm0
movapd 0x820(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movq   -0xe8(%rbp),%xmm1
ff
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0xf0(%rbp),%rsi
mov    -0x8c(%rbp),%edx
mov    -0xd0(%rbp),%rcx
mov    -0xe8(%rbp),%r8
lea    0x986(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe8(%rbp),%rsi
lea    0x9ae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x168(%rbp),%rsi
lea    0x9aa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x170(%rbp),%rsi
lea    0x9b3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0x9b1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x48(%rbp),%xmm0
lea    0x9b9(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x2,%edi
jg     121e <main+0x4e>
lea    0x100a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   10c0 <usage@plt>
lea    0xe32(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10a0 <err@plt>
movl   $0x1,0x8(%rsp)
lea    0xe25(%rip),%r13
mov    0x2dc4(%rip),%r15
lea    0xe25(%rip),%r14
jmp    1251 <main+0x81>
nopl   (%rax)
mov    $0x1,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <err@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10d0 <getopt@plt>
cmp    $0x6c,%eax
jg     1280 <main+0xb0>
cmp    $0xffffffff,%eax
je     12a6 <main+0xd6>
cmp    $0x69,%eax
jne    1240 <main+0x70>
mov    (%r15),%edi
call   10e0 <atoi@plt>
mov    %eax,%r12d
jmp    1251 <main+0x81>
nopw   0x0(%rax,%rax,1)
cmp    $0x6d,%eax
je     1298 <main+0xc8>
cmp    $0x72,%eax
jne    1240 <main+0x70>
mov    (%r15),%edi
call   10e0 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    1251 <main+0x81>
mov    (%r15),%edi
call   10e0 <atoi@plt>
mov    %eax,0x8(%rsp)
jmp    1251 <main+0x81>
xor    %edi,%edi
mov    %r12d,%esi
call   1070 <pin_cpu@plt>
cmp    $0xffffffff,%eax
je     12d1 <main+0x101>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xdc4(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    12e4 <main+0x114>
lea    0xd9a(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10a0 <err@plt>
mov    0x8(%rsp),%r8d
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
lea    0xdbf(%rip),%rsi
mov    $0x2040200,%ecx
mov    $0x800,%edx
mov    %r8d,%r9d
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2cdc(%rip),%r12
mov    0x2cad(%rip),%r14
mov    (%r14),%edx
or     (%r12),%edx
mov    0x2c8f(%rip),%r13
mov    0x2c90(%rip),%rbp
mov    0x0(%rbp),%ecx
or     0x0(%r13),%ecx
mov    $0x2040200,%esi
xor    %edi,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    (%r14),%edx
or     (%r12),%edx
mov    %rax,%rbx
mov    0x0(%rbp),%ecx
or     0x0(%r13),%ecx
mov    $0x2040200,%esi
xor    %edi,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    (%r14),%edx
or     (%r12),%edx
mov    %rax,%r14
mov    0x0(%rbp),%ecx
or     0x0(%r13),%ecx
mov    %rbx,%r13
xor    %ebx,%ebx
mov    $0x2040200,%esi
xor    %edi,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%r15
add    $0x30,%rax
lea    0x30(%r14),%rcx
lea    0x30(%r13),%rdx
lea    0x8(%r15),%rsi
lea    0x8(%r14),%rdi
lea    0x8(%r13),%rbp
movabs $0x3ff199999999999a,%r8
99 f1 3f
xorpd  %xmm0,%xmm0
movapd 0xc32(%rip),%xmm1
mov    %r13,0x40(%rsp)
mov    %r14,0x38(%rsp)
mov    %r15,0x30(%rsp)
jmp    142e <main+0x25e>
nop
mov    0x20(%rsp),%rbx
add    $0x1,%rbx
add    $0x4000,%rax
add    $0x4000,%rcx
add    $0x4000,%rdx
add    $0x4000,%rsi
add    $0x4000,%rdi
add    $0x4000,%rbp
cmp    $0x800,%rbx
mov    0x40(%rsp),%r13
mov    0x38(%rsp),%r14
mov    0x30(%rsp),%r15
je     1546 <main+0x376>
mov    %rbx,0x20(%rsp)
shl    $0xe,%rbx
lea    (%rbx,%r13,1),%r9
lea    (%rbx,%r13,1),%r10
add    $0x4000,%r10
lea    (%r14,%rbx,1),%r12
add    %rbx,%r14
add    $0x4000,%r14
lea    (%r15,%rbx,1),%r13
add    %rbx,%r15
add    $0x4000,%r15
cmp    %r14,%r9
setb   0x10(%rsp)
cmp    %r10,%r12
setb   %r11b
cmp    %r15,%r9
setb   %bl
cmp    %r10,%r13
setb   %r10b
cmp    %r15,%r12
setb   %r9b
cmp    %r14,%r13
setb   %r14b
test   %r11b,0x10(%rsp)
jne    1500 <main+0x330>
and    %r10b,%bl
jne    1500 <main+0x330>
and    %r14b,%r9b
jne    1500 <main+0x330>
xor    %ebx,%ebx
nop
movupd %xmm0,-0x30(%rdx,%rbx,8)
movupd %xmm0,-0x20(%rdx,%rbx,8)
movupd %xmm1,-0x30(%rcx,%rbx,8)
movupd %xmm1,-0x20(%rcx,%rbx,8)
movupd %xmm1,-0x30(%rax,%rbx,8)
movupd %xmm1,-0x20(%rax,%rbx,8)
movupd %xmm0,-0x10(%rdx,%rbx,8)
movupd %xmm0,(%rdx,%rbx,8)
movupd %xmm1,-0x10(%rcx,%rbx,8)
movupd %xmm1,(%rcx,%rbx,8)
movupd %xmm1,-0x10(%rax,%rbx,8)
movupd %xmm1,(%rax,%rbx,8)
add    $0x8,%rbx
cmp    $0x800,%rbx
jne    14a0 <main+0x2d0>
jmp    13e0 <main+0x210>
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movq   $0x0,-0x8(%rbp,%rbx,8)
mov    %r8,-0x8(%rdi,%rbx,8)
mov    %r8,-0x8(%rsi,%rbx,8)
movq   $0x0,0x0(%rbp,%rbx,8)
mov    %r8,(%rdi,%rbx,8)
mov    %r8,(%rsi,%rbx,8)
add    $0x2,%rbx
cmp    $0x800,%rbx
jne    1510 <main+0x340>
jmp    13e0 <main+0x210>
xor    %edi,%edi
mov    0xc(%rsp),%ebx
mov    %ebx,%esi
call   1070 <pin_cpu@plt>
cmp    $0xffffffff,%eax
je     1573 <main+0x3a3>
mov    0x2a71(%rip),%rax
mov    (%rax),%edi
lea    0xb80(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1586 <main+0x3b6>
lea    0xaf8(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10a0 <err@plt>
mov    0x8(%rsp),%ebp
lea    0xb81(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
mov    $0x800,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x58(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   10b0 <_rdtsc@plt>
mov    %rax,0x10(%rsp)
test   %ebp,%ebp
jle    1665 <main+0x495>
movsd  0xa67(%rip),%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x20(%rsp)
xor    %eax,%eax
call   10b0 <_rdtsc@plt>
mov    %rax,%r15
mov    $0x800,%edi
mov    %r13,%rsi
mov    0x38(%rsp),%rdx
mov    0x30(%rsp),%rcx
call   1090 <matrix_mult@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10b0 <_rdtsc@plt>
mov    %rax,%r14
sub    %r15,%r14
add    %r12,%rbx
movq   %r12,%xmm0
movdqa 0x9f9(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0x9fd(%rip),%xmm3
subpd  %xmm3,%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
addsd  %xmm0,%xmm2
movq   %r14,%xmm0
punpckldq %xmm1,%xmm0
subpd  %xmm3,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
maxsd  0x20(%rsp),%xmm2
movapd %xmm2,%xmm0
add    $0xffffffff,%ebp
jne    15d0 <main+0x400>
jmp    166d <main+0x49d>
movsd  0x9c3(%rip),%xmm2
movapd %xmm2,0x20(%rsp)
xor    %eax,%eax
call   10b0 <_rdtsc@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10f0 <_loc_freq@plt>
mov    %rax,%r15
lea    0x48(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x48(%rsp),%rbp
mov    0x50(%rsp),%rax
sub    0x60(%rsp),%rax
sub    0x58(%rsp),%rbp
imul   $0xf4240,%rax,%rax
add    %rax,%rbp
sub    0x10(%rsp),%r12
movq   %rbx,%xmm0
movdqa 0x94d(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0x951(%rip),%xmm2
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
addsd  %xmm0,%xmm3
movq   %r12,%xmm0
punpckldq %xmm1,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm3
movapd %xmm3,0x10(%rsp)
lea    0xa40(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa66(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa66(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa73(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa73(%rip),%rdi
movaps 0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xa7b(%rip),%rdi
movaps 0x20(%rsp),%xmm0
mov    $0x1,%al
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
%struct.timespec = type { i32 }
%struct.timeval = type { i64, i64 }
@.str = [154 x i8] c"triad driver needs at least 3 arguments, cpu_init, cpu_run, cache_level, [call count multiplier def = 1], [offset a, offset_b, offset_c defaults = 0] \0A\00"
@.str.1 = [12 x i8] c" argc = %d\0A\00"
@.str.2 = [14 x i8] c"bad arguments\00"
@.str.3 = [14 x i8] c"i:r:l:m:a:b:c\00"
@optarg = global i32 0
@.str.4 = [18 x i8] c"unknown option %c\00"
@.str.5 = [23 x i8] c"failed to set affinity\00"
@stderr = global i32 0
@.str.6 = [47 x i8] c" process pinned to core %d for initialization\0A\00"
@.str.7 = [48 x i8] c"len = %d, buf_szie = %zd, iter = %d, mult = %d\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@.str.8 = [42 x i8] c" process pinned to core %d for triad run\0A\00"
@.str.9 = [55 x i8] c" calling matrix_mult %d times with dimension len = %d\0A\00"
@.str.10 = [61 x i8] c" total %zd flops %d took %zd cycles/call and a total of %zd\0A\00"
@.str.11 = [17 x i8] c" run time = %zd\0A\00"
@.str.12 = [30 x i8] c" gettimeofday_run time = %zd\0A\00"
@.str.13 = [17 x i8] c"frequency = %zd\0A\00"
@.str.14 = [27 x i8] c" average flops/cycle = %f\0A\00"
@.str.15 = [24 x i8] c" best flops/cycle = %f\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca [4 x i32]
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i64
%34 = alloca i64
%35 = alloca i64
%36 = alloca i64
%37 = alloca i64
%38 = alloca i64
%39 = alloca i64
%40 = alloca i64
%41 = alloca i64
%42 = alloca i64
%43 = alloca i64
%44 = alloca i64
%45 = alloca i64
%46 = alloca %struct.timespec
%47 = alloca %struct.timespec
%48 = alloca i64
%49 = alloca %struct.timeval
%50 = alloca %struct.timeval
%51 = alloca i32
%52 = alloca i32
%53 = alloca i64
%54 = alloca i64
%55 = alloca i32
%56 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
store double 1.000000e-02, double* %8
store double -1.000000e+00, double* %11
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 1, i32* %21
store i32 1, i32* %22
store i32 0, i32* %30
store i64 0, i64* %39
store i64 0, i64* %41
store i64 0, i64* %42
store i64 0, i64* %48
store i32 -1, i32* %52
store i32 0, i32* %55
%57 = load i32, i32* %3
%58 = icmp slt i32 %57, 3
br i1 %58, label %59, label %65
59: ; preds = %2
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0))
%61 = load i32, i32* %3
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = call i32 (...) @usage()
%64 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %65
65: ; preds = %59, %2
store i32 2048, i32* %24
br label %66
66: ; preds = %85, %65
%67 = load i32, i32* %3
%68 = load i8**, i8*** %4
%69 = call i32 @getopt(i32 %67, i8** %68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store i32 %69, i32* %23
%70 = icmp ne i32 %69, -1
br i1 %70, label %71, label %86
71: ; preds = %66
%72 = load i32, i32* %23
switch i32 %72, label %82 [
i32 105, label %73
i32 114, label %76
i32 109, label %79
]
73: ; preds = %71
%74 = load i32, i32* @optarg
%75 = call i32 @atoi(i32 %74)
store i32 %75, i32* %27
br label %85
76: ; preds = %71
%77 = load i32, i32* @optarg
%78 = call i32 @atoi(i32 %77)
store i32 %78, i32* %28
br label %85
79: ; preds = %71
%80 = load i32, i32* @optarg
%81 = call i32 @atoi(i32 %80)
store i32 %81, i32* %21
br label %85
82: ; preds = %71
%83 = load i32, i32* %23
%84 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %83)
br label %85
85: ; preds = %82, %79, %76, %73
br label %66
86: ; preds = %66
%87 = load i32, i32* %22
%88 = load i32, i32* %21
%89 = mul nsw i32 %87, %88
store i32 %89, i32* %22
%90 = load i32, i32* %30
%91 = load i32, i32* %27
%92 = call i32 @pin_cpu(i32 %90, i32 %91)
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %96
94: ; preds = %86
%95 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %100
96: ; preds = %86
%97 = load i32, i32* @stderr
%98 = load i32, i32* %27
%99 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %96, %94
%101 = load i32, i32* %24
%102 = add nsw i32 %101, 8
%103 = load i32, i32* %24
%104 = add nsw i32 %103, 8
%105 = mul nsw i32 %102, %104
%106 = mul nsw i32 %105, 8
%107 = sext i32 %106 to i64
store i64 %107, i64* %56
%108 = load i32, i32* @stderr
%109 = load i32, i32* %24
%110 = load i64, i64* %56
%111 = load i32, i32* %22
%112 = load i32, i32* %21
%113 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i32 %109, i64 %110, i32 %111, i32 %112)
%114 = load i64, i64* %56
%115 = load i32, i32* @PROT_READ
%116 = load i32, i32* @PROT_WRITE
%117 = or i32 %115, %116
%118 = load i32, i32* @MAP_PRIVATE
%119 = load i32, i32* @MAP_ANON
%120 = or i32 %118, %119
%121 = load i32, i32* %52
%122 = load i32, i32* %55
%123 = call i64 @mmap(i32* null, i64 %114, i32 %117, i32 %120, i32 %121, i32 %122)
%124 = inttoptr i64 %123 to i8*
store i8* %124, i8** %12
%125 = load i64, i64* %56
%126 = load i32, i32* @PROT_READ
%127 = load i32, i32* @PROT_WRITE
%128 = or i32 %126, %127
%129 = load i32, i32* @MAP_PRIVATE
%130 = load i32, i32* @MAP_ANON
%131 = or i32 %129, %130
%132 = load i32, i32* %52
%133 = load i32, i32* %55
%134 = call i64 @mmap(i32* null, i64 %125, i32 %128, i32 %131, i32 %132, i32 %133)
%135 = inttoptr i64 %134 to i8*
store i8* %135, i8** %13
%136 = load i64, i64* %56
%137 = load i32, i32* @PROT_READ
%138 = load i32, i32* @PROT_WRITE
%139 = or i32 %137, %138
%140 = load i32, i32* @MAP_PRIVATE
%141 = load i32, i32* @MAP_ANON
%142 = or i32 %140, %141
%143 = load i32, i32* %52
%144 = load i32, i32* %55
%145 = call i64 @mmap(i32* null, i64 %136, i32 %139, i32 %142, i32 %143, i32 %144)
%146 = inttoptr i64 %145 to i8*
store i8* %146, i8** %14
%147 = load i8*, i8** %12
%148 = bitcast i8* %147 to double*
store double* %148, double** %5
%149 = load i8*, i8** %13
%150 = bitcast i8* %149 to double*
store double* %150, double** %6
%151 = load i8*, i8** %14
%152 = bitcast i8* %151 to double*
store double* %152, double** %7
store i32 0, i32* %15
br label %153
153: ; preds = %191, %100
%154 = load i32, i32* %15
%155 = load i32, i32* %24
%156 = icmp slt i32 %154, %155
br i1 %156, label %157, label %194
157: ; preds = %153
store i32 0, i32* %17
br label %158
158: ; preds = %187, %157
%159 = load i32, i32* %17
%160 = load i32, i32* %24
%161 = icmp slt i32 %159, %160
br i1 %161, label %162, label %190
162: ; preds = %158
%163 = load double*, double** %5
%164 = load i32, i32* %15
%165 = load i32, i32* %24
%166 = mul nsw i32 %164, %165
%167 = load i32, i32* %17
%168 = add nsw i32 %166, %167
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds double, double* %163, i64 %169
store double 0.000000e+00, double* %170
%171 = load double*, double** %6
%172 = load i32, i32* %15
%173 = load i32, i32* %24
%174 = mul nsw i32 %172, %173
%175 = load i32, i32* %17
%176 = add nsw i32 %174, %175
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds double, double* %171, i64 %177
store double 1.100000e+00, double* %178
%179 = load double*, double** %7
%180 = load i32, i32* %15
%181 = load i32, i32* %24
%182 = mul nsw i32 %180, %181
%183 = load i32, i32* %17
%184 = add nsw i32 %182, %183
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds double, double* %179, i64 %185
store double 1.100000e+00, double* %186
br label %187
187: ; preds = %162
%188 = load i32, i32* %17
%189 = add nsw i32 %188, 1
store i32 %189, i32* %17
br label %158
190: ; preds = %158
br label %191
191: ; preds = %190
%192 = load i32, i32* %15
%193 = add nsw i32 %192, 1
store i32 %193, i32* %15
br label %153
194: ; preds = %153
%195 = load i32, i32* %30
%196 = load i32, i32* %28
%197 = call i32 @pin_cpu(i32 %195, i32 %196)
%198 = icmp eq i32 %197, -1
br i1 %198, label %199, label %201
199: ; preds = %194
%200 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %205
201: ; preds = %194
%202 = load i32, i32* @stderr
%203 = load i32, i32* %28
%204 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %202, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %203)
br label %205
205: ; preds = %201, %199
%206 = load i32, i32* %22
%207 = load i32, i32* %24
%208 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0), i32 %206, i32 %207)
%209 = call i32 @gettimeofday(%struct.timeval* %49, i32* null)
store i32 %209, i32* %51
%210 = call i64 (...) @_rdtsc()
store i64 %210, i64* %36
store i32 0, i32* %15
br label %211
211: ; preds = %242, %205
%212 = load i32, i32* %15
%213 = load i32, i32* %22
%214 = icmp slt i32 %212, %213
br i1 %214, label %215, label %245
215: ; preds = %211
%216 = call i64 (...) @_rdtsc()
store i64 %216, i64* %33
%217 = load i32, i32* %24
%218 = load double*, double** %5
%219 = load double*, double** %6
%220 = load double*, double** %7
%221 = call i64 @matrix_mult(i32 %217, double* %218, double* %219, double* %220)
store i64 %221, i64* %40
%222 = call i64 (...) @_rdtsc()
store i64 %222, i64* %34
%223 = load i64, i64* %34
%224 = load i64, i64* %33
%225 = sub i64 %223, %224
store i64 %225, i64* %35
%226 = load double, double* %8
%227 = fadd double %226, 1.000000e-02
store double %227, double* %8
%228 = load i64, i64* %40
%229 = load i64, i64* %39
%230 = add i64 %229, %228
store i64 %230, i64* %39
%231 = load i64, i64* %40
%232 = uitofp i64 %231 to double
%233 = load i64, i64* %35
%234 = uitofp i64 %233 to double
%235 = fdiv double %232, %234
store double %235, double* %9
%236 = load double, double* %9
%237 = load double, double* %11
%238 = fcmp ogt double %236, %237
br i1 %238, label %239, label %241
239: ; preds = %215
%240 = load double, double* %9
store double %240, double* %11
br label %241
241: ; preds = %239, %215
br label %242
242: ; preds = %241
%243 = load i32, i32* %15
%244 = add nsw i32 %243, 1
store i32 %244, i32* %15
br label %211
245: ; preds = %211
%246 = call i64 (...) @_rdtsc()
store i64 %246, i64* %37
%247 = call i64 (...) @_loc_freq()
store i64 %247, i64* %54
%248 = call i32 @gettimeofday(%struct.timeval* %50, i32* null)
store i32 %248, i32* %51
%249 = getelementptr inbounds %struct.timeval, %struct.timeval* %50, i32 0, i32 1
%250 = load i64, i64* %249
%251 = getelementptr inbounds %struct.timeval, %struct.timeval* %49, i32 0, i32 1
%252 = load i64, i64* %251
%253 = sub nsw i64 %250, %252
%254 = mul i64 %253, 1000000
store i64 %254, i64* %53
%255 = getelementptr inbounds %struct.timeval, %struct.timeval* %50, i32 0, i32 0
%256 = load i64, i64* %255
%257 = getelementptr inbounds %struct.timeval, %struct.timeval* %49, i32 0, i32 0
%258 = load i64, i64* %257
%259 = sub nsw i64 %256, %258
%260 = load i64, i64* %53
%261 = add i64 %260, %259
store i64 %261, i64* %53
%262 = load i64, i64* %37
%263 = load i64, i64* %36
%264 = sub i64 %262, %263
store i64 %264, i64* %38
%265 = load i64, i64* %39
%266 = uitofp i64 %265 to double
%267 = load i64, i64* %38
%268 = uitofp i64 %267 to double
%269 = fdiv double %266, %268
store double %269, double* %10
%270 = load i64, i64* %39
%271 = load i32, i32* %25
%272 = load i64, i64* %35
%273 = load i64, i64* %38
%274 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.10, i64 0, i64 0), i64 %270, i32 %271, i64 %272, i64 %273)
%275 = load i64, i64* %38
%276 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i64 %275)
%277 = load i64, i64* %53
%278 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i64 %277)
%279 = load i64, i64* %54
%280 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i64 %279)
%281 = load double, double* %10
%282 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), double %281)
%283 = load double, double* %11
%284 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), double %283)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str.1 = [12 x i8] c" argc = %d\0A\00"
@.str.2 = [14 x i8] c"bad arguments\00"
@.str.3 = [14 x i8] c"i:r:l:m:a:b:c\00"
@optarg = global i32 0
@.str.4 = [18 x i8] c"unknown option %c\00"
@.str.5 = [23 x i8] c"failed to set affinity\00"
@stderr = global i32 0
@.str.6 = [47 x i8] c" process pinned to core %d for initialization\0A\00"
@.str.7 = [48 x i8] c"len = %d, buf_szie = %zd, iter = %d, mult = %d\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@.str.8 = [42 x i8] c" process pinned to core %d for triad run\0A\00"
@.str.9 = [55 x i8] c" calling matrix_mult %d times with dimension len = %d\0A\00"
@.str.10 = [61 x i8] c" total %zd flops %d took %zd cycles/call and a total of %zd\0A\00"
@.str.11 = [17 x i8] c" run time = %zd\0A\00"
@.str.12 = [30 x i8] c" gettimeofday_run time = %zd\0A\00"
@.str.13 = [17 x i8] c"frequency = %zd\0A\00"
@.str.14 = [27 x i8] c" average flops/cycle = %f\0A\00"
@.str.15 = [24 x i8] c" best flops/cycle = %f\0A\00"
@str = [153 x i8] c"triad driver needs at least 3 arguments, cpu_init, cpu_run, cache_level, [call count multiplier def = 1], [offset a, offset_b, offset_c defaults = 0] \00"
define void @main(i32 %0, i8** %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([153 x i8], [153 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%11 = tail call i32 (...) @usage()
%12 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %8, %2
br label %14
14: ; preds = %13, %28
%15 = phi i32 [ undef, %13 ], [ %30, %28 ]
%16 = phi i32 [ undef, %13 ], [ %19, %28 ]
%17 = phi i32 [ 1, %13 ], [ %22, %28 ]
br label %18
18: ; preds = %14, %25
%19 = phi i32 [ %16, %14 ], [ %27, %25 ]
%20 = phi i32 [ %17, %14 ], [ %22, %25 ]
br label %21
21: ; preds = %18, %31
%22 = phi i32 [ %20, %18 ], [ %33, %31 ]
br label %23
23: ; preds = %21, %34
%24 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
switch i32 %24, label %34 [
i32 -1, label %36
i32 105, label %25
i32 114, label %28
i32 109, label %31
]
25: ; preds = %23
%26 = load i32, i32* @optarg
%27 = tail call i32 @atoi(i32 %26)
br label %18
28: ; preds = %23
%29 = load i32, i32* @optarg
%30 = tail call i32 @atoi(i32 %29)
br label %14
31: ; preds = %23
%32 = load i32, i32* @optarg
%33 = tail call i32 @atoi(i32 %32)
br label %21
34: ; preds = %23
%35 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %24)
br label %23
36: ; preds = %23
%37 = tail call i32 @pin_cpu(i32 0, i32 %19)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %44
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i32 %19)
br label %44
44: ; preds = %41, %39
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i32 2048, i64 33817088, i32 %22, i32 %22)
%47 = load i32, i32* @PROT_READ
%48 = load i32, i32* @PROT_WRITE
%49 = or i32 %48, %47
%50 = load i32, i32* @MAP_PRIVATE
%51 = load i32, i32* @MAP_ANON
%52 = or i32 %51, %50
%53 = tail call i64 @mmap(i32* null, i64 33817088, i32 %49, i32 %52, i32 -1, i32 0)
%54 = load i32, i32* @PROT_READ
%55 = load i32, i32* @PROT_WRITE
%56 = or i32 %55, %54
%57 = load i32, i32* @MAP_PRIVATE
%58 = load i32, i32* @MAP_ANON
%59 = or i32 %58, %57
%60 = tail call i64 @mmap(i32* null, i64 33817088, i32 %56, i32 %59, i32 -1, i32 0)
%61 = load i32, i32* @PROT_READ
%62 = load i32, i32* @PROT_WRITE
%63 = or i32 %62, %61
%64 = load i32, i32* @MAP_PRIVATE
%65 = load i32, i32* @MAP_ANON
%66 = or i32 %65, %64
%67 = tail call i64 @mmap(i32* null, i64 33817088, i32 %63, i32 %66, i32 -1, i32 0)
%68 = inttoptr i64 %53 to double*
%69 = inttoptr i64 %60 to double*
%70 = inttoptr i64 %67 to double*
br label %71
71: ; preds = %44, %137
%72 = phi i64 [ 0, %44 ], [ %138, %137 ]
%73 = shl nuw nsw i64 %72, 11
%74 = getelementptr double, double* %68, i64 %73
%75 = add nuw i64 %73, 2048
%76 = getelementptr double, double* %68, i64 %75
%77 = getelementptr double, double* %69, i64 %73
%78 = getelementptr double, double* %69, i64 %75
%79 = getelementptr double, double* %70, i64 %73
%80 = getelementptr double, double* %70, i64 %75
%81 = shl nsw i64 %72, 11
%82 = icmp ult double* %74, %78
%83 = icmp ult double* %77, %76
%84 = and i1 %82, %83
%85 = icmp ult double* %74, %80
%86 = icmp ult double* %79, %76
%87 = and i1 %85, %86
%88 = or i1 %84, %87
%89 = icmp ult double* %77, %80
%90 = icmp ult double* %79, %78
%91 = and i1 %89, %90
%92 = or i1 %88, %91
br i1 %92, label %124, label %93
93: ; preds = %71, %93
%94 = phi i64 [ %122, %93 ], [ 0, %71 ]
%95 = add nuw nsw i64 %94, %81
%96 = getelementptr inbounds double, double* %68, i64 %95
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %97
%98 = getelementptr inbounds double, double* %96, i64 2
%99 = bitcast double* %98 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %99
%100 = getelementptr inbounds double, double* %69, i64 %95
%101 = bitcast double* %100 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 1.100000e+00>, <2 x double>* %101
%102 = getelementptr inbounds double, double* %100, i64 2
%103 = bitcast double* %102 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 1.100000e+00>, <2 x double>* %103
%104 = getelementptr inbounds double, double* %70, i64 %95
%105 = bitcast double* %104 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 1.100000e+00>, <2 x double>* %105
%106 = getelementptr inbounds double, double* %104, i64 2
%107 = bitcast double* %106 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 1.100000e+00>, <2 x double>* %107
%108 = or i64 %94, 4
%109 = add nuw nsw i64 %108, %81
%110 = getelementptr inbounds double, double* %68, i64 %109
%111 = bitcast double* %110 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %111
%112 = getelementptr inbounds double, double* %110, i64 2
%113 = bitcast double* %112 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %113
%114 = getelementptr inbounds double, double* %69, i64 %109
%115 = bitcast double* %114 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 1.100000e+00>, <2 x double>* %115
%116 = getelementptr inbounds double, double* %114, i64 2
%117 = bitcast double* %116 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 1.100000e+00>, <2 x double>* %117
%118 = getelementptr inbounds double, double* %70, i64 %109
%119 = bitcast double* %118 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 1.100000e+00>, <2 x double>* %119
%120 = getelementptr inbounds double, double* %118, i64 2
%121 = bitcast double* %120 to <2 x double>*
store <2 x double> <double 1.100000e+00, double 1.100000e+00>, <2 x double>* %121
%122 = add nuw nsw i64 %94, 8
%123 = icmp eq i64 %122, 2048
br i1 %123, label %137, label %93
124: ; preds = %71, %124
%125 = phi i64 [ %135, %124 ], [ 0, %71 ]
%126 = add nuw nsw i64 %125, %81
%127 = getelementptr inbounds double, double* %68, i64 %126
store double 0.000000e+00, double* %127
%128 = getelementptr inbounds double, double* %69, i64 %126
store double 1.100000e+00, double* %128
%129 = getelementptr inbounds double, double* %70, i64 %126
store double 1.100000e+00, double* %129
%130 = or i64 %125, 1
%131 = add nuw nsw i64 %130, %81
%132 = getelementptr inbounds double, double* %68, i64 %131
store double 0.000000e+00, double* %132
%133 = getelementptr inbounds double, double* %69, i64 %131
store double 1.100000e+00, double* %133
%134 = getelementptr inbounds double, double* %70, i64 %131
store double 1.100000e+00, double* %134
%135 = add nuw nsw i64 %125, 2
%136 = icmp eq i64 %135, 2048
br i1 %136, label %137, label %124
137: ; preds = %93, %124
%138 = add nuw nsw i64 %72, 1
%139 = icmp eq i64 %138, 2048
br i1 %139, label %140, label %71
140: ; preds = %137
%141 = tail call i32 @pin_cpu(i32 0, i32 %15)
%142 = icmp eq i32 %141, -1
br i1 %142, label %143, label %145
143: ; preds = %140
%144 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %148
145: ; preds = %140
%146 = load i32, i32* @stderr
%147 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %15)
br label %148
148: ; preds = %145, %143
%149 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0), i32 %22, i32 2048)
%150 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%151 = tail call i64 (...) @_rdtsc()
%152 = icmp sgt i32 %22, 0
br i1 %152, label %153, label %169
153: ; preds = %148, %153
%154 = phi double [ %166, %153 ], [ -1.000000e+00, %148 ]
%155 = phi i32 [ %167, %153 ], [ 0, %148 ]
%156 = phi i64 [ %161, %153 ], [ 0, %148 ]
%157 = tail call i64 (...) @_rdtsc()
%158 = tail call i64 @matrix_mult(i32 2048, double* %68, double* %69, double* %70)
%159 = tail call i64 (...) @_rdtsc()
%160 = sub i64 %159, %157
%161 = add i64 %158, %156
%162 = uitofp i64 %158 to double
%163 = uitofp i64 %160 to double
%164 = fdiv double %162, %163
%165 = fcmp ogt double %164, %154
%166 = select i1 %165, double %164, double %154
%167 = add nuw nsw i32 %155, 1
%168 = icmp eq i32 %167, %22
br i1 %168, label %169, label %153
169: ; preds = %153, %148
%170 = phi i64 [ 0, %148 ], [ %161, %153 ]
%171 = phi i64 [ undef, %148 ], [ %160, %153 ]
%172 = phi double [ -1.000000e+00, %148 ], [ %166, %153 ]
%173 = tail call i64 (...) @_rdtsc()
%174 = tail call i64 (...) @_loc_freq()
%175 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%176 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%177 = load i64, i64* %176
%178 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%179 = load i64, i64* %178
%180 = sub nsw i64 %177, %179
%181 = mul i64 %180, 1000000
%182 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%183 = load i64, i64* %182
%184 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%185 = load i64, i64* %184
%186 = sub i64 %183, %185
%187 = add i64 %186, %181
%188 = sub i64 %173, %151
%189 = uitofp i64 %170 to double
%190 = uitofp i64 %188 to double
%191 = fdiv double %189, %190
%192 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.10, i64 0, i64 0), i64 %170, i32 undef, i64 %171, i64 %188)
%193 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i64 %188)
%194 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i64 %187)
%195 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i64 %174)
%196 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), double %191)
%197 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), double %172)
ret void
}