// File: 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:
movq %rdi, -0x8(%rsp)
movq -0x8(%rsp), %rax
movq %rax, -0x68(%rsp)
movl $0x0, -0xc(%rsp)
movq -0x68(%rsp), %rcx
movl -0xc(%rsp), %eax
cmpl 0x50(%rcx), %eax
jge 0x425f
movl $0x0, -0x14(%rsp)
cmpl $0x3, -0x14(%rsp)
jge 0x4250
movq -0x68(%rsp), %rax
movq 0x18(%rax), %rax
movslq -0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0x421d
jmp 0x4252
movl -0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rsp)
jmp 0x4207
movq -0x68(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x80(%rax)
movsd 0x4de1(%rip), %xmm0     # 0x9058
divsd 0x60(%rax), %xmm0
movsd %xmm0, -0x60(%rsp)
movl $0x0, -0xc(%rsp)
movq -0x68(%rsp), %rcx
movl -0xc(%rsp), %eax
cmpl 0x50(%rcx), %eax
jge 0x4562
movl -0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rsp)
movq -0x68(%rsp), %rcx
movl -0x10(%rsp), %eax
cmpl 0x50(%rcx), %eax
jge 0x4550
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rsp)
movl $0x0, -0x14(%rsp)
cmpl $0x3, -0x14(%rsp)
jge 0x4404
movq -0x68(%rsp), %rax
movq 0x8(%rax), %rcx
movslq -0xc(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x14(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movslq -0x10(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x14(%rsp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movslq -0x14(%rsp), %rcx
movsd %xmm0, -0x38(%rsp,%rcx,8)
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x70(%rsp)
movslq -0x14(%rsp), %rax
movsd -0x38(%rsp,%rax,8), %xmm0
mulsd -0x60(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4363
movslq -0x14(%rsp), %rax
movsd -0x38(%rsp,%rax,8), %xmm0
movsd -0x60(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x4db3(%rip), %xmm1     # 0x9108
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x74(%rsp)
jmp 0x438c
movslq -0x14(%rsp), %rax
movsd -0x38(%rsp,%rax,8), %xmm0
movsd -0x60(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x4da0(%rip), %xmm1     # 0x9120
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x74(%rsp)
movsd -0x70(%rsp), %xmm0
movl -0x74(%rsp), %eax
cvtsi2sd %eax, %xmm2
movslq -0x14(%rsp), %rax
movsd -0x38(%rsp,%rax,8), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rsp,%rax,8)
movslq -0x14(%rsp), %rax
movsd -0x38(%rsp,%rax,8), %xmm0
movslq -0x14(%rsp), %rax
movsd -0x38(%rsp,%rax,8), %xmm2
movsd -0x40(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rsp)
movl -0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0x42ca
movq -0x68(%rsp), %rax
movsd 0x4c47(%rip), %xmm0     # 0x9058
divsd -0x40(%rsp), %xmm0
movsd %xmm0, -0x48(%rsp)
movsd -0x48(%rsp), %xmm0
mulsd -0x48(%rsp), %xmm0
mulsd -0x48(%rsp), %xmm0
movsd %xmm0, -0x50(%rsp)
movsd 0x4cdb(%rip), %xmm0     # 0x9118
mulsd -0x50(%rsp), %xmm0
movsd -0x50(%rsp), %xmm2
movsd 0x4c07(%rip), %xmm1     # 0x9058
subsd %xmm1, %xmm2
movsd 0x80(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rax)
movsd -0x50(%rsp), %xmm0
mulsd -0x48(%rsp), %xmm0
movsd -0x50(%rsp), %xmm1
movsd 0x4c81(%rip), %xmm2     # 0x9108
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rsp)
movl $0x0, -0x14(%rsp)
cmpl $0x3, -0x14(%rsp)
jge 0x453e
movq -0x68(%rsp), %rax
movsd -0x58(%rsp), %xmm0
movslq -0x14(%rsp), %rcx
movsd -0x38(%rsp,%rcx,8), %xmm2
movq 0x18(%rax), %rcx
movslq -0xc(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x14(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
movsd -0x58(%rsp), %xmm0
movslq -0x14(%rsp), %rcx
movsd -0x38(%rsp,%rcx,8), %xmm2
movq 0x18(%rax), %rax
movslq -0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0x449d
jmp 0x4540
movl -0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rsp)
jmp 0x42a7
jmp 0x4552
movl -0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rsp)
jmp 0x428a
retq
nopw %cs:(%rax,%rax)