Program: 50348
Project: 50348
Buggy source:
private Alignments.AlignmentEntry andBack(final int index,int originalIndex,final Alignments.AlignmentEntry reduced){
  final Alignments.AlignmentEntry.Builder result=Alignments.AlignmentEntry.newBuilder(reduced);
  final int multiplicity=multiplicities.get(index);
  final int k=multiplicity - 1;
  multiplicities.set(index,k);
  if (!multiplicityFieldsAllMissing) {
    result.setMultiplicity(1);
  }
  final int queryIndex=queryIndices.getInt(originalIndex);
  result.setQueryIndex(queryIndex);
  if (originalIndex == 0 || reduced.hasPosition() || reduced.hasTargetIndex()) {
    previousPosition=reduced.getPosition();
    previousTargetIndex=reduced.getTargetIndex();
  }
 else {
    final int deltaPos=deltaPositions.getInt(deltaPosIndex);
    final int deltaTarget=deltaTargetIndices.getInt(deltaPosIndex);
    final int position=previousPosition + deltaPos;
    final int targetIndex=previousTargetIndex + deltaTarget;
    result.setPosition(position);
    result.setTargetIndex(targetIndex);
    previousPosition+=deltaPos;
    previousTargetIndex+=deltaTarget;
    deltaPosIndex++;
  }
  int anInt=mappingQualities.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setMappingQuality(anInt);
  }
  anInt=fragmentIndices.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setFragmentIndex(anInt);
  }
  anInt=matchingReverseStrand.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setMatchingReverseStrand(anInt == 1);
  }
  anInt=numberOfMismatches.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setNumberOfMismatches(anInt);
  }
  anInt=numberOfIndels.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setNumberOfIndels(anInt);
  }
  anInt=queryLengths.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setQueryLength(anInt);
  }
  anInt=queryAlignedLengths.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setQueryAlignedLength(anInt);
  }
  anInt=queryPositions.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setQueryPosition(anInt);
  }
  anInt=targetAlignedLengths.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setTargetAlignedLength(anInt);
  }
  Alignments.RelatedAlignmentEntry link=pairLinks.decode(originalIndex,reduced.getPairAlignmentLink());
  if (link != null) {
    result.setPairAlignmentLink(link);
  }
  link=forwardSpliceLinks.decode(originalIndex,reduced.getSplicedForwardAlignmentLink());
  if (link != null) {
    result.setSplicedForwardAlignmentLink(link);
  }
  link=backwardSpliceLinks.decode(originalIndex,reduced.getSplicedBackwardAlignmentLink());
  if (link != null) {
    result.setSplicedBackwardAlignmentLink(link);
  }
  final boolean templateHasSequenceVariations=reduced.getSequenceVariationsCount() > 0;
  final int numVariations=variationCount.getInt(index);
  if (queryIndex == 72) {
    System.out.println("String_Node_Str");
  }
  for (int varIndex=0; varIndex < numVariations; varIndex++) {
    final Alignments.SequenceVariation template=templateHasSequenceVariations ? reduced.getSequenceVariations(varIndex) : null;
    final Alignments.SequenceVariation.Builder varBuilder=templateHasSequenceVariations ? Alignments.SequenceVariation.newBuilder(template) : Alignments.SequenceVariation.newBuilder();
    from.setLength(0);
    to.setLength(0);
    final int fromLength=fromLengths.getInt(varPositionIndex);
    final int toLength=toLengths.getInt(varPositionIndex);
    varBuilder.setPosition(varPositions.getInt(varPositionIndex));
    varBuilder.setReadIndex(varReadIndex.getInt(varPositionIndex));
    final boolean hasToQual=varHasToQuals.getInt(varPositionIndex) == 1;
    final byte[] quals=hasToQual ? new byte[toLength] : null;
    ++varPositionIndex;
    final int maxLength=Math.max(fromLength,toLength);
    for (int i=0; i < maxLength; i++) {
      final int fromTo=varFromTo.getInt(varFromToIndex++);
      if (i < fromLength) {
        from.append((char)(fromTo >> 8));
      }
      if (i < toLength) {
        to.append((char)(fromTo & 0xFF));
      }
      if (hasToQual) {
        quals[i]=(byte)varQuals.getInt(varQualIndex);
        ++varQualIndex;
      }
    }
    varBuilder.setFrom(from.toString());
    varBuilder.setTo(to.toString());
    if (hasToQual) {
      varBuilder.setToQuality(ByteString.copyFrom(quals));
    }
    if (templateHasSequenceVariations) {
      result.setSequenceVariations(varIndex,varBuilder);
    }
 else {
      result.addSequenceVariations(varBuilder);
    }
  }
  return result.build();
}

