//===-- Writer.cpp - Library for converting LLVM code to C ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This library converts LLVM code to C code, compilable by GCC and other C
// compilers.
//
//===----------------------------------------------------------------------===//
#include "CTargetMachine.h"
#include "llvm/Target/TargetMachineImpls.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#include "llvm/SymbolTable.h"
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicLowering.h"
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Analysis/ConstantsScanner.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/Mangler.h"
#include "Support/StringExtras.h"
#include "Config/config.h"
#include <algorithm>
#include <sstream>
using namespace llvm;
namespace {
class CWriter : public Pass, public InstVisitor<CWriter> {
std::ostream &Out;
IntrinsicLowering &IL;
Mangler *Mang;
const Module *TheModule;
FindUsedTypes *FUT;
std::map<const Type *, std::string> TypeNames;
std::map<