public static JClassDeclaration flatten(SIRStream str, JInterfaceDeclaration[] interfaces, SIRInterfaceTable[] interfaceTables, SIRStructure[] structs) {
public static void flatten(SIRStream str, JInterfaceDeclaration[] interfaces, SIRInterfaceTable[] interfaceTables, SIRStructure[] structs) { /* DEBUGGING PRINTING
    public static JClassDeclaration flatten(SIRStream str,					    JInterfaceDeclaration[] 					    interfaces,					    SIRInterfaceTable[]					    interfaceTables,                                            SIRStructure[] structs) {	// DEBUGGING PRINTING        System.out.println("--------- ON ENTRY TO FLATTENER ----------------");	SIRPrinter printer1 = new SIRPrinter();	IterFactory.createIter(str).accept(printer1);	printer1.close();	// move field initializations into init function	FieldInitMover.moveStreamInitialAssignments(str);	// propagate constants and unroll loops	ConstantProp.propagateAndUnroll(str);	// construct stream hierarchy from SIRInitStatements	ConstructSIRTree.doit(str);	INIT_STATEMENTS_RESOLVED = true;	// dump the original graph to a dot format	StreamItDot.printGraph(str, "before.dot");	AdjustGranularity.doit(str, -1);	if (StreamItOptions.partition) {	    Partitioner.doit(str, 			     StreamItOptions.rawRows *			     StreamItOptions.rawColumns);	}	/* Not general code: Just a test for sync-removal on TwoWeightedRR.java */ 	/* StreamItDot.printGraph(str, "before-syncremov.dot");	SIRPipeline parentPipe = (SIRPipeline)str; 	SyncRemovalSJPair.diffuseSJPair((SIRSplitJoin)parentPipe.get(1), (SIRSplitJoin)parentPipe.get(2)); 	StreamItDot.printGraph(str, "after-syncremov.dot"); */ 	/*	SIRFilter toDuplicate = ((SIRFilter)				 ((SIRPipeline)				  ((SIRPipeline)str).get(1)).get(0));	System.err.println("Trying to duplicate " + toDuplicate);	StatelessDuplicate.doit(toDuplicate, 2);	*/	if (StreamItOptions.fusion) {	    System.out.println("Running Fusion");	    FuseAll.fuse(str);	    // DEBUGGING PRINTING	    System.out.println("--------- AFTER FUSION ------------");	    printer1 = new SIRPrinter();	    IterFactory.createIter(str).accept(printer1);	    printer1.close();	    	}	// dump the original graph to a dot format	StreamItDot.printGraph(str, "after.dot");	//Raise NewArray's up to top	new VarDeclRaiser().raiseVars(str);	        // do constant propagation on fields        if (StreamItOptions.constprop) {	    System.out.println("Running Constant Propagation of Fields");	    FieldProp.doPropagate(str);	}	// move field initializations into init function	FieldInitMover.moveStreamInitialAssignments(str);	// DEBUGGING PRINTING	System.out.println("--------- AFTER CONSTANT PROP / FUSION --------");	printer1 = new SIRPrinter();	IterFactory.createIter(str).accept(printer1);	printer1.close();		if (StreamItOptions.constprop) {	    //Flatten Blocks	    new BlockFlattener().flattenBlocks(str);	    //Analyze Branches	    new BranchAnalyzer().analyzeBranches(str);	}	//Destroys arrays into local variables if possible	new ArrayDestroyer().destroyArrays(str);	//Raise variables to the top of their block	new VarDeclRaiser().raiseVars(str);	// if someone wants to run linear analysis (or linear replacement)	if (StreamItOptions.linearanalysis || StreamItOptions.linearreplacement) {	    // pass the program (str) and whether or not we want	    // to do direct replacement code for the work functions	    // of linear filters.	    runLinearAnalysis(str, StreamItOptions.linearreplacement);	}	// DEBUGGING PRINTING	System.out.println("--------- AFTER Linear Analysis --------");		// make single structure	SIRIterator iter = IterFactory.createIter(str);	JClassDeclaration flatClass = Structurer.structure(iter,							   interfaces,							   interfaceTables,                                                           structs);	// build schedule as set of higher-level work functions	Schedule schedule = SIRScheduler.buildWorkFunctions(str, flatClass);	// add LIR hooks to init and work functions	LowerInitFunctions.lower(iter, schedule);        LowerWorkFunctions.lower(iter);	// DEBUGGING PRINTING	System.out.println("----------- AFTER FLATTENER ------------------");	IRPrinter printer = new IRPrinter();	flatClass.accept(printer);	printer.close();	return flatClass;    }