Program: 15436
Project: 15436
Buggy source:
public static int[] tokenizeAndClean(final char[] rawArr){
  final int[] passOneResult=tokenize(rawArr);
  final int passOneResultLength=passOneResult.length;
  final boolean[] toRevert=new boolean[passOneResultLength];
  final boolean[] toDelete=new boolean[passOneResultLength];
  int lastUnderscore=-1, lastUnderscoreDouble=-1;
  int lastAsterisk=-1, lastAsteriskDouble=-1;
  int lastTildeDouble=-1;
  int lastGrave=-1;
  int lastBracketSquareOpen=-1;
  for (int i=0; i < passOneResultLength; i++) {
    final int c=passOneResult[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:
if (lastGrave < 0) {
lastGrave=i;
}
 else {
if (lastGrave == i - 1) {
toRevert[lastGrave]=true;
toRevert[i]=true;
}
lastGrave=-1;
}
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(passOneResult,TOKEN_PAREN_OPEN,lastBracketSquareClose + 1,passOneResultLength);
boolean linkParseSuccess=false;
if (parenOpenPos >= 0) {
if (isSpaces(passOneResult,lastBracketSquareClose + 1,parenOpenPos)) {
final int parenClosePos=indexOf(passOneResult,TOKEN_PAREN_CLOSE,parenOpenPos + 1,passOneResultLength);
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 (passOneResult[j] < 0) toRevert[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:
toRevert[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 (lastGrave >= 0) toRevert[lastGrave]=true;
if (lastBracketSquareOpen >= 0) toRevert[lastBracketSquareOpen]=true;
final int[] passTwoResult=new int[rawArr.length];
int passTwoPos=0;
for (int i=0; i < passOneResultLength; i++) {
if (toDelete[i]) continue;
if (toRevert[i]) {
final char[] revertTo=reverseLookup[20 + passOneResult[i]];
for (final char rCh : revertTo) {
passTwoResult[passTwoPos++]=rCh;
}
}
 else {
passTwoResult[passTwoPos++]=passOneResult[i];
}
}
return Arrays.copyOf(passTwoResult,passTwoPos);
}

Fixed version (ground truth):
public static int[] tokenizeAndClean(final char[] rawArr){
  final int[] passOneResult=tokenize(rawArr);
  final int passOneResultLength=passOneResult.length;
  final boolean[] toRevert=new boolean[passOneResultLength];
  final boolean[] toDelete=new boolean[passOneResultLength];
  int lastUnderscore=-1, lastUnderscoreDouble=-1;
  int lastAsterisk=-1, lastAsteriskDouble=-1;
  int lastTildeDouble=-1;
  int lastBracketSquareOpen=-1;
  for (int i=0; i < passOneResultLength; i++) {
    final int c=passOneResult[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(passOneResult,TOKEN_GRAVE,i + 1,passOneResultLength);
if (closingGrave < 0) {
toRevert[i]=true;
}
 else {
for (int j=openingGrave + 1; j < closingGrave; j++) {
if (passOneResult[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(passOneResult,TOKEN_PAREN_OPEN,lastBracketSquareClose + 1,passOneResultLength);
boolean linkParseSuccess=false;
if (parenOpenPos >= 0) {
if (isSpaces(passOneResult,lastBracketSquareClose + 1,parenOpenPos)) {
final int parenClosePos=indexOf(passOneResult,TOKEN_PAREN_CLOSE,parenOpenPos + 1,passOneResultLength);
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 (passOneResult[j] < 0) toRevert[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:
toRevert[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;
final int[] passTwoResult=new int[rawArr.length];
int passTwoPos=0;
for (int i=0; i < passOneResultLength; i++) {
if (toDelete[i]) continue;
if (toRevert[i]) {
final char[] revertTo=reverseLookup[20 + passOneResult[i]];
for (final char rCh : revertTo) {
passTwoResult[passTwoPos++]=rCh;
}
}
 else {
passTwoResult[passTwoPos++]=passOneResult[i];
}
}
return Arrays.copyOf(passTwoResult,passTwoPos);
}