// Path: src/main/wcanalysis/heuristic/model/State.java
// public abstract class State implements CSVable, Comparable<State> {
//   private final PathCondition pc;
//   
//   public State(PathCondition pc) {
//     this.pc = pc;
//   }
//   
//   public PathCondition getPathCondition() {
//     return this.pc;
//   }
//   
//   // Should this return a double, or would we like to parameterize this (e.g. to subclasses of Number)?
//   public abstract double getWC();
// }
// 
// Path: src/main/wcanalysis/heuristic/util/OmegaConverter.java
// public class OmegaConverter implements ConstraintsConverter {
// 
//   @Override
//   public String convert(PathCondition pc) {
//     if(pc == null)
//       return "";
//     PathCondition convertPc = pc.make_copy(); //probably not necessary...
// 
//     HashSet<String> vars = new HashSet<>();
//     //TODO: does the collector *only* collect integer vars? That's weird
//     SymbolicVariableCollector collector = new SymbolicVariableCollector(vars);
//     collector.collectVariables(convertPc);
// 
//     StringBuilder omegaVarDecl = new StringBuilder();
//     Iterator<String> iter = vars.iterator();
//     while(iter.hasNext()) {
//       omegaVarDecl.append(clean(iter.next()));
//       if(iter.hasNext())
//         omegaVarDecl.append(',');
//     }
// 
//     StringBuilder omegaStr = new StringBuilder();
//     omegaStr.append("{[").append(omegaVarDecl.toString()).append("] : ").append(clean(convertPc)).append("};");
// 
//     return omegaStr.toString();
//   }
// 
//   private static String clean(PathCondition pc) {
//     return (pc.header == null) ? "TRUE" : clean(pc.header.toString());
//   }
// 
//   private static String clean(String constraintsString) {
//     String clean = constraintsString.replaceAll("\\s+", "");
//     clean = clean.replaceAll("CONST_(\\d+)", "$1");
//     clean = clean.replaceAll("CONST_-(\\d+)", "-$1");
//     clean = clean.replaceAll("[a-zA-Z]", "s");
//     return clean;
//   }
// }
// 
// Path: src/main/wcanalysis/heuristic/util/SMTLibConverter.java
// public class SMTLibConverter implements ConstraintsConverter {
// 
//   @Override
//   public String convert(PathCondition pc) {
//     if(pc == null || pc.header == null)
//       return "";
//     StringBuilder smtLib = new StringBuilder();
//     HashSet<String> setOfSymVar = new HashSet<String>();
//     SymbolicVariableCollector collector = new SymbolicVariableCollector(setOfSymVar);
//     collector.collectVariables(pc);
//     //Add declarations
//     for (String var : collector.getListOfVariables())
//       smtLib.append("(declare-const " + var + " Int)\n");
//     //make assertion
//     smtLib.append('\n');
//     smtLib.append("(assert ").append(pc.header.prefix_notation()).append(")\n\n");
//     smtLib.append("(check-sat)\n");
//     smtLib.append("(get-model)");
//     return smtLib.toString();
//   }
// }


