// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rdi, %rbx
movq 0xa8(%rdi), %rsi
movq 0xb0(%rdi), %rcx
leaq -0x30(%rcx), %rax
pushq $0x3
popq %rdi
xorl %edx, %edx
divq %rdi
movabsq $0x7ffffffffffffff0, %r12 # imm = 0x7FFFFFFFFFFFFFF0
andq %rax, %r12
movq %r12, %r14
shrq $0x3, %r14
leaq 0x10(%rsi), %r15
andq $-0x11, %r15
leaq (%r15,%r12), %r13
leaq (%r12,%r13), %rbp
cmpl $0x2, 0x105c74(%rip)    # 0x50e340
jl 0x4086ed
leaq 0xcbedb(%rip), %rdi     # 0x4d45b0
movq %rcx, %rdx
movq %r12, %rcx
movq %r14, %r8
movq %r15, %r9
xorl %eax, %eax
pushq %rbp
pushq %r13
callq 0x415070
popq %rcx
popq %rdx
leaq (%r12,%r12,2), %rax
movq %rax, (%rsp)
pushq $-0x1
popq %r12
callq 0x403630
movq %r12, %rdx
movq 0xca907(%rip), %xmm1    # 0x4d3010
movq %rax, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd 0xca906(%rip), %xmm0    # 0x4d3020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
movq %rbp, %rax
xorl %esi, %esi
movq %r15, %rbp
movq %r13, %r15
movq %rax, %r13
xorl %eax, %eax
cmpq %r14, %rax
jae 0x40877a
testb $0xe, %al
je 0x40876a
movq (%rbp,%rax,8), %rcx
addq (%r13,%rax,8), %rcx
movntiq %rcx, (%r15,%rax,8)
movq 0x8(%rbp,%rax,8), %rcx
addq 0x8(%r13,%rax,8), %rcx
movntiq %rcx, 0x8(%r15,%rax,8)
addq $0x2, %rax
jmp 0x40873c
movq 0xd0(%rbx), %rcx
subq $0x1, %rcx
jb 0x408745
nop
jmp 0x408771
incq %rsi
movq 0xc8(%rbx), %r12
movq %rbp, %rax
cmpq %r12, %rdx
je 0x408731
cmpq $0x0, 0x8(%rbx)
movq %rbp, %rax
jne 0x408731
movq %rsi, 0x8(%rsp)
callq 0x403630
movq %rax, %xmm0
movq 0xca863(%rip), %xmm1    # 0x4d3010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movdqa %xmm1, %xmm3
movapd 0xca863(%rip), %xmm2    # 0x4d3020
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
subsd 0x10(%rsp), %xmm1
movq 0x8(%rsp), %rax
imulq (%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 0xca84a(%rip), %xmm2    # 0x4d3048
movsd 0xca86a(%rip), %xmm0    # 0x4d3070
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xca852(%rip), %xmm2    # 0x4d3078
cvttsd2si %xmm2, %rdx
andq %rcx, %rdx
orq %rax, %rdx
lock
addq %rdx, 0x8(%rbx)
callq 0x403630
movq 0xca7cd(%rip), %xmm1    # 0x4d3010
movq %r12, %rdx
jmp 0x408709
nop