
#include "util.h"
#include "cudd.h"

  manager = Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0);
  f = Cudd_ReadOne(manager);
  Cudd_Ref(f);
  for (i = 3; i >= 0; i--) {
    var = Cudd_bddIthVar(manager,i);
    tmp = Cudd_bddAnd(manager,Cudd_Not(var),f);
    Cudd_Ref(tmp);
    Cudd_RecursiveDeref(manager,f);
    f = tmp;
  }

cudd_destructive_and(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
  DdNode *tmp;
  tmp = Cudd_bddNand(manager, bdd1, bdd2);
  Cudd_Ref(tmp);
  Cudd_RecursiveDeref(manager,bdd2);
  Cudd_RecursiveDeref(manager,bdd1);
  //Cudd_RecursiveDeref(manager, bdd2);
  return tmp;
}

cudd_destructive_nand(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
  DdNode *tmp;
  tmp = Cudd_bddNand(manager, bdd1, bdd2);
  Cudd_Ref(tmp);
  Cudd_RecursiveDeref(manager,bdd2);
  Cudd_RecursiveDeref(manager,bdd1);
  //Cudd_RecursiveDeref(manager, bdd2);
  return tmp;
}

cudd_destructive_or(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
  DdNode *tmp;
  tmp = Cudd_bddOr(manager, bdd1, bdd2);
  Cudd_Ref(tmp);
  Cudd_RecursiveDeref(manager,bdd2);
  Cudd_RecursiveDeref(manager,bdd1);
  //Cudd_RecursiveDeref(manager, bdd2);
  return tmp;
}

cudd_destructive_nor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
  DdNode *tmp;
  tmp = Cudd_bddNOr(manager, bdd1, bdd2);
  Cudd_Ref(tmp);
  Cudd_RecursiveDeref(manager,bdd2);
  Cudd_RecursiveDeref(manager,bdd1);
  //Cudd_RecursiveDeref(manager, bdd2);
  return tmp;
}

cudd_destructive_xor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) {
  DdNode *tmp;
  tmp = Cudd_bddXOr(manager, bdd1, bdd2);
  Cudd_Ref(tmp);
  Cudd_RecursiveDeref(manager,bdd2);
  Cudd_RecursiveDeref(manager,bdd1);
  //Cudd_RecursiveDeref(manager, bdd2);
  return tmp;
}

cudd_0node(DdManager *manager) {
  DdNode *tmp;
  tmp = Cudd_bddIthVar(manager, bdd1, bdd2);
  Cudd_Ref(tmp);
  Cudd_RecursiveDeref(manager,bdd2);
  Cudd_RecursiveDeref(manager,bdd1);
  //Cudd_RecursiveDeref(manager, bdd2);
  return tmp;
}

