Buggy code:
svHeader + gsePath ) + gseName ) + ".encodeDataset<seq2seq4repair_space>=<seq2seq4repair_space>&ber_encode_" ) + ( SCDCodeGenerator . getUniqueDatasetName ( dataset ) ) ) + ";\n" ) ) ; gsePacketDataInit . append ( ( ( ( ( ( "\t" + gsePath ) + gseName ) + ".getDatasetLength<seq2seq4repair_space>=<seq2seq4repair_space>&ber_get_length_" ) + ( SCDCodeGenerator . getUniqueDatasetName ( dataset ) ) ) + ";\n" ) ) ; gsePacketDataInit . append ( ( ( ( ( ( ( ( ( ( "\t" + gsePath ) + gseName ) + ".send<seq2seq4repair_space>=<seq2seq4repair_space>&gse_send_" ) + ( ied . getName ( ) ) ) + "_" ) + ( ld . getInst ( ) ) ) + "_" ) + gseName ) + ";\n" ) ) ; String gseUpdateFunctionPrototype = ( ( ( ( ( "int<seq2seq4repair_space>gse_send_" + ( ied . getName ( ) ) ) + "_" ) + ( ld . getInst ( ) ) ) + "_" ) + gseName ) + "(unsigned<seq2seq4repair_space>char<seq2seq4repair_space>*buf,<seq2seq4repair_space>CTYPE_BOOLEAN<seq2seq4repair_space>statusChange,<seq2seq4repair_space>CTYPE_INT32U<seq2seq4repair_space>timeAllowedToLive)" ; gseHeader . appendFunctionPrototypes ( ( gseUpdateFunctionPrototype + ";\n" ) ) ; gseSource . appendFunctions ( "\n////<seq2seq4repair_space>returns<seq2seq4repair_space>1<seq2seq4repair_space>if<seq2seq4repair_space>buf<seq2seq4repair_space>contains<seq2seq4repair_space>valid<seq2seq4repair_space>packet<seq2seq4repair_space>data" ) ; gseSource . appendFunctions ( ( ( "\n" + gseUpdateFunctionPrototype ) + "<seq2seq4repair_space>{\n" ) ) ; gseSource . appendFunctions ( ( ( ( "\t" + gsePath ) + gseName ) + ".timeAllowedToLive<seq2seq4repair_space>=<seq2seq4repair_space>timeAllowedToLive;\n\n" ) ) ; gseSource . appendFunctions ( "\tif<seq2seq4repair_space>(statusChange)<seq2seq4repair_space>{\n" ) ; gseSource . appendFunctions ( ( ( ( "\t\t" + gsePath ) + gseName ) + ".stNum++;\n" ) ) ; gseSource . appendFunctions ( ( ( ( "\t\tif<seq2seq4repair_space>(" + gsePath ) + gseName ) + ".stNum<seq2seq4repair_space>==<seq2seq4repair_space>0)<seq2seq4repair_space>{\n" ) ) ; gseSource . appendFunctions ( ( ( ( "\t\t\t" + gsePath ) + gseName ) + ".stNum<seq2seq4repair_space>=<seq2seq4repair_space>1;\n" ) ) ; gseSource . appendFunctions ( "\t\t}\n" ) ; gseSource . appendFunctions ( ( ( ( "\t\t" + gsePath ) + gseName ) + ".sqNum<seq2seq4repair_space>=<seq2seq4repair_space>0;\n" ) ) ; gseSource . appendFunctions ( "\t}\n" ) ; gseSource . appendFunctions ( "\telse<seq2seq4repair_space>{\n" ) ; gseSource . appendFunctions ( ( ( ( "\t\t" + gsePath ) + gseName ) + ".sqNum++;\n" ) ) ; gseSource . appendFunctions ( ( ( ( "\t\tif<seq2seq4repair_space>(" + gsePath ) + gseName ) + ".sqNum<seq2seq4repair_space>==<seq2seq4repair_space>0)<seq2seq4repair_space>{\n" ) ) ; gseSource . appendFunctions ( ( ( ( "\t\t\t" + gsePath ) + gseName ) + ".sqNum<seq2seq4repair_space>=<seq2seq4repair_space>1;\n" ) ) ; gseSource . appendFunctions ( "\t\t}\n\t}\n\n" ) ; gseSource . appendFunctions ( ( ( ( "\treturn<seq2seq4repair_space>gseEncodePacket(&" + gsePath ) + gseName ) + ",<seq2seq4repair_space>buf);\n" ) ) ; gseSource . appendFunctions ( "}\n" ) ; } } } } } iedHeader . appendDatatypes ( "\t\t\t}<seq2seq4repair_space>LN0;\n" ) ; } Iterator < TLN > lns = ld . getLN ( ) . iterator ( ) ; while ( lns . hasNext ( ) ) { TLN ln = lns . next ( ) ; StringBuilder lnName = new StringBuilder ( ) ; if ( ( ln . getPrefix ( ) ) != null ) { lnName . append ( ln . getPrefix ( ) ) ; } lnName . append ( ( ( ( ln . getLnType ( ) . replaceAll ( "[^A-Za-z0-9]" , "_" ) ) + "_" ) + ( ln . getInst ( ) ) ) ) ; iedHeader . appendDatatypes ( ( ( ( ( "\t\t\tstruct<seq2seq4repair_space>" + ( ln . getLnType ( ) . replaceAll ( "[^A-Za-z0-9]" , "_" ) ) ) + "<seq2seq4repair_space>" ) + lnName ) + ";\n" ) ) ; } iedHeader . appendDatatypes ( ( ( "\t\t}<seq2seq4repair_space>" + ldName ) + ";\n" ) ) ; } } iedHeader . appendDatatypes ( ( ( "\t}<seq2seq4repair_space>" + apName ) + ";\n" ) ) ; } } iedHeader . appendDatatypes ( "};\n" ) ; if ( ieds . hasNext ( ) ) { iedHeader . appendDatatypes ( "\n" ) ; } iedSource . appendInstances ( ( ( ( ( "struct<seq2seq4repair_space>" + iedName ) + "<seq2seq4repair_space>" ) + iedName ) + ";\n" ) ) ; iedHeader . appendExtern ( ( ( ( ( "extern<seq2seq4repair_space>struct<seq2seq4repair_space>" + iedName ) + "<seq2seq4repair_space>" ) + iedName ) + ";\n" ) ) ; } dataTypesSource . appendFunctions ( "}\n" ) ; Iterator < TLNodeType > lnTypes = dataTypeTemplates . getLNodeType ( ) . iterator ( ) ; dataTypesHeader . appendDatatypes ( "\n\n////<seq2seq4repair_space>logical<seq2seq4repair_space>nodes\n" ) ; svDecodeDatasetFunction . append ( "void<seq2seq4repair_space>svDecodeDataset(unsigned<seq2seq4repair_space>char<seq2seq4repair_space>*dataset,<seq2seq4repair_space>int<seq2seq4repair_space>datasetLength,<seq2seq4repair_space>int<seq2seq4repair_space>ASDU,<seq2seq4repair_space>unsigned<seq2seq4repair_space>char<seq2seq4repair_space>*svID,<seq2seq4repair_space>int<seq2seq4repair_space>svIDLength,<seq2seq4repair_space>CTYPE_INT16U<seq2seq4repair_space>smpCnt)<seq2seq4repair_space>{\n" ) ; gseDecodeDatasetFunction . append ( "void<seq2seq4repair_space>gseDecodeDataset(unsigned<seq2seq4repair_space>char<seq2seq4repair_space>*dataset,<seq2seq4repair_space>CTYPE_INT16U<seq2seq4repair_space>datasetLength,<seq2seq4repair_space>unsigned<seq2seq4repair_space>char<seq2seq4repair_space>*gocbRef,<seq2seq4repair_space>CTYPE_INT16U<seq2seq4repair_space>gocbRefLength,<seq2seq4repair_space>CTYPE_INT32U<seq2seq4repair_space>timeAllowedToLive,<seq2seq4repair_space>CTYPE_TIMESTAMP<seq2seq4repair_space>T,<seq2seq4repair_space>CTYPE_INT32U<seq2seq4repair_space>stNum,<seq2seq4repair_space>CTYPE_INT32U<seq2seq4repair_space>sqNum)<seq2seq4repair_space>{\n" ) ; while ( lnTypes . hasNext ( ) ) { TLNodeType lnType = lnTypes . next ( ) ; dataTypesHeader . appendDatatypes ( ( ( "struct<seq2seq4repair_space>" + ( lnType . getId ( ) . replaceAll ( "[^A-Za-z0-9]" , "_" ) ) ) + "<seq2seq4repair_space>{" ) ) ; Iterator < TDO > dos = lnType . getDO ( ) . iterator ( ) ; while ( dos . hasNext ( ) ) { TDO dataObject = dos . next ( ) ; String doString = ( ( ( "struct<seq2seq4repair_space>" + ( dataObject . getType ( ) ) ) + "<seq2seq4repair_space>" ) + ( dataObject . getName ( ) ) ) + ";" ; dataTypesHeader . appendDatatypes ( ( "\n\t" + doString ) ) ; } ieds = root . getSCL ( ) . getIED ( ) . iterator ( ) ; while ( ieds . hasNext ( ) ) { TIED ied = ieds . next ( ) ; if ( ( ied . getAccessPoint ( ) ) != null ) { Iterator < TAccessPoint > aps = ied . getAccessPoint ( ) . iterator ( ) ; while ( aps . hasNext ( ) ) { TAccessPoint ap = aps . next ( ) ; if ( ( ( ap . getServer ( ) ) != null ) && ( ( ap . getServer ( ) . getLDevice ( ) . size ( ) ) > 0 ) ) { Iterator < TLDevice > lds = ap . getServer ( ) . getLDevice ( ) . iterator ( ) ; List < String > svControlConsumed = new ArrayList < String > ( ) ; List < String > gseControlConsumed = new ArrayList < String > ( ) ; while ( lds . hasNext ( ) ) { TLDevice ld = lds . next ( ) ; Iterator < TLN > lns = ld . getLN ( ) . iterator ( ) ; while ( lns . hasNext ( ) ) { TLN ln = lns . next ( ) ; if ( ln . getLnType ( ) . equals ( lnType . getId ( ) ) ) { if ( ( ln . getInputs ( ) ) != null ) { Iterator < TExtRef > extRefs = ln . getInputs ( ) . getExtRef ( ) . iterator ( ) ; while ( extRefs . hasNext ( ) ) { TExtRef extRef = extRefs . next ( ) ; Iterator < TDataSet > datasets = extRef . getDataSet ( ) . iterator ( ) ; while ( datasets . hasNext ( ) ) { TDataSet dataset = datasets . next ( ) ; String datasetName = SCDCodeGenerator . getUniqueDatasetName ( dataset ) ; Iterator < TControl > controls = dataset . getControl ( ) . iterator ( ) ; while ( controls . hasNext ( ) ) { TControl control = controls . next ( ) ; if ( ( control . eClass ( ) ) == ( eINSTANCE . getTSampledValueControl ( ) ) ) { TSampledValueControl svControl = ( ( TSampledValueControl ) ( control ) ) ; long noASDU = svControl . getNofASDU ( ) ; String noASDUString = "" ; if ( noASDU > 1 ) { noASDUString = ( "[" + noASDU ) + "]" ; } if ( ! ( svControlConsumed . contains ( svControl . getName ( ) ) ) ) { svControlConsumed . add ( svControl . getName ( ) ) ; String inputsPath = ( ( ( ( ( ( ( ( ( ( ( ied . getName ( ) ) + "." ) + ( ap . getName ( ) ) ) + "." ) + ( ld . getInst ( ) ) ) + "." ) + ( ln . getLnType ( ) . replaceAll ( "[^A-Za-z0-9]" , "_" ) ) ) + "_" ) + ( ln . getInst ( ) ) ) + ".sv_inputs_" ) + ( svControl . getName ( ) ) ) + "." ; svDecodeDatasetFunction . append ( ( ( "\n\tif<seq2seq4repair_space>(strncmp((const<seq2seq4repair_space>char<seq2seq4repair_space>*)<seq2seq4repair_space>svID,<seq2seq4repair_space>\"" + ( svControl . getSmvID ( ) ) ) + "\",<seq2seq4repair_space>svIDLength)<seq2seq4repair_space>==<seq2seq4repair_space>0)<seq2seq4repair_space>{" ) ) ; <START_BUG> svDecodeDatasetFunction . append ( ( ( ( ( ( "\n\t\tdecode_" + datasetName ) + "(dataset,<seq2seq4repair_space>ASDU,<seq2seq4repair_space>smpCnt,<seq2seq4repair_space>&" ) + inputsPath ) + datasetName ) + "[ASDU]);" ) ) ; <END_BUG>

Fix:
svDecodeDatasetFunction . append ( ( ( ( ( ( "\n\t\tdecode_" + datasetName ) + "(dataset,<seq2seq4repair_space>smpCnt,<seq2seq4repair_space>&" ) + inputsPath ) + datasetName ) + "[ASDU]);" ) ) ;