// File: /workspace/github_cpp_makefile_star2_O1/kaityo256[P]lj_simd/force_aos.cpp
// Function: force_sorted_swp()
void
force_sorted_swp(void) {
  const int pn = particle_number;
  for (int i = 0; i < pn; i++) {
    const double qix = q[i][X];
    const double qiy = q[i][Y];
    const double qiz = q[i][Z];
    double pfx = 0;
    double pfy = 0;
    double pfz = 0;
    const int kp = pointer[i];
    int ja = sorted_list[kp];
    double dxa = q[ja][X] - qix;
    double dya = q[ja][Y] - qiy;
    double dza = q[ja][Z] - qiz;
    double df = 0.0;
    double dxb = 0.0, dyb = 0.0, dzb = 0.0;
    int jb = 0;

    const int np = number_of_partners[i];
    for (int k = kp; k < np + kp; k++) {

      const double dx = dxa;
      const double dy = dya;
      const double dz = dza;
      double r2 = (dx * dx + dy * dy + dz * dz);
      const int j = ja;
      ja = sorted_list[k + 1];
      dxa = q[ja][X] - qix;
      dya = q[ja][Y] - qiy;
      dza = q[ja][Z] - qiz;
      if (r2 > CL2)continue;
      pfx += df * dxb;
      pfy += df * dyb;
      pfz += df * dzb;
      p[jb][X] -= df * dxb;
      p[jb][Y] -= df * dyb;
      p[jb][Z] -= df * dzb;
      const double r6 = r2 * r2 * r2;
      df = ((24.0 * r6 - 48.0) / (r6 * r6 * r2)) * dt;
      jb = j;
      dxb = dx;
      dyb = dy;
      dzb = dz;
    }
    p[jb][X] -= df * dxb;
    p[jb][Y] -= df * dyb;
    p[jb][Z] -= df * dzb;
    p[i][X] += pfx + df * dxb;
    p[i][Y] += pfy + df * dyb;
    p[i][Z] += pfz + df * dzb;
  }
}

