Program: 15430
Project: 15430
Buggy source:
private static void clean(final IntArrayLengthPair input,final IntArrayLengthPair output){
  final boolean[] toRevert=new boolean[input.pos];
  final boolean[] toDelete=new boolean[input.pos];
  int lastUnderscore=-1, lastUnderscoreDouble=-1;
  int lastAsterisk=-1, lastAsteriskDouble=-1;
  int lastTildeDouble=-1;
  int lastBracketSquareOpen=-1;
  for (int i=0; i < input.pos; i++) {
    final int c=input.data[i];
switch (c) {
case TOKEN_UNDERSCORE:
      lastUnderscore=lastUnderscore < 0 ? i : -1;
    break;
case TOKEN_UNDERSCORE_DOUBLE:
  if (lastUnderscoreDouble < 0) {
    lastUnderscoreDouble=i;
  }
 else {
    if (lastUnderscoreDouble == i - 1) {
      toRevert[lastUnderscoreDouble]=true;
      toRevert[i]=true;
    }
    lastUnderscoreDouble=-1;
  }
break;
case TOKEN_ASTERISK:
lastAsterisk=lastAsterisk < 0 ? i : -1;
break;
case TOKEN_ASTERISK_DOUBLE:
if (lastAsteriskDouble < 0) {
lastAsteriskDouble=i;
}
 else {
if (lastAsteriskDouble == i - 1) {
toRevert[lastAsteriskDouble]=true;
toRevert[i]=true;
}
lastAsteriskDouble=-1;
}
break;
case TOKEN_TILDE_DOUBLE:
if (lastTildeDouble < 0) {
lastTildeDouble=i;
}
 else {
if (lastTildeDouble == i - 1) {
toRevert[lastTildeDouble]=true;
toRevert[i]=true;
}
lastTildeDouble=-1;
}
break;
case TOKEN_GRAVE:
final int openingGrave=i;
final int closingGrave=indexOf(input.data,TOKEN_GRAVE,i + 1,input.pos);
if (closingGrave < 0) {
toRevert[i]=true;
}
 else {
for (int j=openingGrave + 1; j < closingGrave; j++) {
if (input.data[j] < 0) toRevert[j]=true;
}
i=closingGrave;
}
break;
case TOKEN_BRACKET_SQUARE_OPEN:
if (lastBracketSquareOpen < 0) {
lastBracketSquareOpen=i;
}
 else {
toRevert[lastBracketSquareOpen]=true;
lastBracketSquareOpen=i;
}
break;
case TOKEN_BRACKET_SQUARE_CLOSE:
if (lastBracketSquareOpen < 0) {
toRevert[i]=true;
}
 else {
final int lastBracketSquareClose=i;
final int parenOpenPos=indexOf(input.data,TOKEN_PAREN_OPEN,lastBracketSquareClose + 1,input.pos);
boolean linkParseSuccess=false;
if (parenOpenPos >= 0) {
if (isSpaces(input.data,lastBracketSquareClose + 1,parenOpenPos)) {
final int parenClosePos=findParenClosePos(input,parenOpenPos + 1);
if (parenClosePos >= 0) {
linkParseSuccess=true;
for (int j=lastBracketSquareClose + 1; j < parenOpenPos; j++) {
toDelete[j]=true;
}
for (int j=parenOpenPos + 1; j < parenClosePos; j++) {
if (input.data[j] < 0) {
toRevert[j]=true;
}
 else if (input.data[j] == ' ' && input.data[j - 1] == ' ') {
toDelete[j]=true;
}
}
for (int j=parenOpenPos + 1; input.data[j] == ' '; j++) {
toDelete[j]=true;
}
for (int j=parenClosePos - 1; input.data[j] == ' '; j--) {
toDelete[j]=true;
}
i=parenClosePos;
}
}
}
if (!linkParseSuccess) {
toRevert[lastBracketSquareOpen]=true;
toRevert[lastBracketSquareClose]=true;
i=lastBracketSquareClose;
}
}
lastBracketSquareOpen=-1;
break;
case TOKEN_PAREN_OPEN:
case TOKEN_PAREN_CLOSE:
case TOKEN_UNICODE_CLOSE:
toRevert[i]=true;
break;
case TOKEN_UNICODE_OPEN:
final int openingUnicode=i;
final int closingUnicode=indexOf(input.data,TOKEN_UNICODE_CLOSE,i + 1,Math.min(input.pos,i + 8));
if (closingUnicode < 0 || !isDigits(input.data,openingUnicode + 1,closingUnicode)) {
toRevert[i]=true;
}
 else {
final int codePoint=getDecimal(input.data,openingUnicode + 1,closingUnicode);
input.data[openingUnicode]=codePoint;
for (int j=openingUnicode + 1; j <= closingUnicode; j++) {
toDelete[j]=true;
}
i=closingUnicode;
}
break;
case ' ':
if (i < 1 || input.data[i - 1] == ' ') {
toDelete[i]=true;
}
break;
}
}
if (lastUnderscore >= 0) toRevert[lastUnderscore]=true;
if (lastUnderscoreDouble >= 0) toRevert[lastUnderscoreDouble]=true;
if (lastAsterisk >= 0) toRevert[lastAsterisk]=true;
if (lastAsteriskDouble >= 0) toRevert[lastAsteriskDouble]=true;
if (lastTildeDouble >= 0) toRevert[lastTildeDouble]=true;
if (lastBracketSquareOpen >= 0) toRevert[lastBracketSquareOpen]=true;
for (int j=input.pos - 1; input.data[j] == ' '; j--) {
toDelete[j]=true;
}
output.clear();
for (int i=0; i < input.pos; i++) {
if (toDelete[i]) continue;
if (toRevert[i]) {
final char[] revertTo=reverseLookup[20 + input.data[i]];
output.append(revertTo);
}
 else {
output.data[output.pos++]=input.data[i];
}
}
}

