Program: 187098
Project: 187098
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();
  InstructionHandle ih=stih;
  blockcychit=0;
  blockcycmiss=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+="String_Node_Str" + wcbb.getId() + "String_Node_Str";
      }
      tStr+="String_Node_Str";
      sb.append(WU.postpad("String_Node_Str" + id + 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) {
      int wcetihMiss=-1;
      int wcetihHit=-1;
      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();
      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);
          wcetihMiss=cycles;
          wcetihHit=cycles;
          blockcycmiss+=wcetihMiss;
          blockcychit+=wcetihHit;
          sb.append(WU.prepad(Integer.toString(wcetihHit),10));
          sb.append("String_Node_Str");
          sb.append("String_Node_Str");
          invoStr=methodid;
        }
      }
 else       if (m != null && !m.isAbstract()) {
        int n=-1;
        if (m.getCode() != null) {
          n=(m.getCode().getCode().length + 3) / 4;
        }
 else {
          n=0;
        }
        int invokehit=WCETInstruction.getCyclesFromHandle(ih,false,n);
        int invokemiss=WCETInstruction.getCyclesFromHandle(ih,true,n);
        int rethit=-1;
        int retmiss=-1;
        if (retsig.equals("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.RETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.RETURN,true,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,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.IRETURN,true,n);
        }
 else         if (retsig.equals("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.LRETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.LRETURN,true,n);
        }
 else         if (retsig.equals("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.DRETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.DRETURN,true,n);
        }
 else         if (retsig.equals("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.FRETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.FRETURN,true,n);
        }
 else         if (retsig.startsWith("String_Node_Str") || retsig.startsWith("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.ARETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.ARETURN,true,n);
        }
 else {
          System.out.println("String_Node_Str" + retsig + "String_Node_Str");
          System.exit(-1);
        }
        wcetihMiss=invokemiss + retmiss;
        blockcycmiss+=wcetihMiss;
        wcetihHit=invokehit + rethit;
        blockcychit+=wcetihHit;
        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 + (invokemiss - invokehit) + "String_Node_Str",8));
          sb.append(WU.prepad(wcmb.wca.las + (retmiss - rethit) + "String_Node_Str",8));
        }
        sb.append("String_Node_Str");
        invoStr=methodid + "String_Node_Str" + n+ "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+="String_Node_Str";
        }
      }
 else {
        sb.append("String_Node_Str");
      }
    }
 else {
      int wcetihMiss;
      int wcetihHit;
      if (ih.getInstruction() instanceof ReturnInstruction) {
        wcetihMiss=0;
        wcetihHit=WCETInstruction.getCyclesFromHandle(ih,false,wcmb.getN());
        sb.append(WU.prepad(Integer.toString(wcetihHit),10));
      }
 else {
        wcetihMiss=WCETInstruction.getCyclesFromHandle(ih,true,wcmb.getN());
        wcetihHit=WCETInstruction.getCyclesFromHandle(ih,false,wcmb.getN());
        sb.append(WU.prepad(Integer.toString(wcetihHit),10));
      }
      blockcycmiss+=wcetihMiss;
      blockcychit+=wcetihHit;
      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" + id + "String_Node_Str");
      if (ih.getInstruction() instanceof ReturnInstruction) {
        sb.append(WU.prepad(blockcychit + "String_Node_Str",7));
      }
 else {
        sb.append(WU.prepad(blockcychit + "String_Node_Str" + blockcycmiss,7));
      }
    }
    sb.append(wcmb.wca.lae + "String_Node_Str");
  }
 while (ih != endih && (ih=ih.getNext()) != null);
  if (blockcycmiss < blockcychit)   blockcycmiss=blockcychit;
  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();
  InstructionHandle ih=stih;
  blockcychit=0;
  blockcycmiss=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+="String_Node_Str" + wcbb.getId() + "String_Node_Str";
      }
      tStr+="String_Node_Str";
      sb.append(WU.postpad("String_Node_Str" + id + 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) {
      int wcetihMiss=-1;
      int wcetihHit=-1;
      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();
      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);
          wcetihMiss=cycles;
          wcetihHit=cycles;
          blockcycmiss+=wcetihMiss;
          blockcychit+=wcetihHit;
          sb.append(WU.prepad(Integer.toString(wcetihHit),10));
          sb.append("String_Node_Str");
          sb.append("String_Node_Str");
          invoStr=methodid;
        }
      }
 else       if (m != null && !m.isAbstract()) {
        int n=-1;
        if (m.getCode() != null) {
          n=(m.getCode().getCode().length + 3) / 4;
        }
 else {
          n=0;
        }
        int invokehit=WCETInstruction.getCyclesFromHandle(ih,false,n);
        int invokemiss=WCETInstruction.getCyclesFromHandle(ih,true,n);
        int rethit=-1;
        int retmiss=-1;
        if (retsig.equals("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.RETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.RETURN,true,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,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.IRETURN,true,n);
        }
 else         if (retsig.equals("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.LRETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.LRETURN,true,n);
        }
 else         if (retsig.equals("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.DRETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.DRETURN,true,n);
        }
 else         if (retsig.equals("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.FRETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.FRETURN,true,n);
        }
 else         if (retsig.startsWith("String_Node_Str") || retsig.startsWith("String_Node_Str")) {
          rethit=WCETInstruction.getCycles(org.apache.bcel.Constants.ARETURN,false,n);
          retmiss=WCETInstruction.getCycles(org.apache.bcel.Constants.ARETURN,true,n);
        }
 else {
          System.out.println("String_Node_Str" + retsig + "String_Node_Str");
          System.exit(-1);
        }
        wcetihMiss=invokemiss;
        blockcycmiss+=wcetihMiss;
        wcetihHit=invokehit;
        blockcychit+=wcetihHit;
        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 + (invokemiss - invokehit) + "String_Node_Str",8));
          sb.append(WU.prepad(wcmb.wca.las + (retmiss - rethit) + "String_Node_Str",8));
        }
        sb.append("String_Node_Str");
        invoStr=methodid + "String_Node_Str" + n+ "String_Node_Str"+ invokehit+ "String_Node_Str"+ invokemiss;
        if ((((InvokeInstruction)ih.getInstruction()).getClassName(wcmb.getCpg())).equals(wcmb.wca.nativeClass)) {
          invoStr+="String_Node_Str";
        }
      }
 else {
        sb.append("String_Node_Str");
      }
    }
 else {
      int wcetihMiss;
      int wcetihHit;
      if (ih.getInstruction() instanceof ReturnInstruction) {
        wcetihMiss=0;
        wcetihHit=WCETInstruction.getCyclesFromHandle(ih,false,wcmb.getN());
        sb.append(WU.prepad(Integer.toString(wcetihHit),10));
      }
 else {
        wcetihMiss=WCETInstruction.getCyclesFromHandle(ih,true,wcmb.getN());
        wcetihHit=WCETInstruction.getCyclesFromHandle(ih,false,wcmb.getN());
        sb.append(WU.prepad(Integer.toString(wcetihHit),10));
      }
      blockcycmiss+=wcetihMiss;
      blockcychit+=wcetihHit;
      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" + id + "String_Node_Str");
      if (ih.getInstruction() instanceof ReturnInstruction) {
        sb.append(WU.prepad(blockcychit + "String_Node_Str",7));
      }
 else {
        sb.append(WU.prepad(blockcychit + "String_Node_Str" + blockcycmiss,7));
      }
    }
    sb.append(wcmb.wca.lae + "String_Node_Str");
  }
 while (ih != endih && (ih=ih.getNext()) != null);
  if (blockcycmiss < blockcychit)   blockcycmiss=blockcychit;
  return sb.toString();
}