U.S. stocks eked out gains on Tuesday as investors’ appetite for risk suddenly reversed about halfway through the session, sparking…