// File: /workspace/github_c_makefile_star2_O1/google[P]multichase/multiload.c
// Function: load_stream_triad_nontemporal_injection_delay
static void load_stream_triad_nontemporal_injection_delay(per_thread_t *t) {
#define LOOP_OPS 3
#define LOOP_ALIGN 16
  uint64_t load_loop, load_bites;
  register uint64_t N, i;
  register uint64_t *a;
  register uint64_t *b;
  register uint64_t *c;
  register uint64_t *tmp;
  const uint64_t num_elem_twocachelines = DEF_CACHELINE / sizeof(uint64_t) * 2;

  load_loop =
      t->x.load_total_memory -
      (LOOP_OPS * LOOP_ALIGN);  // subtract to allow aligning count/addresses
  load_loop = (load_loop / LOOP_OPS) &
              ~(LOOP_ALIGN - 1);  // divide by 3 buffers and align byte count on
                                  // LOOP_ALIGN byte multiple
  N = load_loop / sizeof(uint64_t);
  load_bites = N * sizeof(uint64_t) * LOOP_OPS;
  size_t aa = (((size_t)t->x.load_arena + LOOP_ALIGN) &
               ~(LOOP_ALIGN));  // align on 16 byte address
  a = (uint64_t *)aa;
  b = a + N;
  c = b + N;

  if (verbosity > 1) {
    printf(
        "load_arena=%p, load_total_memory=0x%lX, load_loop=0x%lX, N=0x%lX, "
        "a=%p, b=%p, c=%p\n",
        (char *)t->x.load_arena, t->x.load_total_memory, load_loop, N, a, b, c);
  }

  LOAD_MEMORY_INIT_MIBPS
  do {
    tmp = a;
    a = b;
    b = c;
    c = tmp;

    for (i = 0; i < N; i += 2) {
      if (i % num_elem_twocachelines == 0) delay_until_iteration(t->x.delay);
#if defined(__aarch64__)
      asm volatile ("stnp %0, %1, [%2]" :: "r"(b[i]+c[i]), "r"(b[i+1]+c[i+1]), "r" (a+i));
#elif defined(__x86_64__)
      _mm_stream_si64(&((long long*)a)[i], b[i]+c[i]);
      _mm_stream_si64(&((long long*)a)[i+1], b[i+1]+c[i+1]);
#else
      a[i] = b[i] + c[i];
      a[i+1] = b[i+1] + c[i+1];
#endif
    }
    LOAD_MEMORY_SAMPLE_MIBPS
  } while (1);
#undef LOOP_OPS
#undef LOOP_ALIGN
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0xb0(%rdi), %rcx
leaq -0x30(%rcx), %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
movq %rdx, %rax
movq 0xa8(%rdi), %rsi
shrq %rax
andq $-0x10, %rax
movq %rax, %r15
shrq $0x3, %r15
leaq 0x10(%rsi), %r13
andq $-0x11, %r13
leaq (%rax,%r13), %rbp
leaq (%rax,%rbp), %r12
cmpl $0x2, 0x1064b3(%rip)    # 0x50f340
movq %rax, 0x18(%rsp)
jl 0x408eba
leaq 0xcc749(%rip), %rdi     # 0x4d55e4
movq %rcx, %rdx
movq %rax, %rcx
movq %r15, %r8
movq %r13, %r9
xorl %eax, %eax
pushq %r12
pushq %rbp
callq 0x4158b0
movq 0x28(%rsp), %rax
addq $0x10, %rsp
leaq (%rax,%rax,2), %rax
movq %rax, 0x20(%rsp)
leaq 0x8(%rsp), %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0x466f20
imulq $0x3b9aca00, (%r14), %rcx # imm = 0x3B9ACA00
addq 0x8(%r14), %rcx
movq $-0x1, %rax
movq 0xcb121(%rip), %xmm1    # 0x4d4010
movq %rcx, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd 0xcb120(%rip), %xmm0    # 0x4d4020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
movq %r12, %rcx
xorl %edi, %edi
movq 0x18(%rsp), %rsi
movq %r13, %r12
movq %rbp, %r13
movq %rcx, %rbp
testq %rsi, %rsi
je 0x408f6b
xorl %ecx, %ecx
testb $0xe, %cl
jne 0x408f43
movq 0xd0(%rbx), %rdx
testq %rdx, %rdx
je 0x408f43
nop
decq %rdx
jne 0x408f3d
movq (%r12,%rcx,8), %rdx
addq (%rbp,%rcx,8), %rdx
movntiq %rdx, (%r13,%rcx,8)
movq 0x8(%r12,%rcx,8), %rdx
addq 0x8(%rbp,%rcx,8), %rdx
movntiq %rdx, 0x8(%r13,%rcx,8)
addq $0x2, %rcx
cmpq %r15, %rcx
jb 0x408f2c
incq %rdi
movq 0xc8(%rbx), %r14
movq %r12, %rcx
cmpq %r14, %rax
je 0x408f1c
cmpq $0x0, 0x8(%rbx)
movq %r12, %rcx
jne 0x408f1c
movq %rdi, 0x28(%rsp)
movl $0x1, %edi
leaq 0x8(%rsp), %rsi
callq 0x466f20
imulq $0x3b9aca00, 0x8(%rsp), %rax # imm = 0x3B9ACA00
addq 0x10(%rsp), %rax
movq %rax, %xmm0
movq 0xcb05a(%rip), %xmm1    # 0x4d4010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movdqa %xmm1, %xmm3
movapd 0xcb05a(%rip), %xmm2    # 0x4d4020
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
subsd 0x30(%rsp), %xmm1
movq 0x28(%rsp), %rax
imulq 0x20(%rsp), %rax
movq %rax, %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd 0xcb038(%rip), %xmm2    # 0x4d4040
movsd 0xcb060(%rip), %xmm0    # 0x4d4070
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xcb048(%rip), %xmm2    # 0x4d4078
cvttsd2si %xmm2, %rdx
andq %rcx, %rdx
orq %rax, %rdx
lock
addq %rdx, 0x8(%rbx)
movl $0x1, %edi
leaq 0x8(%rsp), %rsi
callq 0x466f20
movq 0xcafb9(%rip), %xmm1    # 0x4d4010
imulq $0x3b9aca00, 0x8(%rsp), %rcx # imm = 0x3B9ACA00
addq 0x10(%rsp), %rcx
movq %r14, %rax
jmp 0x408eef
nopl (%rax)