Optimized trace and print