// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
vmovsd 0x2120(%rip), %xmm0     # 0x4040
vmovsd 0x2100(%rip), %xmm1     # 0x4028
vmovsd 0x2100(%rip), %xmm2     # 0x4030
vmovsd 0x2100(%rip), %xmm3     # 0x4038
movl 0x325ec42(%rip), %eax   # 0x3260b80
leaq 0x18ac0b(%rip), %rdx    # 0x18cb50
leaq 0x8f72e44(%rip), %rsi   # 0x8f74d90
leaq 0x90f983d(%rip), %rdi   # 0x90fb790
leaq 0x325ec36(%rip), %r8    # 0x3260b90
leaq 0xdbfbef(%rip), %r9     # 0xdc1b50
movl %eax, %ecx
sarl $0x1f, %ecx
andnl %eax, %ecx, %eax
xorl %ecx, %ecx
cmpq %rax, %rcx
je 0x20cf
movslq (%rsi,%rcx,4), %r11
movq %rcx, %r10
shlq $0x5, %r10
vxorpd %xmm10, %xmm10, %xmm10
vxorpd %xmm6, %xmm6, %xmm6
vxorpd %xmm9, %xmm9, %xmm9
vxorpd %xmm5, %xmm5, %xmm5
vxorpd %xmm8, %xmm8, %xmm8
xorl %ebp, %ebp
vmovsd 0x10(%r10,%rdx), %xmm4
vmovapd (%r10,%rdx), %xmm7
movslq (%rdi,%r11,4), %r14
movq %r14, %rbx
shlq $0x5, %rbx
vmovapd (%rbx,%rdx), %xmm11
vmovsd 0x10(%rbx,%rdx), %xmm12
movslq (%r8,%rcx,4), %rbx
addq %r11, %rbx
movslq %ebp, %r12
cmpq %rbx, %r11
jge 0x2077
vsubpd %xmm7, %xmm11, %xmm13
movl %r14d, %r15d
movslq 0x4(%rdi,%r11,4), %r14
vsubsd %xmm4, %xmm12, %xmm14
incq %r11
vmulpd %xmm13, %xmm13, %xmm11
movq %r14, %r13
shlq $0x5, %r13
vshufpd $0x1, %xmm11, %xmm11, %xmm15 # xmm15 = xmm11[1,0]
vmovapd (%r13,%rdx), %xmm11
vmovsd 0x10(%r13,%rdx), %xmm12
vfmadd231sd %xmm13, %xmm13, %xmm15 # xmm15 = (xmm13 * xmm13) + xmm15
vfmadd231sd %xmm14, %xmm14, %xmm15 # xmm15 = (xmm14 * xmm14) + xmm15
vucomisd %xmm0, %xmm15
ja 0x1fc4
vmovddup %xmm6, %xmm16           # xmm16 = xmm6[0,0]
shlq $0x5, %r12
vfmadd231sd %xmm9, %xmm6, %xmm5 # xmm5 = (xmm6 * xmm9) + xmm5
movl %r15d, %ebp
vfmadd231pd %xmm10, %xmm16, %xmm8 # xmm8 = (xmm16 * xmm10) + xmm8
vfnmadd213pd (%r12,%r9), %xmm16, %xmm10 # xmm10 = -(xmm16 * xmm10) + mem
vmovapd %xmm10, (%r12,%r9)
vmovapd %xmm13, %xmm10
vfnmadd213sd 0x10(%r12,%r9), %xmm6, %xmm9 # xmm9 = -(xmm6 * xmm9) + mem
vmulsd %xmm15, %xmm15, %xmm6
vmulsd %xmm6, %xmm15, %xmm6
vmovsd %xmm9, 0x10(%r12,%r9)
vmovapd %xmm1, %xmm9
vfmadd213sd %xmm2, %xmm6, %xmm9 # xmm9 = (xmm6 * xmm9) + xmm2
vmulsd %xmm6, %xmm6, %xmm6
vmulsd %xmm6, %xmm15, %xmm6
vdivsd %xmm6, %xmm9, %xmm6
vmovapd %xmm14, %xmm9
vmulsd %xmm3, %xmm6, %xmm6
jmp 0x1fc4
shlq $0x5, %r12
vmovddup %xmm6, %xmm4            # xmm4 = xmm6[0,0]
vfmadd231sd %xmm9, %xmm6, %xmm5 # xmm5 = (xmm6 * xmm9) + xmm5
incq %rcx
vmovapd (%r12,%r9), %xmm7
vfmadd231pd %xmm10, %xmm4, %xmm8 # xmm8 = (xmm4 * xmm10) + xmm8
vfnmadd231pd %xmm10, %xmm4, %xmm7 # xmm7 = -(xmm4 * xmm10) + xmm7
vmovapd %xmm7, (%r12,%r9)
vmovsd 0x10(%r12,%r9), %xmm7
vfnmadd231sd %xmm9, %xmm6, %xmm7 # xmm7 = -(xmm6 * xmm9) + xmm7
vmovsd %xmm7, 0x10(%r12,%r9)
vaddpd (%r10,%r9), %xmm8, %xmm4
vmovapd %xmm4, (%r10,%r9)
vaddsd 0x10(%r10,%r9), %xmm5, %xmm4
vmovsd %xmm4, 0x10(%r10,%r9)
jmp 0x1f6d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq