Program: 15435
Project: 15435
Buggy source:
public static int[] tokenizeCleanAndLinkify(final char[] rawArr){
  final int[] passTwoResult=tokenizeAndClean(rawArr);
  final int passTwoResultLength=passTwoResult.length;
  final int[] passThreeResult=new int[rawArr.length * 3];
  int passThreeResultLength=0;
  boolean ready=true;
  for (int i=0; i < passTwoResultLength; i++) {
    final int token=passTwoResult[i];
switch (token) {
case TOKEN_BRACKET_SQUARE_OPEN:
case TOKEN_PAREN_OPEN:
      passThreeResult[passThreeResultLength++]=token;
    ready=false;
  break;
case TOKEN_BRACKET_SQUARE_CLOSE:
case TOKEN_PAREN_CLOSE:
case ' ':
passThreeResult[passThreeResultLength++]=token;
ready=true;
break;
case 'h':
case 'w':
if (ready) {
final int linkStartType=getLinkStartType(passThreeResult,i,passThreeResultLength);
if (linkStartType >= 0) {
int linkEndPos=i + linkPrefixes[linkStartType].length;
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
ready=false;
break;
case 'r':
case 'u':
case '/':
if (ready) {
final int linkStartType=getRedditLinkStartType(passThreeResult,i,passThreeResultLength);
if (linkStartType >= 0) {
final int linkStartPos=i;
final int linkPrefixEndPos=linkPrefixes_reddit[linkStartType].length + linkStartPos;
int linkEndPos=linkPrefixEndPos;
while (linkEndPos < passTwoResultLength) {
final int lToken=passThreeResult[linkEndPos];
final boolean isValidChar=(lToken >= 'a' && lToken <= 'z') || (lToken >= 'A' && lToken <= 'Z') || (lToken >= '0' && lToken <= '9')|| lToken == '_' || lToken == '+' || lToken == '-';
linkEndPos++;
}
if (linkEndPos - linkPrefixEndPos > 2) {
final int[] reverted=revert(passTwoResult,linkStartPos,linkEndPos);
passThreeResult[passThreeResultLength++]=TOKEN_BRACKET_SQUARE_OPEN;
System.arraycopy(reverted,0,passThreeResult,passThreeResultLength,reverted.length);
passThreeResultLength+=reverted.length;
passThreeResult[passThreeResultLength++]=TOKEN_BRACKET_SQUARE_CLOSE;
passThreeResult[passThreeResultLength++]=TOKEN_PAREN_OPEN;
System.arraycopy(reverted,0,passThreeResult,passThreeResultLength,reverted.length);
passThreeResultLength+=reverted.length;
passThreeResult[passThreeResultLength++]=TOKEN_PAREN_CLOSE;
i=linkEndPos;
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
ready=false;
break;
default :
ready=token < 0 || (!Character.isAlphabetic(token) && !Character.isDigit(token) && token != '/');
passThreeResult[passThreeResultLength++]=token;
break;
}
}
return Arrays.copyOf(passThreeResult,passThreeResultLength);
}

Fixed version (ground truth):
public static int[] tokenizeCleanAndLinkify(final char[] rawArr){
  final int[] passTwoResult=tokenizeAndClean(rawArr);
  final int passTwoResultLength=passTwoResult.length;
  final int[] passThreeResult=new int[rawArr.length * 3];
  int passThreeResultLength=0;
  boolean ready=true;
  for (int i=0; i < passTwoResultLength; i++) {
    final int token=passTwoResult[i];
switch (token) {
case TOKEN_BRACKET_SQUARE_OPEN:
case TOKEN_PAREN_OPEN:
      passThreeResult[passThreeResultLength++]=token;
    ready=false;
  break;
case TOKEN_BRACKET_SQUARE_CLOSE:
case TOKEN_PAREN_CLOSE:
case ' ':
passThreeResult[passThreeResultLength++]=token;
ready=true;
break;
case 'h':
case 'w':
if (ready) {
final int linkStartType=getLinkStartType(passTwoResult,i,passTwoResultLength);
if (linkStartType >= 0) {
int linkEndPos=i + linkPrefixes[linkStartType].length;
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
ready=false;
break;
case 'r':
case 'u':
case '/':
if (ready) {
final int linkStartType=getRedditLinkStartType(passTwoResult,i,passTwoResultLength);
if (linkStartType >= 0) {
final int linkStartPos=i;
final int linkPrefixEndPos=linkPrefixes_reddit[linkStartType].length + linkStartPos;
int linkEndPos=linkPrefixEndPos;
while (linkEndPos < passTwoResultLength) {
final int lToken=passTwoResult[linkEndPos];
final boolean isValidChar=(lToken >= 'a' && lToken <= 'z') || (lToken >= 'A' && lToken <= 'Z') || (lToken >= '0' && lToken <= '9')|| lToken == '_' || lToken == TOKEN_UNDERSCORE || lToken == TOKEN_UNDERSCORE_DOUBLE || lToken == '+' || lToken == '-';
if (isValidChar) {
linkEndPos++;
}
 else {
break;
}
}
if (linkEndPos - linkPrefixEndPos > 2) {
final int[] reverted=revert(passTwoResult,linkStartPos,linkEndPos);
passThreeResult[passThreeResultLength++]=TOKEN_BRACKET_SQUARE_OPEN;
System.arraycopy(reverted,0,passThreeResult,passThreeResultLength,reverted.length);
passThreeResultLength+=reverted.length;
passThreeResult[passThreeResultLength++]=TOKEN_BRACKET_SQUARE_CLOSE;
passThreeResult[passThreeResultLength++]=TOKEN_PAREN_OPEN;
System.arraycopy(reverted,0,passThreeResult,passThreeResultLength,reverted.length);
passThreeResultLength+=reverted.length;
passThreeResult[passThreeResultLength++]=TOKEN_PAREN_CLOSE;
i=linkEndPos - 1;
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
}
 else {
passThreeResult[passThreeResultLength++]=token;
}
ready=false;
break;
default :
ready=token < 0 || (!Character.isAlphabetic(token) && !Character.isDigit(token) && token != '/');
passThreeResult[passThreeResultLength++]=token;
break;
}
}
return Arrays.copyOf(passThreeResult,passThreeResultLength);
}