Fixed version (ground truth):
private static void clean(final IntArrayLengthPair input,final IntArrayLengthPair output){
  final boolean[] toRevert=new boolean[input.pos];
  final boolean[] toDelete=new boolean[input.pos];
  int lastUnderscore=-1, lastUnderscoreDouble=-1;
  int lastAsterisk=-1, lastAsteriskDouble=-1;
  int lastTildeDouble=-1;
  int lastBracketSquareOpen=-1;
  for (int i=0; i < input.pos; i++) {
    final int c=input.data[i];
switch (c) {
case TOKEN_UNDERSCORE:
      lastUnderscore=lastUnderscore < 0 ? i : -1;
    break;
case TOKEN_UNDERSCORE_DOUBLE:
  if (lastUnderscoreDouble < 0) {
    lastUnderscoreDouble=i;
  }
 else {
    if (lastUnderscoreDouble == i - 1) {
      toRevert[lastUnderscoreDouble]=true;
      toRevert[i]=true;
    }
    lastUnderscoreDouble=-1;
  }
break;
case TOKEN_ASTERISK:
lastAsterisk=lastAsterisk < 0 ? i : -1;
break;
case TOKEN_ASTERISK_DOUBLE:
if (lastAsteriskDouble < 0) {
lastAsteriskDouble=i;
}
 else {
if (lastAsteriskDouble == i - 1) {
toRevert[lastAsteriskDouble]=true;
toRevert[i]=true;
}
lastAsteriskDouble=-1;
}
break;
case TOKEN_TILDE_DOUBLE:
if (lastTildeDouble < 0) {
lastTildeDouble=i;
}
 else {
if (lastTildeDouble == i - 1) {
toRevert[lastTildeDouble]=true;
toRevert[i]=true;
}
lastTildeDouble=-1;
}
break;
case TOKEN_GRAVE:
final int openingGrave=i;
final int closingGrave=indexOf(input.data,TOKEN_GRAVE,i + 1,input.pos);
if (closingGrave < 0) {
toRevert[i]=true;
}
 else {
for (int j=openingGrave + 1; j < closingGrave; j++) {
if (input.data[j] < 0) toRevert[j]=true;
}
i=closingGrave;
}
break;
case TOKEN_BRACKET_SQUARE_OPEN:
if (lastBracketSquareOpen < 0) {
lastBracketSquareOpen=i;
}
 else {
toRevert[lastBracketSquareOpen]=true;
lastBracketSquareOpen=i;
}
break;
case TOKEN_BRACKET_SQUARE_CLOSE:
if (lastBracketSquareOpen < 0) {
toRevert[i]=true;
}
 else {
final int lastBracketSquareClose=i;
final int parenOpenPos=indexOf(input.data,TOKEN_PAREN_OPEN,lastBracketSquareClose + 1,input.pos);
boolean linkParseSuccess=false;
if (parenOpenPos >= 0) {
if (isSpaces(input.data,lastBracketSquareClose + 1,parenOpenPos)) {
final int parenClosePos=findParenClosePos(input,parenOpenPos + 1);
if (parenClosePos >= 0) {
linkParseSuccess=true;
for (int j=lastBracketSquareClose + 1; j < parenOpenPos; j++) {
toDelete[j]=true;
}
for (int j=parenOpenPos + 1; j < parenClosePos; j++) {
if (input.data[j] < 0) {
toRevert[j]=true;
}
 else if (input.data[j] == ' ' && input.data[j - 1] == ' ') {
toDelete[j]=true;
}
}
for (int j=parenOpenPos + 1; input.data[j] == ' '; j++) {
toDelete[j]=true;
}
for (int j=parenClosePos - 1; input.data[j] == ' '; j--) {
toDelete[j]=true;
}
i=parenClosePos;
}
}
}
if (!linkParseSuccess) {
toRevert[lastBracketSquareOpen]=true;
toRevert[lastBracketSquareClose]=true;
i=lastBracketSquareClose;
}
}
lastBracketSquareOpen=-1;
break;
case TOKEN_PAREN_OPEN:
case TOKEN_PAREN_CLOSE:
case TOKEN_UNICODE_CLOSE:
toRevert[i]=true;
break;
case TOKEN_UNICODE_OPEN:
final int openingUnicode=i;
final int closingUnicode=indexOf(input.data,TOKEN_UNICODE_CLOSE,i + 1,Math.min(input.pos,i + 8));
if (closingUnicode < 0 || !isDigits(input.data,openingUnicode + 1,closingUnicode)) {
toRevert[i]=true;
}
 else {
final int codePoint=getDecimal(input.data,openingUnicode + 1,closingUnicode);
input.data[openingUnicode]=codePoint;
for (int j=openingUnicode + 1; j <= closingUnicode; j++) {
toDelete[j]=true;
}
i=closingUnicode;
}
break;
case ' ':
if (i < 1 || input.data[i - 1] == ' ') {
toDelete[i]=true;
}
break;
}
}
if (lastUnderscore >= 0) toRevert[lastUnderscore]=true;
if (lastUnderscoreDouble >= 0) toRevert[lastUnderscoreDouble]=true;
if (lastAsterisk >= 0) toRevert[lastAsterisk]=true;
if (lastAsteriskDouble >= 0) toRevert[lastAsteriskDouble]=true;
if (lastTildeDouble >= 0) toRevert[lastTildeDouble]=true;
if (lastBracketSquareOpen >= 0) toRevert[lastBracketSquareOpen]=true;
for (int j=input.pos - 1; j >= 0 && input.data[j] == ' '; j--) {
toDelete[j]=true;
}
output.clear();
for (int i=0; i < input.pos; i++) {
if (toDelete[i]) continue;
if (toRevert[i]) {
final char[] revertTo=reverseLookup[20 + input.data[i]];
output.append(revertTo);
}
 else {
output.data[output.pos++]=input.data[i];
}
}
}