// Path: src/main/java/bixie/checker/GlobalsCache.java
// public class GlobalsCache {
// 	
// 	private static GlobalsCache instance = null;
// 	
// 	public static GlobalsCache v() {
// 		if (instance==null) {
// 			instance = new GlobalsCache();
// 		}
// 		return instance;
// 	}
// 	
// 	public static void resetInstance() {
// 		instance = null;		
// 	}
// 	
// 	private GlobalsCache() {
// 		
// 	}
// 	
// 	/**
// 	 * @return the programFactory
// 	 */
// 	public ProgramFactory getProgramFactory() {
// 		return programFactory;
// 	}
// 
// 	/**
// 	 * @param programFactory the programFactory to set
// 	 */
// 	public void setProgramFactory(ProgramFactory programFactory) {
// 		this.programFactory = programFactory;
// 	}
// 
// 	private ProgramFactory programFactory;
// 	
// }


import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import util.Log;
import bixie.checker.GlobalsCache;
import boogie.ProgramFactory;
import boogie.ast.Attribute;
import boogie.controlflow.BasicBlock;
import boogie.controlflow.CfgProcedure;
import boogie.controlflow.expression.CfgBooleanLiteral;
import boogie.controlflow.statement.CfgAssertStatement;
import boogie.controlflow.util.LoopInfo;

		// fix the successors of the cloned nodes.
		for (BasicBlock b : loop.loopBody) {
			BasicBlock clone = clonemap.get(b);
			for (BasicBlock s : new HashSet<BasicBlock>(b.getSuccessors())) {
				if (clonemap.containsKey(s)) {
					clone.connectToSuccessor(clonemap.get(s));
				} else {
					// add the missing edge that was not cloned
					clone.connectToSuccessor(s);
				}
			}
		}

		// now redirect all back edges to the original loop head.
		for (BasicBlock b : loop.loopingPred) {
			if (!clonemap.containsKey(b)) {
				Log.error("something fishy with that loop!");
				continue;
			}
			BasicBlock clone = clonemap.get(b);
			clone.disconnectFromSuccessor(cloneHead);
			clone.connectToSuccessor(loop.loopHead);
		}

		loop.UpdateLoopEntries();

		unwind(loop, unwindings - 1);
	}
	
	private void markAsClone(BasicBlock clone) {

// Path: src/main/java/bixie/checker/GlobalsCache.java
// public class GlobalsCache {
// 	
// 	private static GlobalsCache instance = null;
// 	
// 	public static GlobalsCache v() {
// 		if (instance==null) {
// 			instance = new GlobalsCache();
// 		}
// 		return instance;
// 	}
// 	
// 	public static void resetInstance() {
// 		instance = null;		
// 	}
// 	
// 	private GlobalsCache() {
// 		
// 	}
// 	
// 	/**
// 	 * @return the programFactory
// 	 */
// 	public ProgramFactory getProgramFactory() {
// 		return programFactory;
// 	}
// 
// 	/**
// 	 * @param programFactory the programFactory to set
// 	 */
// 	public void setProgramFactory(ProgramFactory programFactory) {
// 		this.programFactory = programFactory;
// 	}
// 
// 	private ProgramFactory programFactory;
// 	
// }


// Path: src/main/java/bixie/transformation/loopunwinding/AbstractLoopUnwinding.java
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import util.Log;
import bixie.checker.GlobalsCache;
import boogie.ProgramFactory;
import boogie.ast.Attribute;
import boogie.controlflow.BasicBlock;
import boogie.controlflow.CfgProcedure;
import boogie.controlflow.expression.CfgBooleanLiteral;
import boogie.controlflow.statement.CfgAssertStatement;
import boogie.controlflow.util.LoopInfo;

		// fix the successors of the cloned nodes.
		for (BasicBlock b : loop.loopBody) {
			BasicBlock clone = clonemap.get(b);
			for (BasicBlock s : new HashSet<BasicBlock>(b.getSuccessors())) {
				if (clonemap.containsKey(s)) {
					clone.connectToSuccessor(clonemap.get(s));
				} else {
					// add the missing edge that was not cloned
					clone.connectToSuccessor(s);
				}
			}
		}

		// now redirect all back edges to the original loop head.
		for (BasicBlock b : loop.loopingPred) {
			if (!clonemap.containsKey(b)) {
				Log.error("something fishy with that loop!");
				continue;
			}
			BasicBlock clone = clonemap.get(b);
			clone.disconnectFromSuccessor(cloneHead);
			clone.connectToSuccessor(loop.loopHead);
		}

		loop.UpdateLoopEntries();

		unwind(loop, unwindings - 1);
	}
	
	private void markAsClone(BasicBlock clone) {

		ProgramFactory pf = GlobalsCache.v().getProgramFactory();		
