#include <iostream>
#include <string>

using namespace std;

class CompilerDriver {
   string _name;
public:
   CompilerDriver(const string & name) { _name = name; }
   int run() {
      int ret = 0;
      string cmd;
      cmd = "cl /X /E " + _name + ".c > " + _name + ".temp.c";
      if((ret |= system(cmd.c_str())) == 0) {
         cout << "c-pre-processor done..." << endl;
      }
      cmd = "c.exe " + _name + ".temp.c " + _name + ".asm";
      if((ret |= system(cmd.c_str())) == 0) {
         cmd = "nasm -f bin " + _name + ".asm " + " -o " + _name + ".com";
         if((ret |= system(cmd.c_str())) == 0) {
            cout << "compilation successfull..." << endl;
         }
      }
      return ret;
   }
};

int
main(int argc, char ** argv)
{
   if(argc == 2) {
      return CompilerDriver(argv[1]).run();
   }
   cerr << "usage: cc <program-name>" << endl;
   exit(1); 
   return 0;
}