Program: 5772
Project: 5772
Buggy source:
public void dataReceived(USART source,int data){
  if (chipSelect) {
    if (DEBUG)     System.out.println("String_Node_Str" + Utils.hex8(data) + '\''+ (char)data+ '\''+ "String_Node_Str"+ chipSelect+ "String_Node_Str"+ state);
switch (state) {
case WAITING:
      state=WRITE_REGISTER;
    if ((data & FLAG_READ) != 0) {
      state=READ_REGISTER;
    }
  if ((data & FLAG_RAM) != 0) {
    state=RAM_ACCESS;
    address=data & 0x7f;
  }
 else {
    address=data & 0x3f;
    if (address == REG_RXFIFO) {
      state=READ_RXFIFO;
    }
 else     if (address == REG_TXFIFO) {
      state=WRITE_TXFIFO;
    }
  }
if (data < 0x0f) {
  strobe(data);
}
pos=0;
source.byteReceived(status);
break;
case WRITE_REGISTER:
if (pos == 0) {
source.byteReceived(registers[address] >> 8);
registers[address]=registers[address] & 0xff | (data << 8);
}
 else {
source.byteReceived(registers[address] & 0xff);
registers[address]=registers[address] & 0xff00 | data;
if (DEBUG) System.out.println("String_Node_Str" + Utils.hex8(address) + "String_Node_Str"+ registers[address]);
}
break;
case READ_REGISTER:
if (pos == 0) {
source.byteReceived(registers[address] >> 8);
}
 else {
source.byteReceived(registers[address] & 0xff);
if (DEBUG) System.out.println("String_Node_Str" + Utils.hex8(address) + "String_Node_Str"+ registers[address]);
}
break;
case READ_RXFIFO:
source.byteReceived(memory[RAM_RXFIFO + rxCursor++]);
if (rxCursor >= 128) rxCursor=0;
if (rxPacket) {
rxPacket=false;
updateFifopPin();
}
break;
case WRITE_TXFIFO:
memory[RAM_TXFIFO + txCursor++]=data & 0xff;
break;
case RAM_ACCESS:
if (pos == 0) {
address=address | (data << 1) & 0x180;
ramRead=(data & 0x20) != 0;
if (DEBUG) System.out.println("String_Node_Str" + Utils.hex16(address) + "String_Node_Str"+ ramRead);
pos++;
}
 else {
if (!ramRead) {
memory[address++]=data;
if (DEBUG && address == RAM_PANID + 2) {
System.out.println("String_Node_Str" + Utils.hex8(memory[RAM_PANID]) + Utils.hex8(memory[RAM_PANID + 1]));
}
}
}
break;
}
}
}

Fixed version (ground truth):
public void dataReceived(USART source,int data){
  if (on && chipSelect) {
    if (DEBUG)     System.out.println("String_Node_Str" + Utils.hex8(data) + '\''+ (char)data+ '\''+ "String_Node_Str"+ chipSelect+ "String_Node_Str"+ state);
switch (state) {
case WAITING:
      state=WRITE_REGISTER;
    if ((data & FLAG_READ) != 0) {
      state=READ_REGISTER;
    }
  if ((data & FLAG_RAM) != 0) {
    state=RAM_ACCESS;
    address=data & 0x7f;
  }
 else {
    address=data & 0x3f;
    if (address == REG_RXFIFO) {
      state=READ_RXFIFO;
    }
 else     if (address == REG_TXFIFO) {
      state=WRITE_TXFIFO;
    }
  }
if (data < 0x0f) {
  strobe(data);
}
pos=0;
source.byteReceived(status);
break;
case WRITE_REGISTER:
if (pos == 0) {
source.byteReceived(registers[address] >> 8);
registers[address]=registers[address] & 0xff | (data << 8);
}
 else {
source.byteReceived(registers[address] & 0xff);
registers[address]=registers[address] & 0xff00 | data;
if (DEBUG) System.out.println("String_Node_Str" + Utils.hex8(address) + "String_Node_Str"+ registers[address]);
}
break;
case READ_REGISTER:
if (pos == 0) {
source.byteReceived(registers[address] >> 8);
}
 else {
source.byteReceived(registers[address] & 0xff);
if (DEBUG) System.out.println("String_Node_Str" + Utils.hex8(address) + "String_Node_Str"+ registers[address]);
}
break;
case READ_RXFIFO:
source.byteReceived(memory[RAM_RXFIFO + rxCursor++]);
if (rxCursor >= 128) rxCursor=0;
if (rxPacket) {
rxPacket=false;
updateFifopPin();
}
break;
case WRITE_TXFIFO:
memory[RAM_TXFIFO + txCursor++]=data & 0xff;
break;
case RAM_ACCESS:
if (pos == 0) {
address=address | (data << 1) & 0x180;
ramRead=(data & 0x20) != 0;
if (DEBUG) System.out.println("String_Node_Str" + Utils.hex16(address) + "String_Node_Str"+ ramRead);
pos++;
}
 else {
if (!ramRead) {
memory[address++]=data;
if (DEBUG && address == RAM_PANID + 2) {
System.out.println("String_Node_Str" + Utils.hex8(memory[RAM_PANID]) + Utils.hex8(memory[RAM_PANID + 1]));
}
}
}
break;
}
}
}