public static void compile(String fileName, boolean opt)
	                    throws IOException
	{
		Program     program = null;

		FileReader  file = new FileReader(fileName);

		SFECompiler compiler = new SFECompiler(file);

		try {
			program = compiler.compileProgram();
		} catch (ParseException pe) {
			System.err.println("Error in line " + pe.getErrorOffset() + ": " +
			                   pe.getMessage());
			System.exit(1);
		}

		file.close();

		System.out.println("Program compiled.");

		// transformations
		program.multi2SingleBit();

		// unique vars transformations
		program.uniqueVars();

		//Optimization
		if (opt) {
			program.optimize();
		}

		// write circuit
		PrintWriter circuit =
			new PrintWriter(new FileWriter(fileName +
			                               ((opt) ? ".Opt" : ".NoOpt") +
			                               ".circuit"));

		program.toCircuit(circuit, opt);
		circuit.close();

		// write Format file
		PrintWriter fmt =
			new PrintWriter(new FileWriter(fileName +
			                               ((opt) ? ".Opt" : ".NoOpt") +
			                               ".fmt"));
		fmt.println(program.toFormat());
		fmt.close();
	}