// File: /workspace/github_cpp_makefile_star2_O3/kaityo256[P]lj_simd/force_soa.cpp
// Function: force_avx2()
void
force_avx2(void) {
  const int pn = particle_number;
  const v4df vzero = _mm256_set_pd(0, 0, 0, 0);
  const v4df vcl2 = _mm256_set_pd(CL2, CL2, CL2, CL2);
  const v4df vc24 = _mm256_set_pd(24 * dt, 24 * dt, 24 * dt, 24 * dt);
  const v4df vc48 = _mm256_set_pd(48 * dt, 48 * dt, 48 * dt, 48 * dt);
  for (int i = 0; i < pn; i++) {
    const double qix = q[X][i];
    const double qiy = q[Y][i];
    const double qiz = q[Z][i];
    const int np = number_of_partners[i];
    double pfx = 0;
    double pfy = 0;
    double pfz = 0;
    const int kp = pointer[i];
    const v4df vqix = _mm256_set_pd(q[X][i], q[X][i], q[X][i], q[X][i]);
    const v4df vqiy = _mm256_set_pd(q[Y][i], q[Y][i], q[Y][i], q[Y][i]);
    const v4df vqiz = _mm256_set_pd(q[Z][i], q[Z][i], q[Z][i], q[Z][i]);

    for (int k = 0; k < (np / 4) * 4; k += 4) {
      const int j_1 = sorted_list[kp + k];
      const int j_2 = sorted_list[kp + k + 1];
      const int j_3 = sorted_list[kp + k + 2];
      const int j_4 = sorted_list[kp + k + 3];

      const v4df vqjx = _mm256_set_pd(q[X][j_1], q[X][j_2], q[X][j_3], q[X][j_4]);
      const v4df vqjy = _mm256_set_pd(q[Y][j_1], q[Y][j_2], q[Y][j_3], q[Y][j_4]);
      const v4df vqjz = _mm256_set_pd(q[Z][j_1], q[Z][j_2], q[Z][j_3], q[Z][j_4]);

      const v4df vdx = vqjx - vqix;
      const v4df vdy = vqjy - vqiy;
      const v4df vdz = vqjz - vqiz;
      const v4df vr2 = vdx * vdx + vdy * vdy + vdz * vdz;
      const v4df vr6 = vr2 * vr2 * vr2;
      v4df vdf = (vc24 * vr6 - vc48) / (vr6 * vr6 * vr2);
      const v4df mask = vcl2 - vr2;
      vdf = _mm256_blendv_pd(vdf, vzero, mask);
      v4df vdfx = vdf * vdx;
      v4df vdfy = vdf * vdy;
      v4df vdfz = vdf * vdz;
      double *dfx = (double *)(&vdfx);
      double *dfy = (double *)(&vdfy);
      double *dfz = (double *)(&vdfz);

      pfx += dfx[3];
      pfy += dfy[3];
      pfz += dfz[3];

      p[X][j_1] -= dfx[3];
      p[Y][j_1] -= dfy[3];
      p[Z][j_1] -= dfz[3];

      pfx += dfx[2];
      pfy += dfy[2];
      pfz += dfz[2];
      p[X][j_2] -= dfx[2];
      p[Y][j_2] -= dfy[2];
      p[Z][j_2] -= dfz[2];

      pfx += dfx[1];
      pfy += dfy[1];
      pfz += dfz[1];
      p[X][j_3] -= dfx[1];
      p[Y][j_3] -= dfy[1];
      p[Z][j_3] -= dfz[1];

      pfx += dfx[0];
      pfy += dfy[0];
      pfz += dfz[0];
      p[X][j_4] -= dfx[0];
      p[Y][j_4] -= dfy[0];
      p[Z][j_4] -= dfz[0];
    }
    p[X][i] += pfx;
    p[Y][i] += pfy;
    p[Z][i] += pfz;
    for (int k = (np / 4) * 4; k < np; k++) {
      const int j = sorted_list[kp + k];
      double dx = q[X][j] - qix;
      double dy = q[Y][j] - qiy;
      double dz = q[Z][j] - qiz;
      double r2 = (dx * dx + dy * dy + dz * dz);
      if (r2 > CL2) continue;
      double r6 = r2 * r2 * r2;
      double df = ((24.0 * r6 - 48.0) / (r6 * r6 * r2)) * dt;
      p[X][i] += df * dx;
      p[Y][i] += df * dy;
      p[Z][i] += df * dz;
      p[X][j] -= df * dx;
      p[Y][j] -= df * dy;
      p[Z][j] -= df * dz;
    }
  }
}

