Program: 147322
Project: 147322
Buggy source:
int appendString(FeatureExpr ctx,MJIEnv env,int objref,Conditional<String> conditionalS){
  Conditional<Integer> condAref=env.getReferenceField(ctx,objref,"String_Node_Str");
  Map<Integer,FeatureExpr> arefMap=condAref.toMap();
  for (  Integer aref : arefMap.keySet()) {
    FeatureExpr arefCtx=ctx.and(arefMap.get(aref));
    Map<String,FeatureExpr> sMap=conditionalS.simplify(arefCtx).toMap();
    for (    String s : sMap.keySet()) {
      FeatureExpr stringCtx=arefCtx.and(sMap.get(s));
      final int slen=s.length();
      final int alen=env.getArrayLength(aref);
      Conditional<Integer> condCount=env.getIntField(ctx,objref,"String_Node_Str").simplify(stringCtx);
      Map<Integer,FeatureExpr> map=condCount.toMap();
      for (      Integer count : map.keySet()) {
        FeatureExpr currentCtx=stringCtx.and(map.get(count));
        int i, j;
        int n=count + slen;
        if (n < alen) {
          for (i=count, j=0; i < n; i++, j++) {
            env.setCharArrayElement(currentCtx,aref,i,s.charAt(j));
          }
        }
 else {
          int m=3 * alen / 2;
          if (m < n) {
            m=n;
          }
          int arefNew=env.newCharArray(currentCtx,m);
          for (i=0; i < count; i++) {
            env.setCharArrayElement(currentCtx,arefNew,i,env.getCharArrayElement(aref,i).simplify(currentCtx).getValue());
          }
          for (j=0; i < n; i++, j++) {
            env.setCharArrayElement(currentCtx,arefNew,i,s.charAt(j));
          }
          env.setReferenceField(currentCtx,objref,"String_Node_Str",arefNew);
        }
        env.setIntField(currentCtx,objref,"String_Node_Str",n);
      }
    }
  }
  return objref;
}

Fixed version (ground truth):
int appendString(FeatureExpr ctx,MJIEnv env,int objref,Conditional<String> conditionalS){
  Conditional<Integer> condAref=env.getReferenceField(ctx,objref,"String_Node_Str");
  Map<Integer,FeatureExpr> arefMap=condAref.toMap();
  for (  Integer aref : arefMap.keySet()) {
    FeatureExpr arefCtx=ctx.and(arefMap.get(aref));
    Map<String,FeatureExpr> sMap=conditionalS.simplify(arefCtx).toMap();
    for (    String s : sMap.keySet()) {
      FeatureExpr stringCtx=arefCtx.and(sMap.get(s));
      final int slen=s.length();
      final int alen=env.getArrayLength(aref);
      Conditional<Integer> condCount=env.getIntField(ctx,objref,"String_Node_Str").simplify(stringCtx);
      Map<Integer,FeatureExpr> map=condCount.toMap();
      for (      Integer count : map.keySet()) {
        FeatureExpr currentCtx=stringCtx.and(map.get(count));
        int i, j;
        int n=count + slen;
        if (n < alen) {
          for (i=count, j=0; i < n; i++, j++) {
            env.setCharArrayElement(currentCtx,aref,i,s.charAt(j));
          }
        }
 else {
          int m=3 * alen / 2;
          if (m < n) {
            m=n;
          }
          int arefNew=env.newCharArray(currentCtx,m);
          for (i=0; i < count; i++) {
            Map<Character,FeatureExpr> charMap=env.getCharArrayElement(aref,i).simplify(currentCtx).toMap();
            for (            char c : charMap.keySet()) {
              env.setCharArrayElement(currentCtx.and(charMap.get(c)),arefNew,i,c);
            }
          }
          for (j=0; i < n; i++, j++) {
            env.setCharArrayElement(currentCtx,arefNew,i,s.charAt(j));
          }
          env.setReferenceField(currentCtx,objref,"String_Node_Str",arefNew);
        }
        env.setIntField(currentCtx,objref,"String_Node_Str",n);
      }
    }
  }
  return objref;
}