Code to simulate a trace-based cache ( C or C++)