replace nested max/min macros with {max,min}3 macro