Loop Optimization of Tensor Network Renormalization: Algorithms and Applications