#include "llvm/Pass.h"
#include "llvm/Function.h"
#include "llvm/Module.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

namespace {
  class LLVM_15745_Printer : public ModulePass {
  public:
    static char ID;
    
    LLVM_15745_Printer () : ModulePass (ID) {}
    ~LLVM_15745_Printer () {}

  virtual void getAnalysisUsage(AnalysisUsage &AU) const
  {
    AU.setPreservesAll();
  }
	
  virtual bool runOnFunction(Function &F)
    {
    for (Function::iterator b = F.begin (), e = F.end ();
	 b != e; b++) {
      errs () << *b << "\n";
    }
    errs () << "}\n";

    return false;
    }
    
  virtual bool runOnModule(Module& M)
    {
      errs () << "15745 LLVM Bytecode Printer Pass \n"; //remove this
      for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI)
	{
	  runOnFunction(*MI);
	}
      return false;
    }
  };
  char LLVM_15745_Printer::ID = 0;
  RegisterPass<LLVM_15745_Printer>X("15745-llvm-printer", "15745: Print LLVM code");
}