// Assembly:
movslq 0x325eaa4(%rip), %rax   # 0x3261bc0
testq %rax, %rax
jle 0x32ec
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
xorl %ecx, %ecx
leaq 0x18aa5c(%rip), %rdx    # 0x18db90
leaq 0x325ea95(%rip), %rsi   # 0x3261bd0
leaq 0x8f72c8e(%rip), %rdi   # 0x8f75dd0
leaq 0x90f9687(%rip), %r8    # 0x90fc7d0
vmovsd 0x1eef(%rip), %xmm0     # 0x5040
leaq 0xdbfa38(%rip), %r9     # 0xdc2b90
vmovsd 0x1ec8(%rip), %xmm1     # 0x5028
vmovsd 0x1ec8(%rip), %xmm2     # 0x5030
vmovsd 0x1ec8(%rip), %xmm3     # 0x5038
movq %rcx, %r10
shlq $0x5, %r10
movslq (%rsi,%rcx,4), %r11
testq %r11, %r11
jle 0x3272
vmovapd (%r10,%rdx), %xmm9
vmovsd 0x10(%r10,%rdx), %xmm10
movslq (%rdi,%rcx,4), %rbx
addq %rbx, %r11
movslq (%r8,%rbx,4), %r14
movq %r14, %r15
shlq $0x5, %r15
vmovsd 0x10(%r15,%rdx), %xmm12
vmovapd (%r15,%rdx), %xmm11
vxorpd %xmm6, %xmm6, %xmm6
xorl %ebp, %ebp
vxorpd %xmm4, %xmm4, %xmm4
vxorpd %xmm7, %xmm7, %xmm7
vxorpd %xmm5, %xmm5, %xmm5
vxorpd %xmm8, %xmm8, %xmm8
vsubsd %xmm10, %xmm12, %xmm12
vsubpd %xmm9, %xmm11, %xmm11
vmulpd %xmm11, %xmm11, %xmm13
vshufpd $0x1, %xmm13, %xmm13, %xmm13 # xmm13 = xmm13[1,0]
vfmadd231sd %xmm11, %xmm11, %xmm13 # xmm13 = (xmm11 * xmm11) + xmm13
vfmadd231sd %xmm12, %xmm12, %xmm13 # xmm13 = (xmm12 * xmm12) + xmm13
vucomisd %xmm0, %xmm13
ja 0x3248
vmovddup %xmm5, %xmm14           # xmm14 = xmm5[0,0]
vfmadd231pd %xmm6, %xmm14, %xmm8 # xmm8 = (xmm14 * xmm6) + xmm8
vfmadd231sd %xmm7, %xmm5, %xmm4 # xmm4 = (xmm5 * xmm7) + xmm4
movslq %ebp, %r15
shlq $0x5, %r15
vfnmadd213pd (%r15,%r9), %xmm14, %xmm6 # xmm6 = -(xmm14 * xmm6) + mem
vmovapd %xmm6, (%r15,%r9)
vfnmadd213sd 0x10(%r15,%r9), %xmm5, %xmm7 # xmm7 = -(xmm5 * xmm7) + mem
vmovsd %xmm7, 0x10(%r15,%r9)
vmulsd %xmm13, %xmm13, %xmm5
vmulsd %xmm5, %xmm13, %xmm5
vmovapd %xmm1, %xmm6
vfmadd213sd %xmm2, %xmm5, %xmm6 # xmm6 = (xmm5 * xmm6) + xmm2
vmulsd %xmm5, %xmm5, %xmm5
vmulsd %xmm5, %xmm13, %xmm5
vdivsd %xmm5, %xmm6, %xmm5
vmulsd %xmm3, %xmm5, %xmm5
vmovapd %xmm12, %xmm7
movl %r14d, %ebp
vmovapd %xmm11, %xmm6
movslq 0x4(%r8,%rbx,4), %r14
incq %rbx
movq %r14, %r15
shlq $0x5, %r15
vmovaps (%r15,%rdx), %xmm11
vmovsd 0x10(%r15,%rdx), %xmm12
cmpq %r11, %rbx
jl 0x31c7
movslq %ebp, %r11
jmp 0x328a
vxorpd %xmm6, %xmm6, %xmm6
vxorpd %xmm5, %xmm5, %xmm5
vxorpd %xmm7, %xmm7, %xmm7
xorl %r11d, %r11d
vxorpd %xmm4, %xmm4, %xmm4
vxorpd %xmm8, %xmm8, %xmm8
shlq $0x5, %r11
vmovddup %xmm5, %xmm9            # xmm9 = xmm5[0,0]
vmovapd (%r11,%r9), %xmm10
vfnmadd231pd %xmm6, %xmm9, %xmm10 # xmm10 = -(xmm9 * xmm6) + xmm10
vmovapd %xmm10, (%r11,%r9)
vmovsd 0x10(%r11,%r9), %xmm10
vfnmadd231sd %xmm7, %xmm5, %xmm10 # xmm10 = -(xmm5 * xmm7) + xmm10
vmovsd %xmm10, 0x10(%r11,%r9)
vfmadd231pd %xmm6, %xmm9, %xmm8 # xmm8 = (xmm9 * xmm6) + xmm8
vaddpd (%r10,%r9), %xmm8, %xmm6
vmovapd %xmm6, (%r10,%r9)
vfmadd231sd %xmm7, %xmm5, %xmm4 # xmm4 = (xmm5 * xmm7) + xmm4
vaddsd 0x10(%r10,%r9), %xmm4, %xmm4
vmovsd %xmm4, 0x10(%r10,%r9)
incq %rcx
cmpq %rax, %rcx
jne 0x3170
popq %rbx
popq %r14
popq %r15
popq %rbp
retq