SmaRTLy: RTL Optimization with Logic Inferencing and Structural Rebuilding (Full Report)