Program: 187094
Project: 187094
Buggy source:
/** 
 * Outputs in the format similar to Table 1 in the DATE paper.
 * @return the formatted string
 */
public String toCodeString(){
  StringBuffer sb=new StringBuffer();
  if (nodetype == WCETBasicBlock.SNODE) {
    sb.append(WU.postpad(getIDS() + "String_Node_Str",6));
  }
 else   if (nodetype == WCETBasicBlock.TNODE) {
    String tStr="String_Node_Str";
    for (Iterator iter=inbbs.keySet().iterator(); iter.hasNext(); ) {
      Integer keyInt=(Integer)iter.next();
      WCETBasicBlock wcbb=(WCETBasicBlock)inbbs.get(keyInt);
      tStr+=wcbb.getIDS();
      if (iter.hasNext())       tStr+="String_Node_Str";
    }
    tStr+="String_Node_Str";
    sb.append(WU.postpad(getIDS() + tStr + "String_Node_Str",6));
  }
 else {
    InstructionHandle ih=stih;
    blockcyc=0;
    LineNumberTable lnt=wcmb.methodbcel.getLineNumberTable();
    int prevLine=-1;
    int srcLine=-1;
    do {
      if (wcmb.wca.jline) {
        srcLine=lnt.getSourceLine(ih.getPosition());
        if (srcLine > prevLine) {
          int ai=wcmb.codeLines[srcLine - 1].trim().indexOf("String_Node_Str");
          String c="String_Node_Str";
          if (ai != -1) {
            c=wcmb.codeLines[srcLine - 1].trim().substring(ai);
            sb.append(WU.postpad(wcmb.wca.las + wcmb.wca.las + wcmb.wca.las+ wcmb.wca.las+ wcmb.wca.las+ wcmb.wca.las+ "String_Node_Str"+ srcLine+ "String_Node_Str"+ wcmb.codeLines[srcLine - 1].trim()+ wcmb.wca.lae,62) + "String_Node_Str");
          }
 else           sb.append(WU.postpad(wcmb.wca.las + wcmb.wca.las + wcmb.wca.las+ wcmb.wca.las+ wcmb.wca.las+ wcmb.wca.las+ "String_Node_Str"+ srcLine+ "String_Node_Str"+ wcmb.codeLines[srcLine - 1].trim()+ wcmb.wca.lae,62) + "String_Node_Str");
        }
        prevLine=srcLine;
      }
      if (ih == stih) {
        String tStr="String_Node_Str";
        for (Iterator iter=inbbs.keySet().iterator(); iter.hasNext(); ) {
          Integer keyInt=(Integer)iter.next();
          WCETBasicBlock wcbb=(WCETBasicBlock)inbbs.get(keyInt);
          tStr+=wcbb.getIDS();
          if (iter.hasNext())           tStr+="String_Node_Str";
        }
        tStr+="String_Node_Str";
        sb.append(WU.postpad(getIDS() + tStr,6));
      }
 else {
        sb.append("String_Node_Str");
      }
      sb.append(wcmb.wca.las);
      sb.append(WU.postpad(ih.getPosition() + "String_Node_Str",6));
      if (!WCETInstruction.wcetAvailable(ih.getInstruction().getOpcode()))       sb.append("String_Node_Str");
 else       sb.append("String_Node_Str");
      sb.append(wcmb.wca.las);
      StringBuffer ihs=new StringBuffer(ih.getInstruction().getName() + "String_Node_Str" + ih.getInstruction().getOpcode()+ "String_Node_Str");
      if (ih.getInstruction() instanceof BranchInstruction) {
        InstructionHandle ihtar=((BranchInstruction)ih.getInstruction()).getTarget();
        int tarpos=ihtar.getPosition();
        ihs.append("String_Node_Str" + tarpos + "String_Node_Str");
      }
      sb.append(WU.postpad(ihs.toString(),20));
      sb.append(wcmb.wca.las);
      String invoStr="String_Node_Str";
      if (ih.getInstruction() instanceof InvokeInstruction) {
        String methodid=((InvokeInstruction)ih.getInstruction()).getClassName(wcmb.getCpg()) + "String_Node_Str" + ((InvokeInstruction)ih.getInstruction()).getMethodName(wcmb.getCpg())+ ((InvokeInstruction)ih.getInstruction()).getSignature(wcmb.getCpg());
        String retsig=((InvokeInstruction)ih.getInstruction()).getReturnType(wcmb.getCpg()).getSignature();
        bbinvo=methodid;
        Method m=wcmb.wca.getMethod(methodid);
        if (methodid.startsWith("String_Node_Str")) {
          int opcode=wcmb.wca.getNativeOpcode(m.getName());
          if (opcode == -1) {
            sb.append(WU.prepad("String_Node_Str",10));
            invoStr=methodid + "String_Node_Str";
          }
 else {
            int cycles=WCETInstruction.getCycles(opcode,false,0);
            blockcyc+=cycles;
            sb.append(WU.prepad(Integer.toString(cycles),10));
            sb.append("String_Node_Str");
            sb.append("String_Node_Str");
            invoStr=methodid;
          }
        }
 else         if (m != null && !m.isAbstract()) {
          int invon=-1;
          if (m.getCode() != null) {
            invon=(m.getCode().getCode().length + 3) / 4;
          }
 else {
            invon=0;
          }
          int invokehit=WCETInstruction.getCyclesFromHandle(ih,false,invon);
          int invokemiss=WCETInstruction.getCyclesFromHandle(ih,true,invon);
          int rethit=-1;
          int retmiss=-1;
          if (retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.RETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.RETURN,true,wcmb.n);
          }
 else           if (retsig.equals("String_Node_Str") || retsig.equals("String_Node_Str") || retsig.equals("String_Node_Str")|| retsig.equals("String_Node_Str")|| retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.IRETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.IRETURN,true,wcmb.n);
          }
 else           if (retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.LRETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.LRETURN,true,wcmb.n);
          }
 else           if (retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.DRETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.DRETURN,true,wcmb.n);
          }
 else           if (retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.FRETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.FRETURN,true,wcmb.n);
          }
 else           if (retsig.startsWith("String_Node_Str") || retsig.startsWith("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.ARETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.ARETURN,true,wcmb.n);
          }
 else {
            System.out.println("String_Node_Str" + retsig + "String_Node_Str");
            System.exit(-1);
          }
          int cacheInvokeMiss=(invokemiss - invokehit);
          int cacheReturnMiss=(retmiss - rethit);
          blockcyc+=invokehit;
          blockcyc+=cacheInvokeMiss;
          blockcyc+=cacheReturnMiss;
          if ((((InvokeInstruction)ih.getInstruction()).getClassName(wcmb.getCpg())).equals(wcmb.wca.nativeClass)) {
            sb.append(WU.prepad("String_Node_Str",10));
          }
 else {
            sb.append(WU.prepad(invokehit + "String_Node_Str",10));
            sb.append(WU.prepad(wcmb.wca.las + cacheInvokeMiss + "String_Node_Str",8));
            sb.append(WU.prepad(wcmb.wca.las + cacheReturnMiss + "String_Node_Str",8));
          }
          sb.append("String_Node_Str");
          invoStr=methodid + "String_Node_Str" + invon+ "String_Node_Str"+ invokehit+ "String_Node_Str"+ invokemiss+ "String_Node_Str"+ wcmb.getN()+ "String_Node_Str"+ rethit+ "String_Node_Str"+ retmiss;
          if ((((InvokeInstruction)ih.getInstruction()).getClassName(wcmb.getCpg())).equals(wcmb.wca.nativeClass)) {
            invoStr=methodid;
          }
        }
 else {
          sb.append("String_Node_Str");
        }
      }
 else {
        int wcetih;
        if (ih.getInstruction() instanceof ReturnInstruction) {
          wcetih=WCETInstruction.getCyclesFromHandle(ih,false,wcmb.getN());
          sb.append(WU.prepad(Integer.toString(wcetih),10));
        }
 else {
          wcetih=WCETInstruction.getCyclesFromHandle(ih,false,wcmb.getN());
          sb.append(WU.prepad(Integer.toString(wcetih),10));
        }
        blockcyc+=wcetih;
        sb.append(wcmb.wca.las + "String_Node_Str");
        sb.append(wcmb.wca.las + "String_Node_Str");
      }
      sb.append(wcmb.wca.las);
      sb.append(invoStr);
      if (ih.getInstruction() instanceof FieldInstruction) {
        String fieStrType=((FieldInstruction)ih.getInstruction()).getFieldType(wcmb.getCpg()).toString();
        sb.append(fieStrType + "String_Node_Str");
        if (ih.getInstruction() instanceof FieldOrMethod) {
          String fieStrClass=((FieldOrMethod)ih.getInstruction()).getClassName(wcmb.getCpg());
          sb.append(fieStrClass + "String_Node_Str");
        }
        String fieStrName=((FieldInstruction)ih.getInstruction()).getFieldName(wcmb.cpg);
        sb.append(fieStrName);
      }
      if (ih.getInstruction() instanceof LocalVariableInstruction) {
        if (ih.getInstruction() instanceof StoreInstruction) {
          StoreInstruction si=(StoreInstruction)ih.getInstruction();
          String siStr=wcmb.getLocalVarName(si.getIndex(),ih.getPosition() + ih.getInstruction().getLength());
          if (siStr.length() > 0)           sb.append("String_Node_Str" + siStr + "String_Node_Str");
        }
 else {
          LocalVariableInstruction lvi=(LocalVariableInstruction)ih.getInstruction();
          String lvStr=wcmb.getLocalVarName(lvi.getIndex(),ih.getPosition());
          if (lvStr.length() > 0)           sb.append(lvStr + "String_Node_Str");
        }
      }
      if (ih.getInstruction() instanceof ArrayInstruction) {
        String aType=((ArrayInstruction)ih.getInstruction()).getType(wcmb.getCpg()).getSignature();
        sb.append(aType + "String_Node_Str");
      }
      if (ih == endih) {
        sb.append("String_Node_Str" + bid + "String_Node_Str");
        sb.append(WU.prepad("String_Node_Str" + blockcyc,7));
      }
      sb.append(wcmb.wca.lae + "String_Node_Str");
    }
 while (ih != endih && (ih=ih.getNext()) != null);
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Outputs in the format similar to Table 1 in the DATE paper.
 * @return the formatted string
 */