// Assembly:
movslq 0x19f4bae(%rip), %rax   # 0x19f7b30
testq %rax, %rax
jle 0x3436
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
vbroadcastsd 0x20aa(%rip), %ymm0 # 0x5048
vbroadcastsd 0x20a9(%rip), %ymm1 # 0x5050
vbroadcastsd 0x2090(%rip), %ymm2 # 0x5040
vmovsd 0x2088(%rip), %xmm4     # 0x5040
vmovsd 0x2068(%rip), %xmm5     # 0x5028
vmovsd 0x2066(%rip), %xmm21    # 0x5030
vmovsd 0x2064(%rip), %xmm22    # 0x5038
leaq 0x18ab55(%rip), %rdx    # 0x18db30
leaq 0x7a1615e(%rip), %r8    # 0x7a19140
vxorpd %xmm3, %xmm3, %xmm3
leaq 0xdbfb43(%rip), %r9     # 0xdc2b30
xorl %ecx, %ecx
leaq 0x19f4b4a(%rip), %rsi   # 0x19f7b40
vbroadcastsd (%rdx,%rcx,8), %ymm8
vbroadcastsd 0x30d400(%rdx,%rcx,8), %ymm9
vbroadcastsd 0x61a800(%rdx,%rcx,8), %ymm10
vxorpd %xmm11, %xmm11, %xmm11
vxorpd %xmm12, %xmm12, %xmm12
vxorpd %xmm13, %xmm13, %xmm13
movslq (%rsi,%rcx,4), %r10
leaq 0x7708d16(%rip), %rsi   # 0x770bd40
movslq (%rsi,%rcx,4), %r11
leal 0x3(%r10), %ebx
testq %r10, %r10
cmovnsl %r10d, %ebx
andl $-0x4, %ebx
cmpq $0x4, %r10
jl 0x32e5
leaq 0xc(%r8,%r11,4), %r15
movl %ebx, %r14d
xorl %r12d, %r12d
movslq (%r15,%r12,4), %r13
movslq -0x8(%r15,%r12,4), %rsi
movslq -0xc(%r15,%r12,4), %rdi
movslq -0x4(%r15,%r12,4), %rbp
vmovapd %ymm0, %ymm19
addq $0x4, %r12
vmovsd 0x30d400(%rdx,%rsi,8), %xmm16
vmovsd 0x30d400(%rdx,%r13,8), %xmm17
vmovsd (%rdx,%rsi,8), %xmm14
vmovsd (%rdx,%r13,8), %xmm15
vmovsd 0x61a800(%rdx,%r13,8), %xmm18
vmovsd (%r9,%rdi,8), %xmm23
vmovhpd 0x30d400(%rdx,%rdi,8), %xmm16, %xmm16 # xmm16 = xmm16[0],mem[0]
vmovhpd 0x30d400(%rdx,%rbp,8), %xmm17, %xmm17 # xmm17 = xmm17[0],mem[0]
vmovhpd (%rdx,%rdi,8), %xmm14, %xmm14 # xmm14 = xmm14[0],mem[0]
vmovhpd (%rdx,%rbp,8), %xmm15, %xmm15 # xmm15 = xmm15[0],mem[0]
vmovhpd 0x61a800(%rdx,%rbp,8), %xmm18, %xmm18 # xmm18 = xmm18[0],mem[0]
vinsertf32x4 $0x1, %xmm16, %ymm17, %ymm16
vmovsd 0x61a800(%rdx,%rsi,8), %xmm17
vinsertf128 $0x1, %xmm14, %ymm15, %ymm14
vmovhpd 0x61a800(%rdx,%rdi,8), %xmm17, %xmm17 # xmm17 = xmm17[0],mem[0]
vsubpd %ymm9, %ymm16, %ymm16
vsubpd %ymm8, %ymm14, %ymm14
vinsertf32x4 $0x1, %xmm17, %ymm18, %ymm15
vmulpd %ymm16, %ymm16, %ymm17
vsubpd %ymm10, %ymm15, %ymm15
vfmadd231pd %ymm14, %ymm14, %ymm17 # ymm17 = (ymm14 * ymm14) + ymm17
vfmadd231pd %ymm15, %ymm15, %ymm17 # ymm17 = (ymm15 * ymm15) + ymm17
vmulpd %ymm17, %ymm17, %ymm18
vsubpd %ymm17, %ymm2, %ymm7
vmulpd %ymm18, %ymm17, %ymm18
vmulpd %ymm18, %ymm18, %ymm20
vfmadd213pd %ymm1, %ymm18, %ymm19 # ymm19 = (ymm18 * ymm19) + ymm1
vmulpd %ymm20, %ymm17, %ymm18
vdivpd %ymm18, %ymm19, %ymm6
vblendvpd %ymm7, %ymm3, %ymm6, %ymm6
vmulpd %ymm6, %ymm14, %ymm7
vmulpd %ymm16, %ymm6, %ymm16
vmulpd %ymm6, %ymm15, %ymm14
vextractf128 $0x1, %ymm7, %xmm6
vextractf32x4 $0x1, %ymm16, %xmm17
vextractf32x4 $0x1, %ymm14, %xmm19
vshufpd $0x1, %xmm6, %xmm6, %xmm15 # xmm15 = xmm6[1,0]
vshufpd $0x1, %xmm17, %xmm17, %xmm18 # xmm18 = xmm17[1,0]
vshufpd $0x1, %xmm19, %xmm19, %xmm20 # xmm20 = xmm19[1,0]
vaddsd %xmm15, %xmm13, %xmm13
vsubsd %xmm15, %xmm23, %xmm15
vaddsd %xmm18, %xmm12, %xmm12
vaddsd %xmm20, %xmm11, %xmm11
vmovsd %xmm15, (%r9,%rdi,8)
vaddsd %xmm6, %xmm13, %xmm13
vaddsd %xmm11, %xmm19, %xmm11
vmovsd 0x30d400(%r9,%rdi,8), %xmm15
vsubsd %xmm18, %xmm15, %xmm15
vmovsd %xmm15, 0x30d400(%r9,%rdi,8)
vmovsd 0x61a800(%r9,%rdi,8), %xmm15
vsubsd %xmm20, %xmm15, %xmm15
vmovsd %xmm15, 0x61a800(%r9,%rdi,8)
vmovsd (%r9,%rsi,8), %xmm15
vsubsd %xmm6, %xmm15, %xmm6
vshufpd $0x1, %xmm16, %xmm16, %xmm15 # xmm15 = xmm16[1,0]
vmovsd %xmm6, (%r9,%rsi,8)
vaddsd %xmm12, %xmm17, %xmm6
vmovsd 0x30d400(%r9,%rsi,8), %xmm12
vaddsd %xmm6, %xmm15, %xmm6
vsubsd %xmm17, %xmm12, %xmm12
vshufpd $0x1, %xmm14, %xmm14, %xmm17 # xmm17 = xmm14[1,0]
vaddsd %xmm11, %xmm17, %xmm11
vmovsd %xmm12, 0x30d400(%r9,%rsi,8)
vmovsd 0x61a800(%r9,%rsi,8), %xmm12
vaddsd %xmm11, %xmm14, %xmm11
vsubsd %xmm19, %xmm12, %xmm12
vmovsd %xmm12, 0x61a800(%r9,%rsi,8)
vshufpd $0x1, %xmm7, %xmm7, %xmm12 # xmm12 = xmm7[1,0]
vmovsd (%r9,%rbp,8), %xmm18
vaddsd %xmm13, %xmm12, %xmm13
vaddsd %xmm7, %xmm13, %xmm13
vsubsd %xmm12, %xmm18, %xmm12
vmovsd %xmm12, (%r9,%rbp,8)
vmovsd 0x30d400(%r9,%rbp,8), %xmm12
vsubsd %xmm15, %xmm12, %xmm12
vmovsd %xmm12, 0x30d400(%r9,%rbp,8)
vmovsd 0x61a800(%r9,%rbp,8), %xmm12
vsubsd %xmm17, %xmm12, %xmm12
vmovsd %xmm12, 0x61a800(%r9,%rbp,8)
vaddsd %xmm6, %xmm16, %xmm12
vmovsd (%r9,%r13,8), %xmm6
vsubsd %xmm7, %xmm6, %xmm6
vmovsd %xmm6, (%r9,%r13,8)
vmovsd 0x30d400(%r9,%r13,8), %xmm6
vsubsd %xmm16, %xmm6, %xmm6
vmovsd %xmm6, 0x30d400(%r9,%r13,8)
vmovsd 0x61a800(%r9,%r13,8), %xmm6
vsubsd %xmm14, %xmm6, %xmm6
vmovsd %xmm6, 0x61a800(%r9,%r13,8)
cmpq %r14, %r12
jb 0x3051
vaddsd (%r9,%rcx,8), %xmm13, %xmm13
vmovsd %xmm13, (%r9,%rcx,8)
vaddsd 0x30d400(%r9,%rcx,8), %xmm12, %xmm12
vmovsd %xmm12, 0x30d400(%r9,%rcx,8)
vaddsd 0x61a800(%r9,%rcx,8), %xmm11, %xmm11
vmovsd %xmm11, 0x61a800(%r9,%rcx,8)
cmpl %r10d, %ebx
jge 0x3420
movslq %ebx, %rsi
addq %rsi, %r11
subq %rsi, %r10
xorl %esi, %esi
shlq $0x2, %r11
leaq (%r11,%rsi,4), %rdi
movslq (%r8,%rdi), %rdi
vmovsd 0x30d400(%rdx,%rdi,8), %xmm11
vmovsd (%rdx,%rdi,8), %xmm6
vmovsd 0x61a800(%rdx,%rdi,8), %xmm7
vsubsd %xmm9, %xmm11, %xmm12
vsubsd %xmm8, %xmm6, %xmm13
vsubsd %xmm10, %xmm7, %xmm11
vmulsd %xmm12, %xmm12, %xmm14
vfmadd231sd %xmm13, %xmm13, %xmm14 # xmm14 = (xmm13 * xmm13) + xmm14
vfmadd231sd %xmm11, %xmm11, %xmm14 # xmm14 = (xmm11 * xmm11) + xmm14
vucomisd %xmm4, %xmm14
ja 0x3414
vmulsd %xmm14, %xmm14, %xmm6
vmovapd %xmm5, %xmm7
vmulsd %xmm6, %xmm14, %xmm6
vfmadd213sd %xmm21, %xmm6, %xmm7 # xmm7 = (xmm6 * xmm7) + xmm21
vmulsd %xmm6, %xmm6, %xmm6
vmulsd %xmm6, %xmm14, %xmm6
vdivsd %xmm6, %xmm7, %xmm6
vmovsd (%r9,%rcx,8), %xmm7
vmulsd %xmm22, %xmm6, %xmm6
vfmadd231sd %xmm13, %xmm6, %xmm7 # xmm7 = (xmm6 * xmm13) + xmm7
vmovsd %xmm7, (%r9,%rcx,8)
vmovsd 0x30d400(%r9,%rcx,8), %xmm7
vfmadd231sd %xmm12, %xmm6, %xmm7 # xmm7 = (xmm6 * xmm12) + xmm7
vmovsd %xmm7, 0x30d400(%r9,%rcx,8)
vmovsd 0x61a800(%r9,%rcx,8), %xmm7
vfmadd231sd %xmm11, %xmm6, %xmm7 # xmm7 = (xmm6 * xmm11) + xmm7
vmovsd %xmm7, 0x61a800(%r9,%rcx,8)
vfnmadd213sd (%r9,%rdi,8), %xmm6, %xmm13 # xmm13 = -(xmm6 * xmm13) + mem
vmovsd %xmm13, (%r9,%rdi,8)
vfnmadd213sd 0x30d400(%r9,%rdi,8), %xmm6, %xmm12 # xmm12 = -(xmm6 * xmm12) + mem
vmovsd %xmm12, 0x30d400(%r9,%rdi,8)
vfnmadd213sd 0x61a800(%r9,%rdi,8), %xmm6, %xmm11 # xmm11 = -(xmm6 * xmm11) + mem
vmovsd %xmm11, 0x61a800(%r9,%rdi,8)
incq %rsi
cmpq %rsi, %r10
jne 0x3331
incq %rcx
cmpq %rax, %rcx
jne 0x2fef
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq