// File: joraso[P]Glassius/Particles.cpp
// Function: Glass::UpdateForces()
void Glass::UpdateForces(){
    /* Excicutes the forceloop for the Kob-Anderson glass mixture, 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;
    
    // factors for adjusting the forces and distances:
    double rABinv = (1.0/0.8);
    double rBBinv = (1.0/0.88);
    double fAB = 1.5*rABinv*rABinv;
    double fBB = 0.5*rBBinv*rABinv;
    
    // The force loop - AA interactions
    for(i=0;i<Na;i++){
        for(j=i+1;j<Na;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];
            }
        }
        // AB interactions - sigma = 0.8, epsilon = 1.5
        for(j=Na;j<N;j++){
            r2 = 0;
            for(k=0;k<3;k++){
                rij[k] = (r[i][k] - r[j][k]);
                rij[k] -= sidelength*fastround(rij[k]*Linv);
                // effective radius adjusted by sigma
                rij[k] *= rABinv;
                r2 += rij[k]*rij[k];
            }
            r2inv = (1.0)/r2;
            r6inv = r2inv*r2inv*r2inv;
            // energy and forces adjusted by epsilon and force-factor
            potential_energy += (1.5)*4*r6inv*(r6inv-1);
            fij = fAB*r6inv*r2inv*(r6inv-0.5);
            for(k=0;k<3;k++){
                f[i][k] += fij*rij[k];
                f[j][k] -= fij*rij[k];
            }
        }
    }
    // BB interactions - sigma = 0.88, epsilon = 0.5
    for(i=Na;i<N;i++){
        for(j=i+1;j<N;j++){
            r2 = 0;
            for(k=0;k<3;k++){
                rij[k] = r[i][k] - r[j][k];
                rij[k] -= sidelength*fastround(rij[k]*Linv);
                // effective radius adjusted by sigma
                rij[k] *= rBBinv;
                r2 += rij[k]*rij[k];
            }
            r2inv = (1.0)/r2;
            r6inv = r2inv*r2inv*r2inv;
            // Update me!!
            potential_energy += (0.5)*4*r6inv*(r6inv-1);
            fij = fBB*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:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, -0x50(%rsp)
movl $0x0, 0x2c(%rsp)
movq -0x50(%rsp), %rcx
movl 0x2c(%rsp), %eax
cmpl 0x50(%rcx), %eax
jge 0x45e3
movl $0x0, 0x24(%rsp)
cmpl $0x3, 0x24(%rsp)
jge 0x45d4
movq -0x50(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x24(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x45a1
jmp 0x45d6
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x458b
movq -0x50(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x80(%rax)
movsd 0x4a5d(%rip), %xmm0     # 0x9058
divsd 0x60(%rax), %xmm0
movsd %xmm0, -0x28(%rsp)
movsd 0x4b22(%rip), %xmm0     # 0x9130
movsd %xmm0, -0x30(%rsp)
movsd 0x4b0c(%rip), %xmm0     # 0x9128
movsd %xmm0, -0x38(%rsp)
movsd 0x4ae6(%rip), %xmm0     # 0x9110
mulsd -0x30(%rsp), %xmm0
mulsd -0x30(%rsp), %xmm0
movsd %xmm0, -0x40(%rsp)
movsd 0x4ac4(%rip), %xmm0     # 0x9108
mulsd -0x38(%rsp), %xmm0
mulsd -0x30(%rsp), %xmm0
movsd %xmm0, -0x48(%rsp)
movl $0x0, 0x2c(%rsp)
movq -0x50(%rsp), %rcx
movl 0x2c(%rsp), %eax
cmpl 0x88(%rcx), %eax
jge 0x4bfb
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
movq -0x50(%rsp), %rcx
movl 0x28(%rsp), %eax
cmpl 0x88(%rcx), %eax
jge 0x4920
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x3, 0x24(%rsp)
jge 0x47d6
movq -0x50(%rsp), %rax
movq 0x8(%rax), %rcx
movslq 0x2c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movslq 0x28(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movslq 0x24(%rsp), %rcx
movsd %xmm0, (%rsp,%rcx,8)
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x58(%rsp)
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
mulsd -0x28(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x473a
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movsd -0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x49dc(%rip), %xmm1     # 0x9108
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x5c(%rsp)
jmp 0x4762
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movsd -0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x49ca(%rip), %xmm1     # 0x9120
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x5c(%rsp)
movsd -0x58(%rsp), %xmm0
movl -0x5c(%rsp), %eax
cvtsi2sd %eax, %xmm2
movslq 0x24(%rsp), %rax
movsd (%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, (%rsp,%rax,8)
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm2
movsd -0x8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x46a4
movq -0x50(%rsp), %rax
movsd 0x4875(%rip), %xmm0     # 0x9058
divsd -0x8(%rsp), %xmm0
movsd %xmm0, -0x10(%rsp)
movsd -0x10(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
movsd %xmm0, -0x18(%rsp)
movsd 0x4909(%rip), %xmm0     # 0x9118
mulsd -0x18(%rsp), %xmm0
movsd -0x18(%rsp), %xmm2
movsd 0x4835(%rip), %xmm1     # 0x9058
subsd %xmm1, %xmm2
movsd 0x80(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rax)
movsd -0x18(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
movsd -0x18(%rsp), %xmm1
movsd 0x48af(%rip), %xmm2     # 0x9108
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x3, 0x24(%rsp)
jge 0x490e
movq -0x50(%rsp), %rax
movsd -0x20(%rsp), %xmm0
movslq 0x24(%rsp), %rcx
movsd (%rsp,%rcx,8), %xmm2
movq 0x18(%rax), %rcx
movslq 0x2c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
movsd -0x20(%rsp), %xmm0
movslq 0x24(%rsp), %rcx
movsd (%rsp,%rcx,8), %xmm2
movq 0x18(%rax), %rax
movslq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x24(%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 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x486f
jmp 0x4910
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x467e
movq -0x50(%rsp), %rax
movl 0x88(%rax), %eax
movl %eax, 0x28(%rsp)
movq -0x50(%rsp), %rcx
movl 0x28(%rsp), %eax
cmpl 0x50(%rcx), %eax
jge 0x4be9
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x3, 0x24(%rsp)
jge 0x4a99
movq -0x50(%rsp), %rax
movq 0x8(%rax), %rcx
movslq 0x2c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movslq 0x28(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movslq 0x24(%rsp), %rcx
movsd %xmm0, (%rsp,%rcx,8)
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x68(%rsp)
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
mulsd -0x28(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x49e8
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movsd -0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x472e(%rip), %xmm1     # 0x9108
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x6c(%rsp)
jmp 0x4a10
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movsd -0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x471c(%rip), %xmm1     # 0x9120
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x6c(%rsp)
movsd -0x68(%rsp), %xmm0
movl -0x6c(%rsp), %eax
cvtsi2sd %eax, %xmm2
movslq 0x24(%rsp), %rax
movsd (%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, (%rsp,%rax,8)
movsd -0x30(%rsp), %xmm0
movslq 0x24(%rsp), %rax
mulsd (%rsp,%rax,8), %xmm0
movsd %xmm0, (%rsp,%rax,8)
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm2
movsd -0x8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x4952
movq -0x50(%rsp), %rax
movsd 0x45b2(%rip), %xmm0     # 0x9058
divsd -0x8(%rsp), %xmm0
movsd %xmm0, -0x10(%rsp)
movsd -0x10(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
movsd %xmm0, -0x18(%rsp)
movsd 0x466e(%rip), %xmm0     # 0x9140
mulsd -0x18(%rsp), %xmm0
movsd -0x18(%rsp), %xmm2
movsd 0x4572(%rip), %xmm1     # 0x9058
subsd %xmm1, %xmm2
movsd 0x80(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rax)
movsd -0x40(%rsp), %xmm0
mulsd -0x18(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
movsd -0x18(%rsp), %xmm1
movsd 0x45e6(%rip), %xmm2     # 0x9108
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x3, 0x24(%rsp)
jge 0x4bd7
movq -0x50(%rsp), %rax
movsd -0x20(%rsp), %xmm0
movslq 0x24(%rsp), %rcx
movsd (%rsp,%rcx,8), %xmm2
movq 0x18(%rax), %rcx
movslq 0x2c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
movsd -0x20(%rsp), %xmm0
movslq 0x24(%rsp), %rcx
movsd (%rsp,%rcx,8), %xmm2
movq 0x18(%rax), %rax
movslq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x24(%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 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x4b38
jmp 0x4bd9
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x492f
jmp 0x4beb
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x465e
movq -0x50(%rsp), %rax
movl 0x88(%rax), %eax
movl %eax, 0x2c(%rsp)
movq -0x50(%rsp), %rcx
movl 0x2c(%rsp), %eax
cmpl 0x50(%rcx), %eax
jge 0x4ef3
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
movq -0x50(%rsp), %rcx
movl 0x28(%rsp), %eax
cmpl 0x50(%rcx), %eax
jge 0x4ee1
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x3, 0x24(%rsp)
jge 0x4d91
movq -0x50(%rsp), %rax
movq 0x8(%rax), %rcx
movslq 0x2c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x8(%rax), %rcx
movslq 0x28(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movslq 0x24(%rsp), %rcx
movsd %xmm0, (%rsp,%rcx,8)
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x78(%rsp)
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
mulsd -0x28(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4ce0
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movsd -0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x4436(%rip), %xmm1     # 0x9108
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x7c(%rsp)
jmp 0x4d08
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movsd -0x28(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x4424(%rip), %xmm1     # 0x9120
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x7c(%rsp)
movsd -0x78(%rsp), %xmm0
movl -0x7c(%rsp), %eax
cvtsi2sd %eax, %xmm2
movslq 0x24(%rsp), %rax
movsd (%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, (%rsp,%rax,8)
movsd -0x38(%rsp), %xmm0
movslq 0x24(%rsp), %rax
mulsd (%rsp,%rax,8), %xmm0
movsd %xmm0, (%rsp,%rax,8)
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm0
movslq 0x24(%rsp), %rax
movsd (%rsp,%rax,8), %xmm2
movsd -0x8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x4c4a
movq -0x50(%rsp), %rax
movsd 0x42ba(%rip), %xmm0     # 0x9058
divsd -0x8(%rsp), %xmm0
movsd %xmm0, -0x10(%rsp)
movsd -0x10(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
movsd %xmm0, -0x18(%rsp)
movsd 0x436e(%rip), %xmm0     # 0x9138
mulsd -0x18(%rsp), %xmm0
movsd -0x18(%rsp), %xmm2
movsd 0x427a(%rip), %xmm1     # 0x9058
subsd %xmm1, %xmm2
movsd 0x80(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rax)
movsd -0x48(%rsp), %xmm0
mulsd -0x18(%rsp), %xmm0
mulsd -0x10(%rsp), %xmm0
movsd -0x18(%rsp), %xmm1
movsd 0x42ee(%rip), %xmm2     # 0x9108
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rsp)
movl $0x0, 0x24(%rsp)
cmpl $0x3, 0x24(%rsp)
jge 0x4ecf
movq -0x50(%rsp), %rax
movsd -0x20(%rsp), %xmm0
movslq 0x24(%rsp), %rcx
movsd (%rsp,%rcx,8), %xmm2
movq 0x18(%rax), %rcx
movslq 0x2c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x24(%rsp), %rdx
movsd (%rcx,%rdx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
movsd -0x20(%rsp), %xmm0
movslq 0x24(%rsp), %rcx
movsd (%rsp,%rcx,8), %xmm2
movq 0x18(%rax), %rax
movslq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x24(%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 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x4e30
jmp 0x4ed1
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x4c27
jmp 0x4ee3
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x4c0a
addq $0x38, %rsp
retq
nopl (%rax,%rax)