import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;
import gov.nasa.jpf.Config;
import gov.nasa.jpf.JPF;
import gov.nasa.jpf.report.Publisher;
import gov.nasa.jpf.report.Reporter;
import gov.nasa.jpf.report.Statistics;
import gov.nasa.jpf.symbc.numeric.PathCondition;
import wcanalysis.heuristic.model.State;
import wcanalysis.heuristic.util.OmegaConverter;
import wcanalysis.heuristic.util.SMTLibConverter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
        if(!stateCSVHeader.endsWith(","))
          stateCSVHeader += ",";
        String header = "inputSize," + 
            ((this.cfgInputSize >= 0) ? "cfgInputSize," : "") + 
            stateCSVHeader +
            "analysisTime,mem,paths," +
            getCustomCSVColumnHeader() +
            ",wcConstraint";
        
        out.println(header);
      }
      
      out.print(conf.getString("target.args") + ",");
      if(cfgInputSize >= 0)
        out.print(cfgInputSize + ",");
      String stateCSVRes = wcState.getCSV();
      if(!stateCSVRes.endsWith(","))
        stateCSVRes += ",";
      out.print(stateCSVRes);
      out.print((reporter.getElapsedTime()/1000) + ",");
      out.print((stat.maxUsed >> 20) + ",");
      out.print(stat.endStates + ",");
      out.print(this.getCustomCSVColumnData() + ",");
      
      if(wcState.getPathCondition() == null) {
        logger.severe("Worst case result state does not have associated constraints! Is it the worst case state at all?");
        out.println("CONSTRAINT N/A");
      } else {
        PathCondition pc = wcState.getPathCondition();
        if(generateSMTLibFormat) {
// Path: src/main/wcanalysis/heuristic/model/State.java
// public abstract class State implements CSVable, Comparable<State> {
//   private final PathCondition pc;
//   
//   public State(PathCondition pc) {
//     this.pc = pc;
//   }
//   
//   public PathCondition getPathCondition() {
//     return this.pc;
//   }
//   
//   // Should this return a double, or would we like to parameterize this (e.g. to subclasses of Number)?
//   public abstract double getWC();
// }
// 
// Path: src/main/wcanalysis/heuristic/util/OmegaConverter.java
// public class OmegaConverter implements ConstraintsConverter {
// 
//   @Override
//   public String convert(PathCondition pc) {
//     if(pc == null)
//       return "";
//     PathCondition convertPc = pc.make_copy(); //probably not necessary...
// 
//     HashSet<String> vars = new HashSet<>();
//     //TODO: does the collector *only* collect integer vars? That's weird
//     SymbolicVariableCollector collector = new SymbolicVariableCollector(vars);
//     collector.collectVariables(convertPc);
// 
//     StringBuilder omegaVarDecl = new StringBuilder();
//     Iterator<String> iter = vars.iterator();
//     while(iter.hasNext()) {
//       omegaVarDecl.append(clean(iter.next()));
//       if(iter.hasNext())
//         omegaVarDecl.append(',');
//     }
// 
//     StringBuilder omegaStr = new StringBuilder();
//     omegaStr.append("{[").append(omegaVarDecl.toString()).append("] : ").append(clean(convertPc)).append("};");
// 
//     return omegaStr.toString();
//   }
// 
//   private static String clean(PathCondition pc) {
//     return (pc.header == null) ? "TRUE" : clean(pc.header.toString());
//   }
// 
//   private static String clean(String constraintsString) {
//     String clean = constraintsString.replaceAll("\\s+", "");
//     clean = clean.replaceAll("CONST_(\\d+)", "$1");
//     clean = clean.replaceAll("CONST_-(\\d+)", "-$1");
//     clean = clean.replaceAll("[a-zA-Z]", "s");
//     return clean;
//   }
// }
// 
// Path: src/main/wcanalysis/heuristic/util/SMTLibConverter.java
// public class SMTLibConverter implements ConstraintsConverter {
// 
//   @Override
//   public String convert(PathCondition pc) {
//     if(pc == null || pc.header == null)
//       return "";
//     StringBuilder smtLib = new StringBuilder();
//     HashSet<String> setOfSymVar = new HashSet<String>();
//     SymbolicVariableCollector collector = new SymbolicVariableCollector(setOfSymVar);
//     collector.collectVariables(pc);
//     //Add declarations
//     for (String var : collector.getListOfVariables())
//       smtLib.append("(declare-const " + var + " Int)\n");
//     //make assertion
//     smtLib.append('\n');
//     smtLib.append("(assert ").append(pc.header.prefix_notation()).append(")\n\n");
//     smtLib.append("(check-sat)\n");
//     smtLib.append("(get-model)");
//     return smtLib.toString();
//   }
// }


// Path: src/main/wcanalysis/heuristic/ResultsPublisher.java
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;
import gov.nasa.jpf.Config;
import gov.nasa.jpf.JPF;
import gov.nasa.jpf.report.Publisher;
import gov.nasa.jpf.report.Reporter;
import gov.nasa.jpf.report.Statistics;
import gov.nasa.jpf.symbc.numeric.PathCondition;
import wcanalysis.heuristic.model.State;
import wcanalysis.heuristic.util.OmegaConverter;
import wcanalysis.heuristic.util.SMTLibConverter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;

        if(!stateCSVHeader.endsWith(","))
          stateCSVHeader += ",";
        String header = "inputSize," + 
            ((this.cfgInputSize >= 0) ? "cfgInputSize," : "") + 
            stateCSVHeader +
            "analysisTime,mem,paths," +
            getCustomCSVColumnHeader() +
            ",wcConstraint";
        
        out.println(header);
      }
      
      out.print(conf.getString("target.args") + ",");
      if(cfgInputSize >= 0)
        out.print(cfgInputSize + ",");
      String stateCSVRes = wcState.getCSV();
      if(!stateCSVRes.endsWith(","))
        stateCSVRes += ",";
      out.print(stateCSVRes);
      out.print((reporter.getElapsedTime()/1000) + ",");
      out.print((stat.maxUsed >> 20) + ",");
      out.print(stat.endStates + ",");
      out.print(this.getCustomCSVColumnData() + ",");
      
      if(wcState.getPathCondition() == null) {
        logger.severe("Worst case result state does not have associated constraints! Is it the worst case state at all?");
        out.println("CONSTRAINT N/A");
      } else {
        PathCondition pc = wcState.getPathCondition();
        if(generateSMTLibFormat) {
          String smtLibPc = new SMTLibConverter().convert(pc);