Program: 83567
Project: 83567
Buggy source:
/** 
 * Rotate a block's data value 90 degrees (north->east->south->west->north);
 * @param type
 * @param data
 * @return
 */
public static int rotate90(int type,int data){
switch (type) {
case 50:
case 75:
case 76:
switch (data) {
case 1:
      return 3;
case 2:
    return 4;
case 3:
  return 2;
case 4:
return 1;
}
break;
case 66:
switch (data) {
case 6:
return 7;
case 7:
return 8;
case 8:
return 9;
case 9:
return 6;
}
case 27:
case 28:
switch (data & 0x7) {
case 0:
return 1 | (data & ~0x7);
case 1:
return 0 | (data & ~0x7);
case 2:
return 5 | (data & ~0x7);
case 3:
return 4 | (data & ~0x7);
case 4:
return 2 | (data & ~0x7);
case 5:
return 3 | (data & ~0x7);
}
break;
case 53:
case 67:
case 108:
case 109:
case 114:
switch (data) {
case 0:
return 2;
case 1:
return 3;
case 2:
return 1;
case 3:
return 0;
}
break;
case 69:
case 77:
int thrown=data & 0x8;
int withoutThrown=data & ~0x8;
switch (withoutThrown) {
case 1:
return 3 | thrown;
case 2:
return 4 | thrown;
case 3:
return 2 | thrown;
case 4:
return 1 | thrown;
}
break;
case 64:
case 71:
int topHalf=data & 0x8;
int swung=data & 0x4;
int withoutFlags=data & ~(0x8 | 0x4);
switch (withoutFlags) {
case 0:
return 1 | topHalf | swung;
case 1:
return 2 | topHalf | swung;
case 2:
return 3 | topHalf | swung;
case 3:
return 0 | topHalf | swung;
}
break;
case 63:
return (data + 4) % 16;
case 65:
case 68:
case 54:
case 61:
case 62:
case 23:
switch (data) {
case 2:
return 5;
case 3:
return 4;
case 4:
return 2;
case 5:
return 3;
}
break;
case 86:
case 91:
switch (data) {
case 0:
return 1;
case 1:
return 2;
case 2:
return 3;
case 3:
return 0;
}
break;
case 93:
case 94:
int dir=data & 0x03;
int delay=data - dir;
switch (dir) {
case 0:
return 1 | delay;
case 1:
return 2 | delay;
case 2:
return 3 | delay;
case 3:
return 0 | delay;
}
break;
case 96:
int withoutOrientation=data & ~0x3;
int orientation=data & 0x3;
switch (orientation) {
case 0:
return 3 | withoutOrientation;
case 1:
return 2 | withoutOrientation;
case 2:
return 0 | withoutOrientation;
case 3:
return 1 | withoutOrientation;
}
break;
case 33:
case 29:
case 34:
final int rest=data & ~0x7;
switch (data & 0x7) {
case 2:
return 5 | rest;
case 3:
return 4 | rest;
case 4:
return 2 | rest;
case 5:
return 3 | rest;
}
break;
case 99:
case 100:
if (data >= 10) {
return data;
}
return (data * 3) % 10;
case 106:
return ((data << 1) | (data >> 3)) & 0xf;
case 107:
return ((data + 1) & 0x3) | (data & ~0x3);
}
return data;
}

Fixed version (ground truth):
/** 
 * Rotate a block's data value 90 degrees (north->east->south->west->north);
 * @param type
 * @param data
 * @return
 */
public static int rotate90(int type,int data){
  int dir;
switch (type) {
case 50:
case 75:
case 76:
switch (data) {
case 1:
      return 3;
case 2:
    return 4;
case 3:
  return 2;
case 4:
return 1;
}
break;
case 66:
switch (data) {
case 6:
return 7;
case 7:
return 8;
case 8:
return 9;
case 9:
return 6;
}
case 27:
case 28:
switch (data & 0x7) {
case 0:
return 1 | (data & ~0x7);
case 1:
return (data & ~0x7);
case 2:
return 5 | (data & ~0x7);
case 3:
return 4 | (data & ~0x7);
case 4:
return 2 | (data & ~0x7);
case 5:
return 3 | (data & ~0x7);
}
break;
case 53:
case 67:
case 108:
case 109:
case 114:
int top=data & 0x4;
dir=data & 0x3;
switch (dir) {
case 0:
return 2 | top;
case 1:
return 3 | top;
case 2:
return 1 | top;
case 3:
return top;
}
break;
case 69:
case 77:
int thrown=data & 0x8;
int withoutThrown=data & ~0x8;
switch (withoutThrown) {
case 1:
return 3 | thrown;
case 2:
return 4 | thrown;
case 3:
return 2 | thrown;
case 4:
return 1 | thrown;
}
break;
case 64:
case 71:
int topHalf=data & 0x8;
int swung=data & 0x4;
int withoutFlags=data & ~(0x8 | 0x4);
switch (withoutFlags) {
case 0:
return 1 | topHalf | swung;
case 1:
return 2 | topHalf | swung;
case 2:
return 3 | topHalf | swung;
case 3:
return topHalf | swung;
}
break;
case 63:
return (data + 4) % 16;
case 65:
case 68:
case 54:
case 61:
case 62:
case 23:
switch (data) {
case 2:
return 5;
case 3:
return 4;
case 4:
return 2;
case 5:
return 3;
}
break;
case 86:
case 91:
switch (data) {
case 0:
return 1;
case 1:
return 2;
case 2:
return 3;
case 3:
return 0;
}
break;
case 93:
case 94:
dir=data & 0x03;
int delay=data - dir;
switch (dir) {
case 0:
return 1 | delay;
case 1:
return 2 | delay;
case 2:
return 3 | delay;
case 3:
return delay;
}
break;
case 96:
int withoutOrientation=data & ~0x3;
int orientation=data & 0x3;
switch (orientation) {
case 0:
return 3 | withoutOrientation;
case 1:
return 2 | withoutOrientation;
case 2:
return withoutOrientation;
case 3:
return 1 | withoutOrientation;
}
break;
case 33:
case 29:
case 34:
final int rest=data & ~0x7;
switch (data & 0x7) {
case 2:
return 5 | rest;
case 3:
return 4 | rest;
case 4:
return 2 | rest;
case 5:
return 3 | rest;
}
break;
case 99:
case 100:
if (data >= 10) {
return data;
}
return (data * 3) % 10;
case 106:
return ((data << 1) | (data >> 3)) & 0xf;
case 107:
return ((data + 1) & 0x3) | (data & ~0x3);
}
return data;
}