// File: /workspace/github_c_makefile_star2_O3/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, 0x105c5f(%rip)    # 0x50f340
movq %rax, 0x18(%rsp)
jl 0x40970e
leaq 0xcbef1(%rip), %rdi     # 0x4d55e0
movq %rcx, %rdx
movq %rax, %rcx
movq %r15, %r8
movq %r13, %r9
xorl %eax, %eax
pushq %r12
pushq %rbp
callq 0x416150
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 0x4677a0
imulq $0x3b9aca00, (%r14), %rcx # imm = 0x3B9ACA00
addq 0x8(%r14), %rcx
movq $-0x1, %rax
movq 0xca8cd(%rip), %xmm1    # 0x4d4010
movq %rcx, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd 0xca8cc(%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 0x4097bf
xorl %ecx, %ecx
testb $0xe, %cl
jne 0x409797
movq 0xd0(%rbx), %rdx
testq %rdx, %rdx
je 0x409797
nop
decq %rdx
jne 0x409791
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 0x409780
incq %rdi
movq 0xc8(%rbx), %r14
movq %r12, %rcx
cmpq %r14, %rax
je 0x409770
cmpq $0x0, 0x8(%rbx)
movq %r12, %rcx
jne 0x409770
movq %rdi, 0x28(%rsp)
movl $0x1, %edi
leaq 0x8(%rsp), %rsi
callq 0x4677a0
imulq $0x3b9aca00, 0x8(%rsp), %rax # imm = 0x3B9ACA00
addq 0x10(%rsp), %rax
movq %rax, %xmm0
movq 0xca806(%rip), %xmm1    # 0x4d4010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movdqa %xmm1, %xmm3
movapd 0xca806(%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 0xca814(%rip), %xmm2    # 0x4d4070
movsd 0xca83c(%rip), %xmm0    # 0x4d40a0
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xca824(%rip), %xmm2    # 0x4d40a8
cvttsd2si %xmm2, %rdx
andq %rcx, %rdx
orq %rax, %rdx
lock
addq %rdx, 0x8(%rbx)
movl $0x1, %edi
leaq 0x8(%rsp), %rsi
callq 0x4677a0
movq 0xca765(%rip), %xmm1    # 0x4d4010
imulq $0x3b9aca00, 0x8(%rsp), %rcx # imm = 0x3B9ACA00
addq 0x10(%rsp), %rcx
movq %r14, %rax
jmp 0x409743
nopl (%rax)