// File: /workspace/github_cpp_makefile_star2_O1/joraso[P]Glassius/Particles.cpp
// Function: Fluid::UpdateForces()
void Fluid::UpdateForces(){
    /* Exicutes the forceloop for the simple Lennard-Jones fluid, updating the
    forces and potential energy. */
    int i, j, k;
    
    // Zero out the forces and potential energy
    for(i=0;i<N;i++){for(k=0;k<3;k++){f[i][k]=0;};};
    potential_energy = 0;
    
    // force-loop variables we need
    double rij[3], r2, r2inv, r6inv, fij;
    double Linv = 1.0 / sidelength;
    
    // The force loop (dun dun duuuuun)
    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            // calculating the radius
            r2 = 0;
            for(k=0;k<3;k++){
                rij[k] = r[i][k] - r[j][k];
                // imposing periodic boundary conditions
                rij[k] -= sidelength*fastround(rij[k]*Linv);
                r2 += rij[k]*rij[k];
            }
            r2inv = (1.0)/r2;
            r6inv = r2inv*r2inv*r2inv;
            // Updating the potential energy
            potential_energy += 4*r6inv*(r6inv-1);
            // Updating the forces
            fij = r6inv*r2inv*(r6inv-0.5);
            for(k=0;k<3;k++){
                f[i][k] += fij*rij[k];
                f[j][k] -= fij*rij[k];
            }
        }
    }
    return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movslq 0x50(%rdi), %rax
testq %rax, %rax
jle 0x372a
movq 0x18(%rdi), %rcx
xorl %edx, %edx
xorpd %xmm0, %xmm0
movq (%rcx,%rdx,8), %rsi
movupd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x3712
movq $0x0, 0x80(%rdi)
testl %eax, %eax
jle 0x38c0
movsd 0x4913(%rip), %xmm0     # 0x8058
movapd %xmm0, %xmm1
divsd 0x60(%rdi), %xmm1
movq 0x8(%rdi), %rcx
movq 0x18(%rdi), %rdx
movl $0x1, %esi
xorl %r8d, %r8d
movapd 0x49fa(%rip), %xmm2     # 0x8160
xorpd %xmm3, %xmm3
leaq 0x49ff(%rip), %r9       # 0x8170
movsd 0x499f(%rip), %xmm4     # 0x8118
movsd 0x499f(%rip), %xmm5     # 0x8120
movsd 0x499f(%rip), %xmm6     # 0x8128
movq %r8, %r11
incq %r8
cmpq %rax, %r8
jae 0x38b4
movq (%rcx,%r11,8), %r10
movq (%rdx,%r11,8), %r11
movq %rsi, %rbx
movq (%rcx,%rbx,8), %r14
movsd 0x60(%rdi), %xmm7
xorpd %xmm2, %xmm7
xorpd %xmm8, %xmm8
xorl %r15d, %r15d
movsd (%r10,%r15,8), %xmm9
subsd (%r14,%r15,8), %xmm9
movapd %xmm1, %xmm10
mulsd %xmm9, %xmm10
xorl %r12d, %r12d
ucomisd %xmm3, %xmm10
setb %r12b
addsd (%r9,%r12,8), %xmm10
cvttpd2dq %xmm10, %xmm10
cvtdq2pd %xmm10, %xmm10
mulsd %xmm7, %xmm10
addsd %xmm9, %xmm10
movsd %xmm10, -0x18(%rsp,%r15,8)
mulsd %xmm10, %xmm10
addsd %xmm10, %xmm8
incq %r15
cmpq $0x3, %r15
jne 0x37b8
movapd %xmm0, %xmm9
divsd %xmm8, %xmm9
movapd %xmm9, %xmm7
mulsd %xmm9, %xmm7
mulsd %xmm9, %xmm7
movapd %xmm7, %xmm8
mulsd %xmm4, %xmm8
movapd %xmm7, %xmm10
addsd %xmm5, %xmm10
mulsd %xmm8, %xmm10
addsd 0x80(%rdi), %xmm10
movsd %xmm10, 0x80(%rdi)
mulsd %xmm7, %xmm9
addsd %xmm6, %xmm7
mulsd %xmm9, %xmm7
movq (%rdx,%rbx,8), %r14
movapd %xmm7, %xmm8
xorpd %xmm2, %xmm8
xorl %r15d, %r15d
movsd -0x18(%rsp,%r15,8), %xmm9
movapd %xmm7, %xmm10
mulsd %xmm9, %xmm10
addsd (%r11,%r15,8), %xmm10
movsd %xmm10, (%r11,%r15,8)
mulsd %xmm8, %xmm9
addsd (%r14,%r15,8), %xmm9
movsd %xmm9, (%r14,%r15,8)
incq %r15
cmpq $0x3, %r15
jne 0x3871
incq %rbx
cmpq %rax, %rbx
jne 0x37a3
incq %rsi
cmpq %rax, %r8
jne 0x3789
popq %rbx
popq %r12
popq %r14
popq %r15
retq