Fixed version (ground truth):
private Alignments.AlignmentEntry andBack(final int index,int originalIndex,final Alignments.AlignmentEntry reduced){
  final Alignments.AlignmentEntry.Builder result=Alignments.AlignmentEntry.newBuilder(reduced);
  final int multiplicity=multiplicities.get(index);
  final int k=multiplicity - 1;
  multiplicities.set(index,k);
  if (!multiplicityFieldsAllMissing) {
    result.setMultiplicity(1);
  }
  final int queryIndex=queryIndices.getInt(originalIndex);
  result.setQueryIndex(queryIndex);
  if (originalIndex == 0 || reduced.hasPosition() || reduced.hasTargetIndex()) {
    previousPosition=reduced.getPosition();
    previousTargetIndex=reduced.getTargetIndex();
  }
 else {
    final int deltaPos=deltaPositions.getInt(deltaPosIndex);
    final int deltaTarget=deltaTargetIndices.getInt(deltaPosIndex);
    final int position=previousPosition + deltaPos;
    final int targetIndex=previousTargetIndex + deltaTarget;
    result.setPosition(position);
    result.setTargetIndex(targetIndex);
    previousPosition+=deltaPos;
    previousTargetIndex+=deltaTarget;
    deltaPosIndex++;
  }
  int anInt=mappingQualities.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setMappingQuality(anInt);
  }
  anInt=fragmentIndices.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setFragmentIndex(anInt);
  }
  anInt=matchingReverseStrand.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setMatchingReverseStrand(anInt == 1);
  }
  anInt=numberOfMismatches.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setNumberOfMismatches(anInt);
  }
  anInt=numberOfIndels.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setNumberOfIndels(anInt);
  }
  anInt=queryLengths.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setQueryLength(anInt);
  }
  anInt=queryAlignedLengths.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setQueryAlignedLength(anInt);
  }
  anInt=queryPositions.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setQueryPosition(anInt);
  }
  anInt=targetAlignedLengths.getInt(index);
  if (anInt != MISSING_VALUE) {
    result.setTargetAlignedLength(anInt);
  }
  Alignments.RelatedAlignmentEntry link=pairLinks.decode(originalIndex,reduced.getPairAlignmentLink());
  if (link != null) {
    result.setPairAlignmentLink(link);
  }
  link=forwardSpliceLinks.decode(originalIndex,reduced.getSplicedForwardAlignmentLink());
  if (link != null) {
    result.setSplicedForwardAlignmentLink(link);
  }
  link=backwardSpliceLinks.decode(originalIndex,reduced.getSplicedBackwardAlignmentLink());
  if (link != null) {
    result.setSplicedBackwardAlignmentLink(link);
  }
  final boolean templateHasSequenceVariations=reduced.getSequenceVariationsCount() > 0;
  final int numVariations=variationCount.getInt(index);
  for (int varIndex=0; varIndex < numVariations; varIndex++) {
    final Alignments.SequenceVariation template=templateHasSequenceVariations ? reduced.getSequenceVariations(varIndex) : null;
    final Alignments.SequenceVariation.Builder varBuilder=templateHasSequenceVariations ? Alignments.SequenceVariation.newBuilder(template) : Alignments.SequenceVariation.newBuilder();
    from.setLength(0);
    to.setLength(0);
    final int fromLength=fromLengths.getInt(varPositionIndex);
    final int toLength=toLengths.getInt(varPositionIndex);
    varBuilder.setPosition(varPositions.getInt(varPositionIndex));
    varBuilder.setReadIndex(varReadIndex.getInt(varPositionIndex));
    final boolean hasToQual=varHasToQuals.getInt(varHasToQualsIndex) == 1;
    varHasToQualsIndex++;
    final byte[] quals=hasToQual ? new byte[toLength] : null;
    ++varPositionIndex;
    final int maxLength=Math.max(fromLength,toLength);
    for (int i=0; i < maxLength; i++) {
      final int fromTo=varFromTo.getInt(varFromToIndex++);
      if (i < fromLength) {
        from.append((char)(fromTo >> 8));
      }
      if (i < toLength) {
        to.append((char)(fromTo & 0xFF));
      }
      if (hasToQual) {
        quals[i]=(byte)varQuals.getInt(varQualIndex);
        ++varQualIndex;
      }
    }
    varBuilder.setFrom(from.toString());
    varBuilder.setTo(to.toString());
    if (hasToQual) {
      varBuilder.setToQuality(ByteString.copyFrom(quals));
    }
    if (templateHasSequenceVariations) {
      result.setSequenceVariations(varIndex,varBuilder);
    }
 else {
      result.addSequenceVariations(varBuilder);
    }
  }
  return result.build();
}