Program: 131374
Project: 131374
Buggy source:
public void backward(DenseFactor[] varBeliefsAdj,DenseFactor[] facBeliefsAdj){
  for (int v=0; v < varBeliefsAdj.length; v++) {
    unnormalizeAdjInPlace(varBeliefs[v],varBeliefsAdj[v],varBeliefsUnSum[v]);
  }
  for (int a=0; a < facBeliefsAdj.length; a++) {
    unnormalizeAdjInPlace(facBeliefs[a],facBeliefsAdj[a],facBeliefsUnSum[a]);
  }
  this.msgsAdj=new Messages[fg.getNumEdges()];
  for (int i=0; i < msgs.length; i++) {
    FgEdge edge=fg.getEdge(i);
    int varId=edge.getVar().getId();
    int facId=edge.getFactor().getId();
    msgsAdj[i]=new Messages(edge,prm.logDomain,prm.normalizeMessages);
    if (edge.isVarToFactor()) {
      initVarToFactorAdj(i,facBeliefsAdj,varId,facId,edge);
    }
 else     if (!(edge.getFactor() instanceof GlobalFactor)) {
      initFactorToVarAdj(i,varBeliefsAdj,varId,facId);
    }
 else {
      msgsAdj[i]=null;
    }
  }
  this.potentialsAdj=new DenseFactor[fg.getNumFactors()];
  for (int a=0; a < fg.getNumFactors(); a++) {
    initPotentialsAdj(a,facBeliefsAdj);
  }
  for (  Factor factor : fg.getFactors()) {
    if (factor instanceof GlobalFactor) {
      ((GlobalFactor)factor).reset();
    }
  }
  if (prm.updateOrder == BpUpdateOrder.SEQUENTIAL) {
    for (int t=tape.size() - 1; t >= 0; t--) {
      backwardSendMessage(t);
      backwardNormalize(t);
      backwardCreateMessage(t);
    }
  }
 else   if (prm.updateOrder == BpUpdateOrder.PARALLEL) {
    int t=tape.size() - 1;
    while (t >= 0) {
      int tTop=t;
      for (; t >= 0; t--) {
        if (tape.edges.get(t) == END_OF_EDGE_CREATION) {
          break;
        }
        backwardSendMessage(t);
        backwardNormalize(t);
      }
      t=tTop;
      for (; t >= 0; t--) {
        if (tape.edges.get(t) == END_OF_EDGE_CREATION) {
          t--;
          break;
        }
        backwardCreateMessage(t);
      }
    }
  }
 else {
    throw new RuntimeException("String_Node_Str" + prm.updateOrder);
  }
}

Fixed version (ground truth):
public void backward(DenseFactor[] varBeliefsAdj,DenseFactor[] facBeliefsAdj){
  for (int v=0; v < varBeliefsAdj.length; v++) {
    unnormalizeAdjInPlace(varBeliefs[v],varBeliefsAdj[v],varBeliefsUnSum[v]);
  }
  for (int a=0; a < facBeliefsAdj.length; a++) {
    unnormalizeAdjInPlace(facBeliefs[a],facBeliefsAdj[a],facBeliefsUnSum[a]);
  }
  this.msgsAdj=new Messages[fg.getNumEdges()];
  for (int i=0; i < msgs.length; i++) {
    FgEdge edge=fg.getEdge(i);
    int varId=edge.getVar().getId();
    int facId=edge.getFactor().getId();
    msgsAdj[i]=new Messages(edge,prm.logDomain,prm.normalizeMessages);
    msgsAdj[i].message.scale(s.zero());
    msgsAdj[i].newMessage.scale(s.zero());
    if (edge.isVarToFactor()) {
      initVarToFactorAdj(i,facBeliefsAdj,varId,facId,edge);
    }
 else     if (!(edge.getFactor() instanceof GlobalFactor)) {
      initFactorToVarAdj(i,varBeliefsAdj,varId,facId);
    }
 else {
      msgsAdj[i]=null;
    }
  }
  this.potentialsAdj=new DenseFactor[fg.getNumFactors()];
  for (int a=0; a < fg.getNumFactors(); a++) {
    initPotentialsAdj(a,facBeliefsAdj);
  }
  for (  Factor factor : fg.getFactors()) {
    if (factor instanceof GlobalFactor) {
      ((GlobalFactor)factor).reset();
    }
  }
  if (prm.updateOrder == BpUpdateOrder.SEQUENTIAL) {
    for (int t=tape.size() - 1; t >= 0; t--) {
      backwardSendMessage(t);
      backwardNormalize(t);
      backwardCreateMessage(t);
    }
  }
 else   if (prm.updateOrder == BpUpdateOrder.PARALLEL) {
    int t=tape.size() - 1;
    while (t >= 0) {
      int tTop=t;
      for (; t >= 0; t--) {
        if (tape.edges.get(t) == END_OF_EDGE_CREATION) {
          break;
        }
        backwardSendMessage(t);
        backwardNormalize(t);
      }
      t=tTop;
      for (; t >= 0; t--) {
        if (tape.edges.get(t) == END_OF_EDGE_CREATION) {
          t--;
          break;
        }
        backwardCreateMessage(t);
      }
    }
  }
 else {
    throw new RuntimeException("String_Node_Str" + prm.updateOrder);
  }
}