value = input_file.readInt();
value = Utilities.getIntFromDataInputStream(input_file);
  static private TraceRecord readTraceRecord(DataInputStream input_file)  {    TraceRecord tr = null;        try {      int encoding = input_file.readInt();      int record_format = encoding & 0x0000000F;        // last 4 bits      if (record_format == 0) {        // EOF        return tr;      } else if (record_format == TraceRecord.COUNTER_TYPE) {        TraceCounterRecord tcr = new TraceCounterRecord(n_counters);        tcr.local_tid     =  encoding >> 16;        tcr.buffer_code   = (encoding >> 15) & 0x00000001;        int bit           = (encoding >> 14) & 0x00000001;        tcr.vpid          = (encoding >>  4) & 0x000003FF;        tcr.thread_switch = (bit==1?true:false);        tcr.tid           = input_file.readInt();        if(options.debug>=5){          if (tcr.thread_switch) {            System.out.print(tcr.buffer_code+" VPID "+tcr.vpid);          } else {            System.out.print(tcr.buffer_code+"*VPID "+tcr.vpid);          }          System.out.print(" TID "+tcr.tid+" LTID "+tcr.local_tid);        }        tcr.start_wall_time   = input_file.readLong();        // translate end wall time to relative wall time.        tcr.counters[0]       = input_file.readLong() - tcr.start_wall_time;        tcr.callee_MID        = input_file.readInt();        tcr.caller_MID        = input_file.readInt();        if(options.debug>=5){          System.out.print(" SWT "+tcr.start_wall_time);System.out.print(" RWT "+tcr.counters[0]);        }        for (int i=1; i<=tcr.n_counters; i++) {          tcr.counters[i] = input_file.readLong();          if(options.debug>=5)System.out.print(" "+i+": "+tcr.counters[i]);        }        if(options.debug>=5)System.out.println();        // first Trace Counter Record read         if (trace_file_vpid == -1) {          trace_file_vpid = tcr.vpid;                           // cache vpid          trace_file_start_wall_time = tcr.start_wall_time;          TraceCounterRecord.start_time = tcr.start_wall_time;          if (debug>=3) {            System.out.println(trace_file_vpid+" start wall clock time "+trace_file_start_wall_time);          }        } else { // check that all vpid in a trace file are the same!          if (trace_file_vpid != tcr.vpid) {            System.out.println("***readTraceRecord: trace_file_vpid "+trace_file_vpid+" != record vpid "+tcr.vpid+"!***");            System.exit(-1);          }        }        tr = tcr;      } else if (record_format == TraceRecord.START_APP_TYPE) {        String app_name = Utilities.getStringFromDataInputStream(input_file);        if(options.debug>=1)System.out.println("  VPID "+trace_file_vpid+" START_APP_TYPE: app "+app_name);        tr = new TraceStartAppRecord(trace_file_vpid, app_name);      } else if (record_format == TraceRecord.COMPLETE_APP_TYPE) {        String app_name = Utilities.getStringFromDataInputStream(input_file);        if(options.debug>=4)System.out.println("  VPID "+trace_file_vpid+" COMPLETE_APP_TYPE: app "+app_name);        tr = new TraceCompleteAppRecord(trace_file_vpid, app_name);              } else if (record_format == TraceRecord.START_APP_RUN_TYPE) {        int  run = input_file.readInt();        String app_name = Utilities.getStringFromDataInputStream(input_file);        if(options.debug>=4)System.out.println("  VPID "+trace_file_vpid+" START_APP_RUN_TYPE: app "+app_name+", run "+run);        tr = new TraceStartAppRunRecord(trace_file_vpid, app_name, run);      } else if (record_format == TraceRecord.COMPLETE_APP_RUN_TYPE) {        int  run = input_file.readInt();        String app_name = Utilities.getStringFromDataInputStream(input_file);        if(options.debug>=4)System.out.println("  VPID "+trace_file_vpid+" COMPLETE_APP_RUN_TYPE: app "+app_name+", run "+run);        Integer Index = (Integer)completeApplicationRunIndex.get(app_name);        tr = new TraceCompleteAppRunRecord(trace_file_vpid, app_name, run);      } else if (record_format == TraceRecord.EXIT_TYPE) {        int  value = input_file.readInt();      // value        if(options.debug>=4)System.out.println("  VPID "+trace_file_vpid+" EXIT_TYPE: value "+value);        tr = new TraceExitRecord(trace_file_vpid, value);      } else if (record_format == TraceRecord.PADDING_TYPE) {        int  length = input_file.readInt();     // value        if(options.debug>=4)System.out.println("  VPID "+trace_file_vpid+" PADDING_TYPE: length "+length);        // gobble up padding        for (int i=0; i<length; i++) {          input_file.readByte();        }        tr = new TracePaddingRecord(trace_file_vpid, length);      } else {        System.out.println("***TraceFileReader.readTraceRecord() record format "+record_format+                           " unknown with encoding "+encoding+"!***");        int value;        int BOUND = 100;        System.out.print("***"+BOUND+" additional values: ");        for (int i = 0; i<BOUND; i++) {          value = input_file.readInt();          System.out.print(" "+value);        }        System.out.println("***");        //      System.exit(-1);      }    } catch (EOFException e) {      if(options.debug>=4)System.out.println("!!!EOF in readTraceRecord!!!");      return null;    } catch (IOException e) {      System.out.println("*** IO Exception in readTraceRecord!***");      System.exit(-1);    }    return tr;  }