Analysing the algorithm's complexity using Sigma notation
For the sake of completeness: when analyzing the time complexity of nested and co-dependent loops such as in your algorithm, Sigma notation can be a good tool

where ⌊x⌋ and ⌈x⌉ are the floor and ceiling functions.
From the above, it's apparent that an upper bound on the asymptotic behaviour of the algorithm is O(n^3 log_2(n))
.
Using Sigma notation to estimate the actual number of iterations
Sigma notation analysis is, in addition to being a rigorous tool for Big-O(-Ω, -Θ) analysis, also useful if we're interested in counting or estimating the actual number of iterations of our algorithm.
We compare the estimated number of iterations—using the formula prior to the ≤ symbol above—with the actual number of iterations as presented in @JohnHascell:s answer.
// our formula (pseudo-code / matlab-compliant)
numIt(n) = n*ceil(log2(n))*(n^2-n)/2;
// comparison with actual count:
---------------------------------------------------------
n actual # of iter. estimated # of iter.
(from @JohnHascell) (from formula above)
------------ ------------------- --------------------
1 0 0
10 1 800 1 800
100 3 465 000 3 465 000
1000 4 995 000 000 4 995 000 000
10000 6 999 300 000 000 6 999 300 000 000
---------------------------------------------------------
We see that the count from the formula conforms perfectly with the actual count; in this case, the estimation is in fact an actual count.