Program: 12181
Project: 12181
Buggy source:
void build_CDPS(Instantiation inst){
  for (Condition cond=inst.top_of_instantiated_conditions; cond != null; cond=cond.next) {
    final PositiveCondition pc=cond.asPositiveCondition();
    final BackTraceInfo bt=pc != null ? pc.bt() : null;
    if (pc != null) {
      bt.clearContextDependentPreferenceSet();
    }
    if (pc != null && bt.trace != null) {
      if (bt.trace.slot != null) {
        if (this.chunker.chunkThroughEvaluationRules) {
          if (bt.trace.slot.hasContextDependentPreferenceSet()) {
            for (Iterator<Preference> it=bt.trace.slot.getContextDependentPreferenceSet().iterator(); it.hasNext(); ) {
              Preference new_pref=null;
              Preference pref=it.next();
              if (pref.inst.match_goal_level == inst.match_goal_level && pref.isInTempMemory()) {
                bt.addContextDependentPreference(pref);
              }
 else {
                new_pref=Preference.find_clone_for_level(pref,inst.match_goal_level);
                if (new_pref != null) {
                  if (new_pref.isInTempMemory()) {
                    bt.addContextDependentPreference(new_pref);
                  }
                }
              }
            }
          }
        }
 else {
          Preference pref=bt.trace.slot.getPreferencesByType(PreferenceType.PROHIBIT);
          while (pref != null) {
            Preference new_pref=null;
            if (pref.inst.match_goal_level == inst.match_goal_level && pref.isInTempMemory()) {
              bt.addContextDependentPreference(pref);
            }
 else {
              new_pref=Preference.find_clone_for_level(pref,inst.match_goal_level);
              if (new_pref != null) {
                if (new_pref.isInTempMemory()) {
                  bt.addContextDependentPreference(new_pref);
                }
              }
            }
            pref=pref.next;
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
void build_CDPS(Instantiation inst){
  for (Condition cond=inst.top_of_instantiated_conditions; cond != null; cond=cond.next) {
    final PositiveCondition pc=cond.asPositiveCondition();
    final BackTraceInfo bt=pc != null ? pc.bt() : null;
    if (pc != null) {
      bt.clearContextDependentPreferenceSet();
    }
    if (pc != null && bt.trace != null) {
      if (bt.trace.slot != null) {
        if (this.chunker.chunkThroughEvaluationRules) {
          if (bt.trace.slot.hasContextDependentPreferenceSet()) {
            for (Iterator<Preference> it=bt.trace.slot.getContextDependentPreferenceSet().iterator(); it.hasNext(); ) {
              Preference new_pref=null;
              Preference pref=it.next();
              if (pref.inst.match_goal_level == inst.match_goal_level && pref.isInTempMemory()) {
                bt.addContextDependentPreference(pref);
                pref.preference_add_ref();
              }
 else {
                new_pref=Preference.find_clone_for_level(pref,inst.match_goal_level);
                if (new_pref != null) {
                  if (new_pref.isInTempMemory()) {
                    bt.addContextDependentPreference(new_pref);
                    new_pref.preference_add_ref();
                  }
                }
              }
            }
          }
        }
 else {
          Preference pref=bt.trace.slot.getPreferencesByType(PreferenceType.PROHIBIT);
          while (pref != null) {
            Preference new_pref=null;
            if (pref.inst.match_goal_level == inst.match_goal_level && pref.isInTempMemory()) {
              bt.addContextDependentPreference(pref);
              pref.preference_add_ref();
            }
 else {
              new_pref=Preference.find_clone_for_level(pref,inst.match_goal_level);
              if (new_pref != null) {
                if (new_pref.isInTempMemory()) {
                  bt.addContextDependentPreference(new_pref);
                  new_pref.preference_add_ref();
                }
              }
            }
            pref=pref.next;
          }
        }
      }
    }
  }
}