public String toCodeString(){
  StringBuffer sb=new StringBuffer();
  if (nodetype == WCETBasicBlock.SNODE) {
    sb.append(WU.postpad(getIDS() + "String_Node_Str",6));
  }
 else   if (nodetype == WCETBasicBlock.TNODE) {
    String tStr="String_Node_Str";
    for (Iterator iter=inbbs.keySet().iterator(); iter.hasNext(); ) {
      Integer keyInt=(Integer)iter.next();
      WCETBasicBlock wcbb=(WCETBasicBlock)inbbs.get(keyInt);
      tStr+=wcbb.getIDS();
      if (iter.hasNext())       tStr+="String_Node_Str";
    }
    tStr+="String_Node_Str";
    sb.append(WU.postpad(getIDS() + tStr + "String_Node_Str",6));
  }
 else {
    InstructionHandle ih=stih;
    blockcyc=0;
    LineNumberTable lnt=wcmb.methodbcel.getLineNumberTable();
    int prevLine=-1;
    int srcLine=-1;
    do {
      if (wcmb.wca.jline) {
        srcLine=lnt.getSourceLine(ih.getPosition());
        if (srcLine > prevLine) {
          int ai=wcmb.codeLines[srcLine - 1].trim().indexOf("String_Node_Str");
          String c="String_Node_Str";
          if (ai != -1) {
            c=wcmb.codeLines[srcLine - 1].trim().substring(ai);
            sb.append(WU.postpad("String_Node_Str" + srcLine + "String_Node_Str"+ wcmb.codeLines[srcLine - 1].trim(),62) + "String_Node_Str");
          }
 else           sb.append(WU.postpad("String_Node_Str" + srcLine + "String_Node_Str"+ wcmb.codeLines[srcLine - 1].trim(),62) + "String_Node_Str");
        }
        prevLine=srcLine;
      }
      if (ih == stih) {
        String tStr="String_Node_Str";
        for (Iterator iter=inbbs.keySet().iterator(); iter.hasNext(); ) {
          Integer keyInt=(Integer)iter.next();
          WCETBasicBlock wcbb=(WCETBasicBlock)inbbs.get(keyInt);
          tStr+=wcbb.getIDS();
          if (iter.hasNext())           tStr+="String_Node_Str";
        }
        tStr+="String_Node_Str";
        sb.append(WU.postpad(getIDS() + tStr,6));
      }
 else {
        sb.append("String_Node_Str");
      }
      sb.append(WU.postpad(ih.getPosition() + "String_Node_Str",6));
      if (!WCETInstruction.wcetAvailable(ih.getInstruction().getOpcode()))       sb.append("String_Node_Str");
 else       sb.append("String_Node_Str");
      StringBuffer ihs=new StringBuffer(ih.getInstruction().getName() + "String_Node_Str" + ih.getInstruction().getOpcode()+ "String_Node_Str");
      if (ih.getInstruction() instanceof BranchInstruction) {
        InstructionHandle ihtar=((BranchInstruction)ih.getInstruction()).getTarget();
        int tarpos=ihtar.getPosition();
        ihs.append("String_Node_Str" + tarpos + "String_Node_Str");
      }
      sb.append(WU.postpad(ihs.toString(),20));
      String invoStr="String_Node_Str";
      if (ih.getInstruction() instanceof InvokeInstruction) {
        String methodid=((InvokeInstruction)ih.getInstruction()).getClassName(wcmb.getCpg()) + "String_Node_Str" + ((InvokeInstruction)ih.getInstruction()).getMethodName(wcmb.getCpg())+ ((InvokeInstruction)ih.getInstruction()).getSignature(wcmb.getCpg());
        String retsig=((InvokeInstruction)ih.getInstruction()).getReturnType(wcmb.getCpg()).getSignature();
        bbinvo=methodid;
        Method m=wcmb.wca.getMethod(methodid);
        if (methodid.startsWith("String_Node_Str")) {
          int opcode=wcmb.wca.getNativeOpcode(m.getName());
          if (opcode == -1) {
            sb.append(WU.prepad("String_Node_Str",10));
            invoStr=methodid + "String_Node_Str";
          }
 else {
            int cycles=WCETInstruction.getCycles(opcode,false,0);
            blockcyc+=cycles;
            sb.append(WU.prepad(Integer.toString(cycles),10));
            sb.append("String_Node_Str");
            sb.append("String_Node_Str");
            invoStr=methodid;
          }
        }
 else         if (m != null && !m.isAbstract()) {
          int invon=-1;
          if (m.getCode() != null) {
            invon=(m.getCode().getCode().length + 3) / 4;
          }
 else {
            invon=0;
          }
          int invokehit=WCETInstruction.getCyclesFromHandle(ih,false,invon);
          int invokemiss=WCETInstruction.getCyclesFromHandle(ih,true,invon);
          int rethit=-1;
          int retmiss=-1;
          if (retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.RETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.RETURN,true,wcmb.n);
          }
 else           if (retsig.equals("String_Node_Str") || retsig.equals("String_Node_Str") || retsig.equals("String_Node_Str")|| retsig.equals("String_Node_Str")|| retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.IRETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.IRETURN,true,wcmb.n);
          }
 else           if (retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.LRETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.LRETURN,true,wcmb.n);
          }
 else           if (retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.DRETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.DRETURN,true,wcmb.n);
          }
 else           if (retsig.equals("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.FRETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.FRETURN,true,wcmb.n);
          }
 else           if (retsig.startsWith("String_Node_Str") || retsig.startsWith("String_Node_Str")) {
            rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.ARETURN,false,wcmb.n);
            retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.ARETURN,true,wcmb.n);
          }
 else {
            System.out.println("String_Node_Str" + retsig + "String_Node_Str");
            System.exit(-1);
          }
          int cacheInvokeMiss=(invokemiss - invokehit);
          int cacheReturnMiss=(retmiss - rethit);
          blockcyc+=invokehit;
          blockcyc+=cacheInvokeMiss;
          blockcyc+=cacheReturnMiss;
          if ((((InvokeInstruction)ih.getInstruction()).getClassName(wcmb.getCpg())).equals(wcmb.wca.nativeClass)) {
            sb.append(WU.prepad("String_Node_Str",10));
          }
 else {
            sb.append(WU.prepad(invokehit + "String_Node_Str",10));
            sb.append(WU.prepad(cacheInvokeMiss + "String_Node_Str",8));
            sb.append(WU.prepad(cacheReturnMiss + "String_Node_Str",8));
          }
          sb.append("String_Node_Str");
          invoStr=methodid + "String_Node_Str" + invon+ "String_Node_Str"+ invokehit+ "String_Node_Str"+ invokemiss+ "String_Node_Str"+ wcmb.getN()+ "String_Node_Str"+ rethit+ "String_Node_Str"+ retmiss;
          if ((((InvokeInstruction)ih.getInstruction()).getClassName(wcmb.getCpg())).equals(wcmb.wca.nativeClass)) {
            invoStr=methodid;
          }
        }
 else {
          sb.append("String_Node_Str");
        }
      }
 else {
        int wcetih;
        if (ih.getInstruction() instanceof ReturnInstruction) {
          wcetih=WCETInstruction.getCyclesFromHandle(ih,false,wcmb.getN());
          sb.append(WU.prepad(Integer.toString(wcetih),10));
        }
 else {
          wcetih=WCETInstruction.getCyclesFromHandle(ih,false,wcmb.getN());
          sb.append(WU.prepad(Integer.toString(wcetih),10));
        }
        blockcyc+=wcetih;
        sb.append("String_Node_Str");
        sb.append("String_Node_Str");
      }
      sb.append(invoStr);
      if (ih.getInstruction() instanceof FieldInstruction) {
        String fieStrType=((FieldInstruction)ih.getInstruction()).getFieldType(wcmb.getCpg()).toString();
        sb.append(fieStrType + "String_Node_Str");
        if (ih.getInstruction() instanceof FieldOrMethod) {
          String fieStrClass=((FieldOrMethod)ih.getInstruction()).getClassName(wcmb.getCpg());
          sb.append(fieStrClass + "String_Node_Str");
        }
        String fieStrName=((FieldInstruction)ih.getInstruction()).getFieldName(wcmb.cpg);
        sb.append(fieStrName);
      }
      if (ih.getInstruction() instanceof LocalVariableInstruction) {
        if (ih.getInstruction() instanceof StoreInstruction) {
          StoreInstruction si=(StoreInstruction)ih.getInstruction();
          String siStr=wcmb.getLocalVarName(si.getIndex(),ih.getPosition() + ih.getInstruction().getLength());
          if (siStr.length() > 0)           sb.append("String_Node_Str" + siStr + "String_Node_Str");
        }
 else {
          LocalVariableInstruction lvi=(LocalVariableInstruction)ih.getInstruction();
          String lvStr=wcmb.getLocalVarName(lvi.getIndex(),ih.getPosition());
          if (lvStr.length() > 0)           sb.append(lvStr + "String_Node_Str");
        }
      }
      if (ih.getInstruction() instanceof ArrayInstruction) {
        String aType=((ArrayInstruction)ih.getInstruction()).getType(wcmb.getCpg()).getSignature();
        sb.append(aType + "String_Node_Str");
      }
      if (ih == endih) {
        sb.append("String_Node_Str" + bid + "String_Node_Str");
        sb.append(WU.prepad("String_Node_Str" + blockcyc,7));
      }
      sb.append("String_Node_Str");
    }
 while (ih != endih && (ih=ih.getNext()) != null);
  }
  return sb.toString();
}