#include <iostream>
#include <string>
#include <intrin.h>
#include "str.h"
#include "st.h"

using namespace std;
using namespace string_tools;

class CPU {
public:
   void run() {
      int regs[4] = {0};
      char vendor[13];
      memset(vendor, 0, 13);
      __cpuid(regs, 0);              // mov eax,0; cpuid
      memcpy(vendor, &regs[1], 4);   // copy EBX
      memcpy(vendor+4, &regs[3], 4); // copy EDX
      memcpy(vendor+8, &regs[2], 4); // copy ECX
      vendor[12] = '\0';
      cout << trim(vendor) << endl;
   }
};

#ifdef NO_MAIN
extern "C" {
int cpu_main(int argc, char** argv);
}
int
cpu_main(int argc, char** argv)
#else
int
main(int argc, char** argv)
#endif
{
   int rc = 0;
   try {
      CPU cpu;
      cpu.run();
   }
   catch(...) {
      cerr << "error reading the CPU..." << endl;
      rc = 1;
   }
   return rc;
}
