#include <string>
#include <iostream>
#include <sstream>

#include "master.h"
#include "paras.hpp"
#include "preprocess/preprocess.hpp"

int main(int argc, char* argv[]) {

    // read command line arguments
    paras::parse(argc, argv);
    opt->print_paras();

    std::stringstream ss;

    auto pre = new preprocess();

    if(OPT(simplify)) {
        char *filename = const_cast<char*>(opt->instance.c_str());
        pre->do_preprocess(filename);

        ss << "p cnf " << pre->vars << " " << pre->clause.size() << std::endl;
        for (int i = 1; i <= pre->clauses; i++) {
            int l = pre->clause[i].size();
            for (int j = 0; j < l; j++)
                ss << pre->clause[i][j] << " ";
            ss << "0" << std::endl;
        }
    }

    const auto& str_ref = ss.str();
    const char* cstr = str_ref.c_str();

    printf("%s\n", cstr);

    return 0;
}