Replace dyn_cast<T>s immediately followed by asserts with cast<T>s.
useNew is set to false in all branches, so set it to false outside the if-else.