Algorithms for the complete decomposition of a closed $3$-manifold