// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movslq 0x50(%rdi), %rax
testq %rax, %rax
jle 0x38fb
movq 0x18(%rdi), %rcx
xorl %edx, %edx
xorps %xmm0, %xmm0
movq (%rcx,%rdx,8), %rsi
movups %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x38e4
movq $0x0, 0x80(%rdi)
movsd 0x474a(%rip), %xmm0     # 0x8058
movapd %xmm0, %xmm1
divsd 0x60(%rdi), %xmm1
movslq 0x88(%rdi), %rcx
testq %rcx, %rcx
jle 0x3bec
movq 0x8(%rdi), %rdx
movq 0x18(%rdi), %rsi
movl $0x1, %r8d
xorl %r9d, %r9d
movapd 0x4820(%rip), %xmm2     # 0x8160
xorpd %xmm3, %xmm3
leaq 0x4825(%rip), %r10      # 0x8170
movsd 0x47c5(%rip), %xmm4     # 0x8118
movsd 0x47c5(%rip), %xmm5     # 0x8120
movsd 0x47c5(%rip), %xmm6     # 0x8128
movsd 0x47c5(%rip), %xmm7     # 0x8130
movsd 0x47c4(%rip), %xmm8     # 0x8138
movsd 0x47c3(%rip), %xmm9     # 0x8140
movq %r9, %r11
incq %r9
cmpq %rcx, %r9
jae 0x3aaa
movq (%rdx,%r11,8), %rbx
movq (%rsi,%r11,8), %r14
movq %r8, %r15
movq (%rdx,%r15,8), %r12
movsd 0x60(%rdi), %xmm10
xorpd %xmm2, %xmm10
xorpd %xmm11, %xmm11
xorl %r13d, %r13d
movsd (%rbx,%r13,8), %xmm12
subsd (%r12,%r13,8), %xmm12
movapd %xmm1, %xmm13
mulsd %xmm12, %xmm13
xorl %ebp, %ebp
ucomisd %xmm3, %xmm13
setb %bpl
addsd (%r10,%rbp,8), %xmm13
cvttpd2dq %xmm13, %xmm13
cvtdq2pd %xmm13, %xmm13
mulsd %xmm10, %xmm13
addsd %xmm12, %xmm13
movsd %xmm13, -0x18(%rsp,%r13,8)
mulsd %xmm13, %xmm13
addsd %xmm13, %xmm11
incq %r13
cmpq $0x3, %r13
jne 0x39ae
movapd %xmm0, %xmm12
divsd %xmm11, %xmm12
movapd %xmm12, %xmm10
mulsd %xmm12, %xmm10
mulsd %xmm12, %xmm10
movapd %xmm10, %xmm11
mulsd %xmm4, %xmm11
movapd %xmm10, %xmm13
addsd %xmm5, %xmm13
mulsd %xmm11, %xmm13
addsd 0x80(%rdi), %xmm13
movsd %xmm13, 0x80(%rdi)
mulsd %xmm10, %xmm12
addsd %xmm6, %xmm10
mulsd %xmm12, %xmm10
movq (%rsi,%r15,8), %r12
movapd %xmm10, %xmm11
xorpd %xmm2, %xmm11
xorl %r13d, %r13d
movsd -0x18(%rsp,%r13,8), %xmm12
movapd %xmm10, %xmm13
mulsd %xmm12, %xmm13
addsd (%r14,%r13,8), %xmm13
movsd %xmm13, (%r14,%r13,8)
mulsd %xmm11, %xmm12
addsd (%r12,%r13,8), %xmm12
movsd %xmm12, (%r12,%r13,8)
incq %r13
cmpq $0x3, %r13
jne 0x3a67
incq %r15
cmpq %rcx, %r15
jne 0x3997
cmpl %eax, %ecx
jge 0x3be0
movq (%rdx,%r11,8), %rbx
movq (%rsi,%r11,8), %r11
movq %rcx, %r14
movq (%rdx,%r14,8), %r15
movsd 0x60(%rdi), %xmm10
xorpd %xmm2, %xmm10
xorpd %xmm11, %xmm11
xorl %r12d, %r12d
movsd (%rbx,%r12,8), %xmm12
subsd (%r15,%r12,8), %xmm12
movapd %xmm1, %xmm13
mulsd %xmm12, %xmm13
xorl %r13d, %r13d
ucomisd %xmm3, %xmm13
setb %r13b
addsd (%r10,%r13,8), %xmm13
cvttpd2dq %xmm13, %xmm13
cvtdq2pd %xmm13, %xmm13
mulsd %xmm10, %xmm13
addsd %xmm12, %xmm13
mulsd %xmm7, %xmm13
movsd %xmm13, -0x18(%rsp,%r12,8)
mulsd %xmm13, %xmm13
addsd %xmm13, %xmm11
incq %r12
cmpq $0x3, %r12
jne 0x3ad4
movapd %xmm0, %xmm12
divsd %xmm11, %xmm12
movapd %xmm12, %xmm10
mulsd %xmm12, %xmm10
mulsd %xmm12, %xmm10
movapd %xmm10, %xmm11
mulsd %xmm8, %xmm11
movapd %xmm10, %xmm13
addsd %xmm5, %xmm13
mulsd %xmm11, %xmm13
addsd 0x80(%rdi), %xmm13
movsd %xmm13, 0x80(%rdi)
movapd %xmm10, %xmm11
mulsd %xmm9, %xmm11
mulsd %xmm12, %xmm11
addsd %xmm6, %xmm10
mulsd %xmm11, %xmm10
movq (%rsi,%r14,8), %r15
movapd %xmm10, %xmm11
xorpd %xmm2, %xmm11
xorl %r12d, %r12d
movsd -0x18(%rsp,%r12,8), %xmm12
movapd %xmm10, %xmm13
mulsd %xmm12, %xmm13
addsd (%r11,%r12,8), %xmm13
movsd %xmm13, (%r11,%r12,8)
mulsd %xmm11, %xmm12
addsd (%r15,%r12,8), %xmm12
movsd %xmm12, (%r15,%r12,8)
incq %r12
cmpq $0x3, %r12
jne 0x3b9d
incq %r14
cmpl %r14d, %eax
jg 0x3abd
incq %r8
cmpq %rcx, %r9
jne 0x397d
cmpl %eax, %ecx
jge 0x3d75
movq 0x8(%rdi), %rdx
movq 0x18(%rdi), %rsi
movapd 0x455c(%rip), %xmm2     # 0x8160
xorpd %xmm3, %xmm3
leaq 0x4561(%rip), %r8       # 0x8170
movsd 0x4531(%rip), %xmm4     # 0x8148
movsd 0x4501(%rip), %xmm5     # 0x8120
movsd 0x4529(%rip), %xmm6     # 0x8150
movsd 0x44f9(%rip), %xmm7     # 0x8128
movq %rcx, %r10
incq %rcx
cmpq %rax, %rcx
jge 0x3d6c
movq (%rdx,%r10,8), %r9
movq (%rsi,%r10,8), %r10
movq %rcx, %r11
movq (%rdx,%r11,8), %rbx
movsd 0x60(%rdi), %xmm8
xorpd %xmm2, %xmm8
xorpd %xmm9, %xmm9
xorl %r14d, %r14d
movsd (%r9,%r14,8), %xmm10
subsd (%rbx,%r14,8), %xmm10
movapd %xmm1, %xmm11
mulsd %xmm10, %xmm11
xorl %r15d, %r15d
ucomisd %xmm3, %xmm11
setb %r15b
addsd (%r8,%r15,8), %xmm11
cvttpd2dq %xmm11, %xmm11
cvtdq2pd %xmm11, %xmm11
mulsd %xmm8, %xmm11
addsd %xmm10, %xmm11
mulsd %xmm4, %xmm11
movsd %xmm11, -0x18(%rsp,%r14,8)
mulsd %xmm11, %xmm11
addsd %xmm11, %xmm9
incq %r14
cmpq $0x3, %r14
jne 0x3c60
movapd %xmm0, %xmm10
divsd %xmm9, %xmm10
movapd %xmm10, %xmm8
mulsd %xmm10, %xmm8
mulsd %xmm10, %xmm8
movapd %xmm8, %xmm9
addsd %xmm8, %xmm9
movapd %xmm8, %xmm11
addsd %xmm5, %xmm11
mulsd %xmm9, %xmm11
addsd 0x80(%rdi), %xmm11
movsd %xmm11, 0x80(%rdi)
movapd %xmm8, %xmm9
mulsd %xmm6, %xmm9
mulsd %xmm10, %xmm9
addsd %xmm7, %xmm8
mulsd %xmm9, %xmm8
movq (%rsi,%r11,8), %rbx
movapd %xmm8, %xmm9
xorpd %xmm2, %xmm9
xorl %r14d, %r14d
movsd -0x18(%rsp,%r14,8), %xmm10
movapd %xmm8, %xmm11
mulsd %xmm10, %xmm11
addsd (%r10,%r14,8), %xmm11
movsd %xmm11, (%r10,%r14,8)
mulsd %xmm9, %xmm10
addsd (%rbx,%r14,8), %xmm10
movsd %xmm10, (%rbx,%r14,8)
incq %r14
cmpq $0x3, %r14
jne 0x3d29
incq %r11
cmpq %rax, %r11
jl 0x3c49
cmpq %rax, %rcx
jne 0x3c2f
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq