if (node.inputs > 0 && node.incoming[0] != null) {
if (node.inputs > 0 && node.incoming[0] != null && CommonUtils.getOutputType(node.incoming[0]) != CStdType.Void) {
    public void generatePreamble(FlatIRToCluster f2c, CodegenPrintWriter p) {        p.println("// ClusterFusion isEliminated: "+isEliminated+"");        for (Iterator iter = fusedWith.iterator(); iter.hasNext();) {            p.println("// Fused with: "+iter.next()+"");        }        p.println("");        p.println("#include <stdlib.h>");        p.println("#include <unistd.h>");        p.println("#include <math.h>");         p.println("");        p.println("#include <init_instance.h>");        p.println("#include <mysocket.h>");        p.println("#include <object_write_buffer.h>");        p.println("#include <save_state.h>");        p.println("#include <sdep.h>");        p.println("#include <message.h>");        p.println("#include <timer.h>");        p.println("#include <thread_info.h>");        p.println("#include <consumer2.h>");          // for cluster edge incoming        p.println("#include <consumer2p.h>");         // for cluster feedback edge incoming with >0 enqueues        p.println("#include <producer2.h>");          // foe cluster edge outgoing        // only include fft.h if we did a frequency transformation        if (at.dms.kjc.sir.linear.frequency.LEETFrequencyReplacer.didTransform) {            p.println("#include <fft.h>");        }        p.println("#include \"cluster.h\"");        p.println("#include \"fusion.h\"");        //p.println("#include \"structs.h\"");        p.println("#include \"global.h\"");        if (KjcOptions.countops) {            p.println("#include \"profiler.h\"");        }        p.println("");        //p.println("#include <peek_stream.h>");        //p.println("#include <data_consumer.h>");        //p.println("#include <data_producer.h>");            p.println("extern int __max_iteration;");        p.println("extern int __init_iter;");        // any Operator with no successor is assumed to be last and will print timer        boolean timer_print = true;        for (Tape succ : data_out) {             if (succ != null) {                timer_print = true;                break;            }        }        if (timer_print) {            p.println("extern int __timer_enabled;");        }        p.println("extern int __frequency_of_chkpts;");        p.println("extern volatile int __vol;");        p.println("message *__msg_stack_"+id+";");        p.println("int __number_of_iterations_"+id+";");        p.println("int __counter_"+id+" = 0;");        p.println("int __steady_"+id+" = 0;");        p.println("int __tmp_"+id+" = 0;");        p.println("int __tmp2_"+id+" = 0;");        p.println("int *__state_flag_"+id+" = NULL;");        p.println("thread_info *__thread_"+id+" = NULL;");        if (restrictedExecution) {            p.println("int __credit_"+id+" = "+initCredit+";");        }            for (Iterator i = msg_to.iterator(); i.hasNext();) {            SIRStream str = (SIRStream)i.next();            p.println("sdep *sdep_"+id+"_"+NodeEnumerator.getSIROperatorId(str)+";");        }        p.println("");            //  +=============================+        //  | Communication Variables     |        //  +=============================+        for (Tape in : data_in) {          if (in != null && in instanceof TapeCluster) {            if (! FixedBufferTape.isFixedBuffer(in.getSource(),in.getDest())) {                if (oper instanceof SIRJoiner                        && oper.getParent() instanceof SIRFeedbackLoop                        && ((SIRFeedbackLoop)oper.getParent()).getDelayInt() > 0                        && NodeEnumerator.getFlatNode(in.getSource()) ==                            node.incoming[1]) {                    p.println("consumer2p<"+ClusterUtils.CTypeToString(in.getType())+"> "+((TapeCluster)in).getConsumerName()+";");                } else {                    p.println("consumer2<"+ClusterUtils.CTypeToString(in.getType())+"> "+((TapeCluster)in).getConsumerName()+";");                }                p.println("extern "+ClusterUtils.CTypeToString(in.getType())+" "+((TapeCluster)in).getPopName()+"();");            /*              if (oper instanceof SIRFilter) {              String type = ((SIRFilter)oper).getInputType().toString();              p.println("peek_stream<"+type+"> "+in.name()+"in(&"+in.getConsumerName()+");");              }            */            }          }        }            for (Tape out : data_out) {          if (out != null && out instanceof TapeCluster) {            if (! FixedBufferTape.isFixedBuffer(out.getSource(),out.getDest())) {                p.println("producer2<"+ClusterUtils.CTypeToString(out.getType())+"> "+((TapeCluster)out).getProducerName()+";");                p.println("extern void "+((TapeCluster)out).getPushName()+"("+ClusterUtils.CTypeToString(out.getType())+");");                p.println("    // this-part:"+ClusterFusion.getPartition(node)+" dst-part:"+ClusterFusion.getPartition(NodeEnumerator.getFlatNode(out.getDest()))+"");            }          }        }               for (Iterator i = msg_from.iterator(); i.hasNext();) {            int src = NodeEnumerator.getSIROperatorId((SIRStream)i.next());            p.println("netsocket *__msg_sock_"+src+"_"+id+"in;");           }        for (Iterator i = msg_to.iterator(); i.hasNext();) {            SIRStream str = (SIRStream)i.next();            int dst = NodeEnumerator.getSIROperatorId(str);            p.println("netsocket *__msg_sock_"+id+"_"+dst+"out; // to " + str);        }            p.println("");        //  +=============================+        //  | Fields                      |        //  +=============================+        for (int i = 0; i < fields.length; i++) {            JFieldDeclaration f = fields[i];            CType fType = f.getType();                    if (fType.toString().endsWith("Portal")) {                continue;   // no declaration for fields that are portals.            }            JVariableDefinition v = f.getVariable();            // Can't ask field to accept since munging identifier!            f2c.visitFieldDeclaration (f,                                       v.getModifiers(),                                       fType,                                       v.getIdent()+"__"+id,                                       v.getValue());        }        p.println("");        //  +=============================+        //  | Read / Write Thread         |        //  +=============================+        if (node.isFilter()) {            if (node.inputs > 0 && node.incoming[0] != null) {                p.println("void save_peek_buffer__" + id                        + "(object_write_buffer *buf);");                p.println("void load_peek_buffer__" + id                        + "(object_write_buffer *buf);");            }            p.println("void save_file_pointer__" + id                    + "(object_write_buffer *buf);");            p.println("void load_file_pointer__" + id                    + "(object_write_buffer *buf);");            p.println("");        }        	if (! KjcOptions.standalone) {	//p.println("#ifndef __CLUSTER_STANDALONE\n");        p.println("void __write_thread__"+id+"(object_write_buffer *buf) {");        for (Tape in : data_in) {          if (in != null && in instanceof TapeCluster) {              TapeCluster inc = (TapeCluster)in;            p.println("  "+inc.getConsumerName()+".write_object(buf);");                    /*              if (oper instanceof SIRFilter) {              p.println("  "+in.name()+"in.write_object(buf);");              }            */          }        }        if (node.isFilter()) {                if (node.inputs > 0 && node.incoming[0] != null) {                    p.println("  save_peek_buffer__" + id + "(buf);");                }                p.println("  save_file_pointer__" + id + "(buf);");            }                for (int f = 0; f < fields.length; f++) {            CType type = fields[f].getType();            String ident = fields[f].getVariable().getIdent();            DetectConst dc = DetectConst.getInstance((SIRFilter)oper);            if (dc != null && dc.isConst(ident)) continue;            if (type.isArrayType()) {                int size = 0;                String dims[] = (new FlatIRToCluster()).makeArrayStrings(((CArrayType)type).getDims());                CType base = ((CArrayType)type).getBaseType();                try {                    size = Integer.valueOf(dims[0]).intValue();                } catch (NumberFormatException ex) {                    System.out.println("Warning! Could not estimate size of an array: "+ident);                }                p.println("  buf->write("+ident+"__"+id+", "+size+" * sizeof("+ClusterUtils.CTypeToString(base)+"));");            } else {                p.println("  buf->write(&"+ident+"__"+id+", sizeof("+ClusterUtils.CTypeToString(type)+"));");            }        }        for (Tape out : data_out) {          if (out != null && out instanceof TapeCluster) {            p.println("  "+((TapeCluster)out).getProducerName()+".write_object(buf);");          }        }        p.println("}");        p.println("");          p.println("void __read_thread__"+id+"(object_write_buffer *buf) {");            for (Tape in : data_in) {          if (in != null && in instanceof TapeCluster) {            p.println("  "+((TapeCluster)in).getConsumerName()+".read_object(buf);");            /*              if (oper instanceof SIRFilter) {              p.println("  "+in.name()+"in.read_object(buf);");              }            */          }        }                if (node.isFilter()) {            if (node.inputs > 0 && node.incoming[0] != null) {                p.println("  load_peek_buffer__" + id + "(buf);");            }            p.println("  load_file_pointer__" + id + "(buf);");        }        for (int f = 0; f < fields.length; f++) {            CType type = fields[f].getType();            String ident = fields[f].getVariable().getIdent();            DetectConst dc = DetectConst.getInstance((SIRFilter)oper);            if (dc != null && dc.isConst(ident)) continue;            if (type.isArrayType()) {                int size = 0;                String dims[] = (new FlatIRToCluster()).makeArrayStrings(((CArrayType)type).getDims());                CType base = ((CArrayType)type).getBaseType();                try {                    size = Integer.valueOf(dims[0]).intValue();                } catch (NumberFormatException ex) {                    System.out.println("Warning! Could not estimate size of an array: "+ident);                }                p.println("  buf->read("+ident+"__"+id+", "+size+" *  sizeof("+ClusterUtils.CTypeToString(base)+"));");            } else {                p.println("  buf->read(&"+ident+"__"+id+", sizeof("+ClusterUtils.CTypeToString(type)+"));");            }        }        for (Tape out : data_out) {          if (out != null && out instanceof TapeCluster) {            p.println("  "+((TapeCluster)out).getProducerName()+".read_object(buf);");          }        }        p.println("}");        p.println("");          //  +=============================+        //  | Check Thread Status         |        //  +=============================+            p.println("inline void check_status__"+id+"() {");        p.println("  check_thread_status(__state_flag_"+id+", __thread_"+id+");");        p.println("}");        p.println("");          p.println("void check_status_during_io__"+id+"() {");        p.println("  check_thread_status_during_io(__state_flag_"+id+", __thread_"+id+");");        p.println("}");        p.println("");          //  +=============================+        //  | Fused Methods               |        //  +=============================+        if (!isEliminated) {            Iterator iter2 = fusedWith.iterator();            while (iter2.hasNext()) {                FlatNode tmp = (FlatNode)iter2.next();                int fid = NodeEnumerator.getFlatNodeId(tmp);                p.println("extern void __declare_sockets_"+fid+"();");                p.println("extern void __init_sockets_"+fid+"(void (*cs_fptr)());");                p.println("extern void __flush_sockets_"+fid+"();");                p.println("extern void __peek_sockets_"+fid+"();");                p.println("extern void __init_thread_info_"+fid+"(thread_info *);");                p.println("");            }        }        //  +=============================+        //  | Thread Info                 |        //  +=============================+        p.println("void __init_thread_info_"+id+"(thread_info *info) {");        for (Tape in : data_in) {          if (in != null && in instanceof TapeCluster) {            p.println("  info->add_incoming_data_connection(new connection_info("+in.getSource()+","+in.getDest()+",&"+((TapeCluster)in).getConsumerName()+"));");          }        }            for(Tape out : data_out) {          if (out != null && out instanceof TapeCluster) {            p.println("  info->add_outgoing_data_connection(new connection_info("+out.getSource()+","+out.getDest()+",&"+((TapeCluster)out).getProducerName()+"));");          }        }        p.println("  __state_flag_"+id+" = info->get_state_flag();");        if (!isEliminated) {            Iterator _i = fusedWith.iterator();            while (_i.hasNext()) {                FlatNode tmp = (FlatNode)_i.next();                int fid = NodeEnumerator.getFlatNodeId(tmp);                p.println("  __init_thread_info_"+fid+"(info);");            }        }        p.println("}");        p.println("");        p.println("thread_info *__get_thread_info_"+id+"() {");        p.println("  if (__thread_"+id+" != NULL) return __thread_"+id+";");        p.println("  __thread_"+id+" = new thread_info("+id+", check_status_during_io__"+id+");");        p.println("  __init_thread_info_"+id+"(__thread_"+id+");");        p.println("  return __thread_"+id+";");            p.println("}");        p.println("");        //  +=============================+        //  | Declare Sockets             |        //  +=============================+        p.println("void __declare_sockets_"+id+"() {");        if (!isEliminated) {            Iterator iter2 = fusedWith.iterator();            while (iter2.hasNext()) {                FlatNode tmp = (FlatNode)iter2.next();                int fid = NodeEnumerator.getFlatNodeId(tmp);                p.println("  __declare_sockets_"+fid+"();");            }        }        for (Tape in : data_in) {          if (in != null) {            FlatNode tmp = NodeEnumerator.getFlatNode(in.getSource());            if (!fusedWith.contains(tmp)) {                 p.println("  init_instance::add_incoming("+in.getSource()+","+in.getDest()+", DATA_SOCKET);");            }          }        }        for (Tape out : data_out) {          if (out != null) {            FlatNode tmp = NodeEnumerator.getFlatNode(out.getDest());            if (!fusedWith.contains(tmp)) {                     p.println("  init_instance::add_outgoing("+out.getSource()+","+out.getDest()+", DATA_SOCKET);");            }          }         }        for (Iterator i = msg_from.iterator(); i.hasNext();) {            int src = NodeEnumerator.getSIROperatorId((SIRStream)i.next());            p.println("  init_instance::add_incoming("+src+","+id+",MESSAGE_SOCKET);");        }        for(Iterator i = msg_to.iterator(); i.hasNext();) {            int dst = NodeEnumerator.getSIROperatorId((SIRStream)i.next());            p.println("  init_instance::add_outgoing("+id+","+dst+",MESSAGE_SOCKET);");        }        p.println("}");        p.println("");        //  +=============================+        //  | Init Sockets                |        //  +=============================+        p.println("void __init_sockets_"+id+"(void (*cs_fptr)()) {");        p.println("  mysocket *sock;");        p.println("");        if (!isEliminated) {            Iterator iter2 = fusedWith.iterator();            while (iter2.hasNext()) {                FlatNode tmp = (FlatNode)iter2.next();                int fid = NodeEnumerator.getFlatNodeId(tmp);                p.println("  __init_sockets_"+fid+"(cs_fptr);");            }        }        for (Tape in : data_in) {          if (in != null && in instanceof TapeCluster) {            FlatNode tmp = NodeEnumerator.getFlatNode(in.getSource());            if (!fusedWith.contains(tmp)) {                p.println("  sock = init_instance::get_incoming_socket("+in.getSource()+","+in.getDest()+",DATA_SOCKET);");                p.println("  sock->set_check_thread_status(cs_fptr);");                //p.println("  sock->set_item_size(sizeof("+in.getType()+"));");                p.println("  "+((TapeCluster)in).getConsumerName()+".set_socket(sock);");                p.println("  "+((TapeCluster)in).getConsumerName()+".init();");                p.println("");            }          }        }        for (Tape out : data_out) {          if (out != null && out instanceof TapeCluster) {            FlatNode tmp = NodeEnumerator.getFlatNode(out.getDest());            if (!fusedWith.contains(tmp)) {                p.println("  sock = init_instance::get_outgoing_socket("+out.getSource()+","+out.getDest()+",DATA_SOCKET);");                p.println("  sock->set_check_thread_status(cs_fptr);");                //p.println("  sock->set_item_size(sizeof("+out.getType()+"));");                p.println("  "+((TapeCluster)out).getProducerName()+".set_socket(sock);");                p.println("  "+((TapeCluster)out).getProducerName()+".init();");                p.println("");            }          }        }        for (Iterator i = msg_from.iterator(); i.hasNext();) {            int src = NodeEnumerator.getSIROperatorId((SIRStream)i.next());            p.println("  __msg_sock_"+src+"_"+id+"in = (netsocket*)init_instance::get_incoming_socket("+src+","+id+",MESSAGE_SOCKET);");            p.println("");        }        for (Iterator i = msg_to.iterator(); i.hasNext();) {            int dst = NodeEnumerator.getSIROperatorId((SIRStream)i.next());            p.println("  __msg_sock_"+id+"_"+dst+"out = (netsocket*)init_instance::get_outgoing_socket("+id+","+dst+",MESSAGE_SOCKET);");            p.println("");        }        p.println("}");        p.println("");        //  +=============================+        //  | Flush Sockets               |        //  +=============================+        p.println("void __flush_sockets_"+id+"() {");        if (!isEliminated) {            Iterator iter2 = fusedWith.iterator();            while (iter2.hasNext()) {                FlatNode tmp = (FlatNode)iter2.next();                int fid = NodeEnumerator.getFlatNodeId(tmp);                p.println("  __flush_sockets_"+fid+"();");            }        }        for(Tape out : data_out) {          if (out != null && out instanceof TapeCluster) {            FlatNode tmp = NodeEnumerator.getFlatNode(out.getDest());            if (!fusedWith.contains(tmp)) {                p.println("  "+((TapeCluster)out).getProducerName()+".flush();");                p.println("  "+((TapeCluster)out).getProducerName()+".get_socket()->close();");            }          }        }        for(Tape out : data_out) {          if (out != null && out instanceof TapeCluster) {            FlatNode tmp = NodeEnumerator.getFlatNode(out.getDest());            if (!fusedWith.contains(tmp)) {                p.println("  "+((TapeCluster)out).getProducerName()+".delete_socket_obj();");            }          }        }        for (Tape in : data_in) {          if (in != null && in instanceof TapeCluster) {            FlatNode tmp = NodeEnumerator.getFlatNode(in.getSource());            if (!fusedWith.contains(tmp)) {                p.println("  "+((TapeCluster)in).getConsumerName()+".delete_socket_obj();");            }          }        }        p.println("}");        p.println("");        //  +=============================+        //  | Peek Sockets                |        //  +=============================+        p.println("void __peek_sockets_"+id+"() {");        if (!isEliminated) {            Iterator iter2 = fusedWith.iterator();            while (iter2.hasNext()) {                FlatNode tmp = (FlatNode)iter2.next();                int fid = NodeEnumerator.getFlatNodeId(tmp);                p.println("  __peek_sockets_"+fid+"();");            }        }        for (Tape in : data_in) {          if (in != null && in instanceof TapeCluster) {            FlatNode tmp = NodeEnumerator.getFlatNode(in.getSource());            if (!fusedWith.contains(tmp)) {                p.println("  "+((TapeCluster)in).getConsumerName()+".peek(0);");            }          }        }        p.println("}");	//p.println("#endif // __CLUSTER_STANDALONE\n");        p.println("");	}        return;    }