nus-yam/ex-repair huggingface dataset:
Program: 5677
Project: 5677
Buggy source:
private void txNext(){
  if (txfifoPos <= memory[RAM_TXFIFO]) {
    if (listener != null) {
      if (DEBUG)       log("String_Node_Str" + Utils.hex8(memory[RAM_TXFIFO + txfifoPos] & 0xFF));
      listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos] & 0xFF));
    }
    txfifoPos++;
    long time=cpu.scheduleTimeEventMillis(sendEvent,SYMBOL_PERIOD * 2);
  }
 else {
    if (DEBUG)     log("String_Node_Str");
    status&=~STATUS_TX_ACTIVE;
    setSFD(false);
    if (overflow) {
      setState(RadioState.RX_OVERFLOW);
    }
 else {
      setState(RadioState.RX_CALIBRATE);
    }
    setMode(MODE_RX_ON);
    txfifoFlush=true;
  }
}

Fixed version (ground truth):
private void txNext(){
  if (txfifoPos <= memory[RAM_TXFIFO]) {
    if (txfifoPos > 0x7f) {
      log("String_Node_Str" + txfifoPos);
    }
    if (listener != null) {
      if (DEBUG)       log("String_Node_Str" + Utils.hex8(memory[RAM_TXFIFO + (txfifoPos & 0x7f)] & 0xFF));
      listener.receivedByte((byte)(memory[RAM_TXFIFO + (txfifoPos & 0x7f)] & 0xFF));
    }
    txfifoPos++;
    long time=cpu.scheduleTimeEventMillis(sendEvent,SYMBOL_PERIOD * 2);
  }
 else {
    if (DEBUG)     log("String_Node_Str");
    status&=~STATUS_TX_ACTIVE;
    setSFD(false);
    if (overflow) {
      setState(RadioState.RX_OVERFLOW);
    }
 else {
      setState(RadioState.RX_CALIBRATE);
    }
    setMode(MODE_RX_ON);
    txfifoFlush=true;
  }
}
Program: 5678
Project: 5678
Buggy source:
@Override public void interruptServiced(int vector){
  cpu.flagInterrupt(RESET_VECTOR,this,false);
}

Fixed version (ground truth):
public void interruptServiced(int vector){
  cpu.flagInterrupt(RESET_VECTOR,this,false);
}
Program: 5679
Project: 5679
Buggy source:
@Override public String getName(){
  return "String_Node_Str";
}

Fixed version (ground truth):
public String getName(){
  return "String_Node_Str";
}
Program: 5680
Project: 5680
Buggy source:
public void interruptServiced(int vector){
  if (vector == ccr0Vector) {
    core.flagInterrupt(ccr0Vector,this,false);
    tcctl[0]&=~CC_IFG;
    System.out.println(getName() + "String_Node_Str");
  }
  if (MSP430Core.debugInterrupts || true) {
    System.out.println(getName() + "String_Node_Str" + lastTIV+ "String_Node_Str"+ core.cycles+ "String_Node_Str"+ (core.cycles - triggerTime));
  }
}

Fixed version (ground truth):
public void interruptServiced(int vector){
  if (vector == ccr0Vector) {
    core.flagInterrupt(ccr0Vector,this,false);
    tcctl[0]&=~CC_IFG;
    System.out.println(getName() + "String_Node_Str");
  }
  if (MSP430Core.debugInterrupts || true) {
    System.out.println(getName() + "String_Node_Str" + lastTIV+ "String_Node_Str"+ core.cycles+ "String_Node_Str"+ (core.cycles - triggerTime));
  }
  triggerInterrupts(core.cycles);
}
Program: 5682
Project: 5682
Buggy source:
public void execute(long t){
  updateTimers(t);
}

Fixed version (ground truth):
public void execute(long t){
  updateTimers(core.cycles);
}
Program: 5683
Project: 5683
Buggy source:
private void resetTIV(long cycles){
  if (lastTIV == timerOverflow) {
    interruptPending=false;
    lastTIV=0;
    if (DEBUG) {
      System.out.println(getName() + "String_Node_Str");
    }
    triggerInterrupts(cycles);
  }
  if (lastTIV / 2 < noCompare) {
    if (DEBUG) {
      System.out.println(getName() + "String_Node_Str" + lastTIV);
    }
    tcctl[lastTIV / 2]&=~CC_IFG;
    triggerInterrupts(cycles);
  }
}

Fixed version (ground truth):
private void resetTIV(long cycles){
  if (lastTIV == timerOverflow) {
    interruptPending=false;
    lastTIV=0;
    if (DEBUG) {
      System.out.println(getName() + "String_Node_Str");
    }
    triggerInterrupts(cycles);
  }
  if (lastTIV / 2 < noCompare) {
    if (DEBUG || true) {
      System.out.println(getName() + "String_Node_Str" + (lastTIV / 2));
    }
    tcctl[lastTIV / 2]&=~CC_IFG;
    triggerInterrupts(cycles);
  }
}
Program: 5684
Project: 5684
Buggy source:
private void recalculateCompares(long cycles){
  for (int i=0; i < expCaptureTime.length; i++) {
    if (expCaptureTime[i] != 0) {
      int diff=tccr[i] - counter;
      if (diff < 0) {
        diff+=0x10000;
      }
      expCaptureTime[i]=cycles + (long)(diff * cyclesMultiplicator);
      if (i == 0) {
        System.out.println("String_Node_Str" + expCaptureTime[0] + "String_Node_Str"+ cycles);
      }
    }
  }
}

Fixed version (ground truth):
private void recalculateCompares(long cycles){
  System.out.println("String_Node_Str");
  for (int i=0; i < expCaptureTime.length; i++) {
    if (expCaptureTime[i] != 0) {
      int diff=tccr[i] - counter;
      if (diff < 0) {
        diff+=0x10000;
      }
      expCaptureTime[i]=cycles + (long)(diff * cyclesMultiplicator);
      if (i == 0) {
        System.out.println("String_Node_Str" + expCaptureTime[0] + "String_Node_Str"+ cycles);
      }
    }
  }
}
Program: 5685
Project: 5685
Buggy source:
private void updateTimers(long cycles){
  if (mode == STOP) {
    if (DEBUG) {
      System.out.println("String_Node_Str");
    }
    return;
  }
  updateCounter(cycles);
  if (cycles >= nextTimerTrigger) {
    interruptPending=true;
    nextTimerTrigger=(long)(nextTimerTrigger + 0x10000 * cyclesMultiplicator);
  }
  for (int i=0, n=noCompare; i < n; i++) {
    if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) {
      if (DEBUG || i < 2) {
        System.out.println(getName() + (captureOn[i] ? "String_Node_Str" : "String_Node_Str") + i+ "String_Node_Str"+ cycles+ "String_Node_Str"+ expCaptureTime[i]+ "String_Node_Str"+ Utils.hex16(expCompare[i])+ "String_Node_Str"+ Utils.hex16(updateCounter(cycles)));
      }
      tcctl[i]|=CC_IFG;
      if (captureOn[i]) {
        tccr[i]=expCompare[i];
        expCompare[i]=(expCompare[i] + expCapInterval[i]) & 0xffff;
        expCaptureTime[i]+=expCapInterval[i] * cyclesMultiplicator;
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + expCaptureTime[i]);
        }
      }
 else {
        expCaptureTime[i]=expCaptureTime[i] + (long)(0x10000 * cyclesMultiplicator);
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + expCaptureTime[i]);
        }
      }
      if (DEBUG) {
        System.out.println("String_Node_Str" + Utils.hex16(offset + TCCTL0 + i * 2 + 1));
      }
    }
  }
  triggerInterrupts(cycles);
  calculateNextEventTime(cycles);
}

Fixed version (ground truth):
private void updateTimers(long cycles){
  if (mode == STOP) {
    if (DEBUG) {
      System.out.println("String_Node_Str");
    }
    return;
  }
  updateCounter(cycles);
  if (cycles >= nextTimerTrigger) {
    interruptPending=true;
    nextTimerTrigger=(long)(nextTimerTrigger + 0x10000 * cyclesMultiplicator);
  }
  for (int i=0, n=noCompare; i < n; i++) {
    if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) {
      if (DEBUG || true) {
        System.out.println(getName() + (captureOn[i] ? "String_Node_Str" : "String_Node_Str") + i+ "String_Node_Str"+ cycles+ "String_Node_Str"+ expCaptureTime[i]+ "String_Node_Str"+ Utils.hex16(expCompare[i])+ "String_Node_Str"+ counter+ "String_Node_Str"+ i+ "String_Node_Str"+ tccr[i]);
      }
      tcctl[i]|=CC_IFG;
      if (captureOn[i]) {
        tccr[i]=expCompare[i];
        expCompare[i]=(expCompare[i] + expCapInterval[i]) & 0xffff;
        expCaptureTime[i]+=expCapInterval[i] * cyclesMultiplicator;
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + expCaptureTime[i]);
        }
      }
 else {
        expCaptureTime[i]=expCaptureTime[i] + (long)(0x10000 * cyclesMultiplicator);
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + expCaptureTime[i]);
        }
      }
      if (DEBUG) {
        System.out.println("String_Node_Str" + Utils.hex16(offset + TCCTL0 + i * 2 + 1));
      }
    }
  }
  triggerInterrupts(cycles);
  calculateNextEventTime(cycles);
}
Program: 5687
Project: 5687
Buggy source:
public void setVRegOn(boolean on){
  if (this.on == on)   return;
  if (on) {
    cpu.scheduleTimeEventMillis(vregEvent,0.1);
    if (DEBUG)     log(getName() + "String_Node_Str" + cpu.cycles+ "String_Node_Str"+ vregEvent.getTime()+ "String_Node_Str"+ cpu.getTime());
  }
 else {
    this.on=on;
    setState(RadioState.VREG_OFF);
  }
}

Fixed version (ground truth):
public void setVRegOn(boolean newOn){
  if (on == newOn)   return;
  if (newOn) {
    cpu.scheduleTimeEventMillis(vregEvent,0.1);
    if (DEBUG)     log(getName() + "String_Node_Str" + cpu.cycles+ "String_Node_Str"+ vregEvent.getTime()+ "String_Node_Str"+ cpu.getTime());
  }
 else {
    on=false;
    setState(RadioState.VREG_OFF);
  }
}
Program: 5688
Project: 5688
Buggy source:
private void flushRX(){
  if (DEBUG) {
    log("String_Node_Str" + rxfifoLen);
  }
  rxfifoReadPos=0;
  rxfifoWritePos=0;
  rxfifoLen=0;
  setSFD(false);
  setFIFOP(false);
  setFIFO(false);
  overflow=false;
  setState(RadioState.RX_SFD_SEARCH);
}

Fixed version (ground truth):
private void flushRX(){
  if (DEBUG) {
    log("String_Node_Str" + rxfifoLen);
  }
  rxfifoReadPos=0;
  rxfifoWritePos=0;
  rxfifoLen=0;
  setSFD(false);
  setFIFOP(false);
  setFIFO(false);
  overflow=false;
  if ((stateMachine == RadioState.RX_CALIBRATE) || (stateMachine == RadioState.RX_SFD_SEARCH) || (stateMachine == RadioState.RX_FRAME)|| (stateMachine == RadioState.RX_OVERFLOW)|| (stateMachine == RadioState.RX_WAIT)) {
    setState(RadioState.RX_SFD_SEARCH);
  }
}
Program: 5689
Project: 5689
Buggy source:
public void receivedByte(byte data){
  log("String_Node_Str" + Utils.hex8(data) + "String_Node_Str"+ stateMachine+ "String_Node_Str"+ zeroSymbols);
  if (stateMachine == RadioState.RX_SFD_SEARCH) {
    if (data == 0) {
      if (zeroSymbols < 4)       zeroSymbols++;
      return;
    }
 else     if (zeroSymbols == 4 && data == 0x7A) {
      setSFD(true);
      if (DEBUG)       log("String_Node_Str");
      rxread=0;
      setState(RadioState.RX_FRAME);
    }
 else {
      zeroSymbols=0;
    }
  }
 else   if (stateMachine == RadioState.RX_FRAME) {
    if (rxfifoLen == 128) {
      setRxOverflow();
    }
 else {
      memory[RAM_RXFIFO + rxfifoWritePos++]=data & 0xFF;
      rxfifoLen++;
      if (rxfifoWritePos == 128) {
        if (DEBUG)         log("String_Node_Str");
        rxfifoWritePos=0;
      }
      if (rxread == 0) {
        rxlen=data & 0xff;
        if (DEBUG)         log("String_Node_Str" + rxlen);
        setFIFO(true);
      }
      if (rxread++ == rxlen) {
        memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)]=(registers[REG_RSSI]) & 0xff;
        memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)]=37 | 0x80;
        setFIFOP(true);
        setSFD(false);
        lastPacketStart=(rxfifoWritePos + 128 - rxlen) & 127;
        if (DEBUG)         log("String_Node_Str" + lastPacketStart);
        setState(RadioState.RX_WAIT);
      }
    }
  }
 else   if (DEBUG) {
    log("String_Node_Str" + stateMachine);
  }
}

Fixed version (ground truth):
public void receivedByte(byte data){
  log("String_Node_Str" + Utils.hex8(data) + "String_Node_Str"+ stateMachine+ "String_Node_Str"+ zeroSymbols+ ((stateMachine == RadioState.RX_SFD_SEARCH || stateMachine == RadioState.RX_FRAME) ? "String_Node_Str" : "String_Node_Str"));
  if (stateMachine == RadioState.RX_SFD_SEARCH) {
    if (data == 0) {
      if (zeroSymbols < 4)       zeroSymbols++;
      return;
    }
 else     if (zeroSymbols == 4 && data == 0x7A) {
      setSFD(true);
      if (DEBUG)       log("String_Node_Str");
      rxread=0;
      setState(RadioState.RX_FRAME);
    }
 else {
      zeroSymbols=0;
    }
  }
 else   if (stateMachine == RadioState.RX_FRAME) {
    if (rxfifoLen == 128) {
      setRxOverflow();
    }
 else {
      memory[RAM_RXFIFO + rxfifoWritePos++]=data & 0xFF;
      rxfifoLen++;
      if (rxfifoWritePos == 128) {
        if (DEBUG)         log("String_Node_Str");
        rxfifoWritePos=0;
      }
      if (rxread == 0) {
        rxlen=data & 0xff;
        if (DEBUG)         log("String_Node_Str" + rxlen);
        setFIFO(true);
      }
      if (rxread++ == rxlen) {
        memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)]=(registers[REG_RSSI]) & 0xff;
        memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)]=37 | 0x80;
        setFIFOP(true);
        setSFD(false);
        lastPacketStart=(rxfifoWritePos + 128 - rxlen) & 127;
        if (DEBUG)         log("String_Node_Str" + lastPacketStart);
        setState(RadioState.RX_WAIT);
      }
    }
  }
}
Program: 5690
Project: 5690
Buggy source:
private boolean setState(RadioState state){
  stateMachine=state;
switch (stateMachine) {
case VREG_OFF:
    if (DEBUG)     log("String_Node_Str");
  flushRX();
flushTX();
status&=~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE);
setMode(MODE_POWER_OFF);
updateCCA();
break;
case POWER_DOWN:
rxfifoReadPos=0;
rxfifoWritePos=0;
status&=~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE);
setMode(MODE_POWER_OFF);
updateCCA();
break;
case RX_CALIBRATE:
setSymbolEvent(12);
setMode(MODE_RX_ON);
break;
case RX_SFD_SEARCH:
zeroSymbols=0;
status|=STATUS_RSSI_VALID;
updateCCA();
break;
case TX_CALIBRATE:
setSymbolEvent(12 + 2);
setMode(MODE_TXRX_ON);
break;
case TX_PREAMBLE:
shrPos=0;
SHR[0]=0;
SHR[1]=0;
SHR[2]=0;
SHR[3]=0;
SHR[4]=0x7A;
shrNext();
break;
case TX_FRAME:
txfifoPos=0;
txNext();
break;
case RX_WAIT:
setSymbolEvent(8);
break;
case IDLE:
status&=~STATUS_RSSI_VALID;
setMode(MODE_TXRX_OFF);
updateCCA();
break;
}
return true;
}

Fixed version (ground truth):
private boolean setState(RadioState state){
  if (DEBUG)   log("String_Node_Str" + stateMachine + "String_Node_Str"+ state);
  stateMachine=state;
switch (stateMachine) {
case VREG_OFF:
    if (DEBUG)     log("String_Node_Str");
  flushRX();
flushTX();
status&=~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE);
setMode(MODE_POWER_OFF);
updateCCA();
break;
case POWER_DOWN:
rxfifoReadPos=0;
rxfifoWritePos=0;
status&=~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE);
setMode(MODE_POWER_OFF);
updateCCA();
break;
case RX_CALIBRATE:
setSymbolEvent(12);
setMode(MODE_RX_ON);
break;
case RX_SFD_SEARCH:
zeroSymbols=0;
status|=STATUS_RSSI_VALID;
updateCCA();
break;
case TX_CALIBRATE:
setSymbolEvent(12 + 2);
setMode(MODE_TXRX_ON);
break;
case TX_PREAMBLE:
shrPos=0;
SHR[0]=0;
SHR[1]=0;
SHR[2]=0;
SHR[3]=0;
SHR[4]=0x7A;
shrNext();
break;
case TX_FRAME:
txfifoPos=0;
txNext();
break;
case RX_WAIT:
setSymbolEvent(8);
break;
case IDLE:
status&=~STATUS_RSSI_VALID;
setMode(MODE_TXRX_OFF);
updateCCA();
break;
}
return true;
}
Program: 5692
Project: 5692
Buggy source:
private void shrNext(){
  if (shr_pos == 5) {
    setSFD(true);
    setState(STATE_TX_FRAME);
  }
 else {
    listener.receivedByte(SHR[shr_pos++]);
    cpu.scheduleTimeEventMillis(shrEvent,SYMBOL_PERIOD * 2);
  }
}

Fixed version (ground truth):
private void shrNext(){
  if (shrPos == 5) {
    setSFD(true);
    setState(STATE_TX_FRAME);
  }
 else {
    listener.receivedByte(SHR[shrPos++]);
    cpu.scheduleTimeEventMillis(shrEvent,SYMBOL_PERIOD * 2);
  }
}
Program: 5693
Project: 5693
Buggy source:
public void setFIFOP(boolean fifop){
  if ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) {
    fifopPort.setPinState(fifopPin,fifop ? 0 : 1);
  }
 else {
    fifopPort.setPinState(fifopPin,fifop ? 1 : 0);
  }
}

Fixed version (ground truth):
private void setFIFOP(boolean fifop){
  if ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) {
    fifopPort.setPinState(fifopPin,fifop ? 0 : 1);
  }
 else {
    fifopPort.setPinState(fifopPin,fifop ? 1 : 0);
  }
}
Program: 5695
Project: 5695
Buggy source:
public String chipinfo(){
  return "String_Node_Str" + on + "String_Node_Str"+ ((status & STATUS_XOSC16M_STABLE) > 0)+ "String_Node_Str"+ ((status & STATUS_RSSI_VALID) > 0)+ "String_Node_Str";
}

Fixed version (ground truth):
public String chipinfo(){
  return "String_Node_Str" + on + "String_Node_Str"+ ((status & STATUS_XOSC16M_STABLE) > 0)+ "String_Node_Str"+ ((status & STATUS_RSSI_VALID) > 0)+ "String_Node_Str"+ cca+ "String_Node_Str";
}
Program: 5696
Project: 5696
Buggy source:
private void txNext(){
  if (txfifo_pos <= memory[RAM_TXFIFO]) {
    listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifo_pos++] & 0xFF));
    long time=cpu.scheduleTimeEventMillis(sendEvent,SYMBOL_PERIOD * 2);
  }
 else {
    if (DEBUG)     System.out.println("String_Node_Str");
    status&=~STATUS_TX_ACTIVE;
    setSFD(false);
    setState(STATE_RX_CALIBRATE);
    setMode(MODE_RX_ON);
    txfifo_flush=true;
  }
}

Fixed version (ground truth):
private void txNext(){
  if (txfifoPos <= memory[RAM_TXFIFO]) {
    listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos++] & 0xFF));
    long time=cpu.scheduleTimeEventMillis(sendEvent,SYMBOL_PERIOD * 2);
  }
 else {
    if (DEBUG)     System.out.println("String_Node_Str");
    status&=~STATUS_TX_ACTIVE;
    setSFD(false);
    setState(STATE_RX_CALIBRATE);
    setMode(MODE_RX_ON);
    txfifoFlush=true;
  }
}
Program: 5697
Project: 5697
Buggy source:
private void flushRX(){
  if (DEBUG) {
    System.out.println("String_Node_Str" + rxfifo_len);
  }
  rxPacket=false;
  rxfifo_read_pos=0;
  rxfifo_write_pos=0;
  rxfifo_len=0;
  setClear(true);
  setSFD(false);
  setFIFOP(false);
}

Fixed version (ground truth):
private void flushRX(){
  if (DEBUG) {
    System.out.println("String_Node_Str" + rxfifoLen);
  }
  rxPacket=false;
  rxfifoReadPos=0;
  rxfifoWritePos=0;
  rxfifoLen=0;
  setCCA(true);
  setSFD(false);
  setFIFOP(false);
}
Program: 5698
Project: 5698
Buggy source:
public void setFIFO(boolean fifo){
  fifoPort.setPinState(fifoPin,fifo ? 1 : 0);
}

Fixed version (ground truth):
private void setFIFO(boolean fifo){
  fifoPort.setPinState(fifoPin,fifo ? 1 : 0);
}
Program: 5699
Project: 5699
Buggy source:
public void execute(long t){
switch (stateMachine) {
case STATE_RX_CALIBRATE:
    setClear(true);
  setState(STATE_RX_SFD_SEARCH);
break;
case STATE_TX_CALIBRATE:
setState(STATE_TX_PREAMBLE);
break;
case STATE_RX_WAIT:
setClear(true);
setState(STATE_RX_SFD_SEARCH);
break;
}
}

Fixed version (ground truth):
public void execute(long t){
switch (stateMachine) {
case STATE_RX_CALIBRATE:
    setCCA(true);
  setState(STATE_RX_SFD_SEARCH);
break;
case STATE_TX_CALIBRATE:
setState(STATE_TX_PREAMBLE);
break;
case STATE_RX_WAIT:
setCCA(true);
setState(STATE_RX_SFD_SEARCH);
break;
}
}
Program: 5700
Project: 5700
Buggy source:
public void setSFD(boolean sfd){
  if (DEBUG)   System.out.println("String_Node_Str" + sfd);
  sfdPort.setPinState(sfdPin,sfd ? 1 : 0);
}

Fixed version (ground truth):
private void setSFD(boolean sfd){
  if (DEBUG)   System.out.println("String_Node_Str" + sfd);
  sfdPort.setPinState(sfdPin,sfd ? 1 : 0);
}
Program: 5701
Project: 5701
Buggy source:
public void setRxOverflow(){
  if (DEBUG)   System.out.println("String_Node_Str" + rxfifo_read_pos + "String_Node_Str"+ rxfifo_write_pos);
  setFIFOP(true);
  setFIFO(false);
}

Fixed version (ground truth):
public void setRxOverflow(){
  if (DEBUG)   System.out.println("String_Node_Str" + rxfifoReadPos + "String_Node_Str"+ rxfifoWritePos);
  setFIFOP(true);
  setFIFO(false);
}
Program: 5702
Project: 5702
Buggy source:
public void receivedByte(byte data){
  if (cca)   setClear(false);
  if (stateMachine == STATE_RX_SFD_SEARCH) {
    if (data == 0) {
      zero_symbols++;
      return;
    }
    if (zero_symbols == 4) {
      if (data == 0x7A) {
        setSFD(true);
        if (DEBUG)         System.out.println("String_Node_Str");
        rxread=0;
        setState(STATE_RX_FRAME);
      }
 else {
        zero_symbols=0;
      }
    }
  }
 else   if (stateMachine == STATE_RX_FRAME) {
    if (rxfifo_len == 128) {
      setRxOverflow();
    }
 else {
      memory[RAM_RXFIFO + rxfifo_write_pos++]=data & 0xFF;
      rxfifo_len++;
      if (rxfifo_write_pos == 128) {
        if (DEBUG)         System.out.println("String_Node_Str");
        rxfifo_write_pos=0;
      }
      if (rxread == 0) {
        rxlen=(int)data;
        if (DEBUG)         System.out.println("String_Node_Str" + rxlen);
        setFIFO(true);
      }
      if (rxread++ == rxlen) {
        memory[RAM_RXFIFO + (rxfifo_write_pos - 2)]=(registers[REG_RSSI]) & 0xff;
        memory[RAM_RXFIFO + (rxfifo_write_pos - 1)]=37 | 0x80;
        setFIFOP(true);
        setSFD(false);
        if (DEBUG)         System.out.println("String_Node_Str");
        setState(STATE_RX_WAIT);
      }
    }
  }
}

Fixed version (ground truth):
public void receivedByte(byte data){
  if (cca)   setCCA(false);
  if (stateMachine == STATE_RX_SFD_SEARCH) {
    if (data == 0) {
      zero_symbols++;
      return;
    }
    if (zero_symbols == 4) {
      if (data == 0x7A) {
        setSFD(true);
        if (DEBUG)         System.out.println("String_Node_Str");
        rxread=0;
        setState(STATE_RX_FRAME);
      }
 else {
        zero_symbols=0;
      }
    }
  }
 else   if (stateMachine == STATE_RX_FRAME) {
    if (rxfifoLen == 128) {
      setRxOverflow();
    }
 else {
      memory[RAM_RXFIFO + rxfifoWritePos++]=data & 0xFF;
      rxfifoLen++;
      if (rxfifoWritePos == 128) {
        if (DEBUG)         System.out.println("String_Node_Str");
        rxfifoWritePos=0;
      }
      if (rxread == 0) {
        rxlen=(int)data;
        if (DEBUG)         System.out.println("String_Node_Str" + rxlen);
        setFIFO(true);
      }
      if (rxread++ == rxlen) {
        memory[RAM_RXFIFO + (rxfifoWritePos - 2)]=(registers[REG_RSSI]) & 0xff;
        memory[RAM_RXFIFO + (rxfifoWritePos - 1)]=37 | 0x80;
        setFIFOP(true);
        setSFD(false);
        if (DEBUG)         System.out.println("String_Node_Str");
        setState(STATE_RX_WAIT);
      }
    }
  }
}
Program: 5703
Project: 5703
Buggy source:
private boolean setState(int state){
  stateMachine=state;
switch (stateMachine) {
case STATE_VREG_OFF:
    if (DEBUG)     System.out.println("String_Node_Str");
  break;
case STATE_POWER_DOWN:
rxfifo_read_pos=0;
rxfifo_write_pos=0;
break;
case STATE_RX_CALIBRATE:
setSymbolEvent(12);
break;
case STATE_RX_SFD_SEARCH:
zero_symbols=0;
status|=STATUS_RSSI_VALID;
break;
case STATE_TX_CALIBRATE:
setSymbolEvent(12 + 2);
break;
case STATE_TX_PREAMBLE:
shr_pos=0;
SHR[0]=0;
SHR[1]=0;
SHR[2]=0;
SHR[3]=0;
SHR[4]=0x7A;
shrNext();
break;
case STATE_TX_FRAME:
txfifo_pos=0;
txNext();
break;
case STATE_RX_WAIT:
setSymbolEvent(8);
break;
case STATE_IDLE:
status&=~STATUS_RSSI_VALID;
break;
}
return true;
}

Fixed version (ground truth):
private boolean setState(int state){
  stateMachine=state;
switch (stateMachine) {
case STATE_VREG_OFF:
    if (DEBUG)     System.out.println("String_Node_Str");
  break;
case STATE_POWER_DOWN:
rxfifoReadPos=0;
rxfifoWritePos=0;
break;
case STATE_RX_CALIBRATE:
setSymbolEvent(12);
break;
case STATE_RX_SFD_SEARCH:
zero_symbols=0;
status|=STATUS_RSSI_VALID;
break;
case STATE_TX_CALIBRATE:
setSymbolEvent(12 + 2);
break;
case STATE_TX_PREAMBLE:
shrPos=0;
SHR[0]=0;
SHR[1]=0;
SHR[2]=0;
SHR[3]=0;
SHR[4]=0x7A;
shrNext();
break;
case STATE_TX_FRAME:
txfifoPos=0;
txNext();
break;
case STATE_RX_WAIT:
setSymbolEvent(8);
break;
case STATE_IDLE:
status&=~STATUS_RSSI_VALID;
break;
}
return true;
}
Program: 5704
Project: 5704
Buggy source:
public CC2420(MSP430Core cpu){
  registers[REG_SNOP]=0;
  registers[REG_TXCTRL]=0xa0ff;
  this.cpu=cpu;
  setModeNames(MODE_NAMES);
  setMode(MODE_POWER_OFF);
  rxPacket=false;
  rxfifo_read_pos=0;
  rxfifo_write_pos=0;
  cca=false;
}

Fixed version (ground truth):
public CC2420(MSP430Core cpu){
  registers[REG_SNOP]=0;
  registers[REG_TXCTRL]=0xa0ff;
  this.cpu=cpu;
  setModeNames(MODE_NAMES);
  setMode(MODE_POWER_OFF);
  rxPacket=false;
  rxfifoReadPos=0;
  rxfifoWritePos=0;
}
Program: 5705
Project: 5705
Buggy source:
public void setCCA(boolean cca){
  if ((registers[REG_IOCFG0] & CCA_POLARITY) == CCA_POLARITY)   ccaPort.setPinState(ccaPin,cca ? 0 : 1);
 else   ccaPort.setPinState(ccaPin,cca ? 1 : 0);
}

Fixed version (ground truth):
public void setCCA(boolean clear){
  cca=clear;
  setCCAPin(clear);
  if (DEBUG)   System.out.println("String_Node_Str" + clear);
}
Program: 5706
Project: 5706
Buggy source:
private void shrNext(){
  if (shrPos == 5) {
    setSFD(true);
    setState(STATE_TX_FRAME);
  }
 else {
    if (listener != null) {
      listener.receivedByte(SHR[shrPos++]);
    }
    cpu.scheduleTimeEventMillis(shrEvent,SYMBOL_PERIOD * 2);
  }
}

Fixed version (ground truth):
private void shrNext(){
  if (shrPos == 5) {
    setSFD(true);
    setState(STATE_TX_FRAME);
  }
 else {
    if (listener != null) {
      listener.receivedByte(SHR[shrPos]);
    }
    shrPos++;
    cpu.scheduleTimeEventMillis(shrEvent,SYMBOL_PERIOD * 2);
  }
}
Program: 5707
Project: 5707
Buggy source:
private void txNext(){
  if (txfifoPos <= memory[RAM_TXFIFO]) {
    if (listener != null) {
      listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos++] & 0xFF));
    }
    long time=cpu.scheduleTimeEventMillis(sendEvent,SYMBOL_PERIOD * 2);
  }
 else {
    if (DEBUG)     System.out.println("String_Node_Str");
    status&=~STATUS_TX_ACTIVE;
    setSFD(false);
    setState(STATE_RX_CALIBRATE);
    setMode(MODE_RX_ON);
    txfifoFlush=true;
  }
}

Fixed version (ground truth):
private void txNext(){
  if (txfifoPos <= memory[RAM_TXFIFO]) {
    if (listener != null) {
      listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos] & 0xFF));
    }
    txfifoPos++;
    long time=cpu.scheduleTimeEventMillis(sendEvent,SYMBOL_PERIOD * 2);
  }
 else {
    if (DEBUG)     System.out.println("String_Node_Str");
    status&=~STATUS_TX_ACTIVE;
    setSFD(false);
    setState(STATE_RX_CALIBRATE);
    setMode(MODE_RX_ON);
    txfifoFlush=true;
  }
}
Program: 5708
Project: 5708
Buggy source:
public void dataReceived(USART source,int data){
  radio.dataReceived(source,data);
  flash.dataReceived(source,data);
  if (!radio.getChipSelect() && !flash.getChipSelect()) {
    source.byteReceived(0);
  }
}

Fixed version (ground truth):
public void dataReceived(USART source,int data){
  radio.dataReceived(source,data);
  flash.dataReceived(source,data);
  if (!radio.getChipSelect() && !flash.getChipSelect()) {
  }
}
Program: 5711
Project: 5711
Buggy source:
public String chipinfo(){
  return "String_Node_Str" + on + "String_Node_Str"+ ((status & STATUS_XOSC16M_STABLE) > 0)+ "String_Node_Str"+ ((status & STATUS_RSSI_VALID) > 0)+ "String_Node_Str"+ cca+ "String_Node_Str";
}

Fixed version (ground truth):
public String chipinfo(){
  return "String_Node_Str" + on + "String_Node_Str"+ ((status & STATUS_XOSC16M_STABLE) > 0)+ "String_Node_Str"+ ((status & STATUS_RSSI_VALID) > 0)+ "String_Node_Str"+ cca+ "String_Node_Str"+ ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY)+ "String_Node_Str";
}
Program: 5713
Project: 5713
Buggy source:
private boolean checkInit(char c){
  if (INIT_COMMAND[initPos] == c) {
    initPos++;
    if (initPos == INIT_COMMAND.length) {
      initPos=0;
      System.out.println("String_Node_Str");
      return true;
    }
  }
 else {
    initPos=0;
  }
  return false;
}

Fixed version (ground truth):
private boolean checkInit(char c){
  if (INIT_COMMAND[initPos] == c) {
    initPos++;
    if (initPos == INIT_COMMAND.length) {
      initPos=0;
      System.out.println("String_Node_Str");
      return true;
    }
  }
 else {
    initPos=0;
    if (c == INIT_COMMAND[0]) {
      initPos=1;
    }
  }
  return false;
}
Program: 5714
Project: 5714
Buggy source:
public void write(int address,int data,boolean word,long cycles){
  memory[address]=data & 0xff;
  if (word) {
    memory[address + 1]=(data >> 8) & 0xff;
  }
  int iAddress=address - offset;
  if (DEBUG) {
    try {
      System.out.println("String_Node_Str" + getName() + "String_Node_Str"+ (interrupt > 0 ? iNames[iAddress] : names[iAddress])+ "String_Node_Str"+ Utils.hex8(address)+ "String_Node_Str"+ Utils.hex8(data)+ "String_Node_Str"+ Utils.binary8(data)+ "String_Node_Str"+ word);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
switch (iAddress) {
case IN:
    break;
case OUT:
  if (listener != null) {
    listener.portWrite(this,data | (~dirReg) & 0xff);
  }
break;
case DIR:
dirReg=data;
break;
case SEL:
if (interrupt > 0) {
if (DEBUG) {
System.out.println(getName() + "String_Node_Str" + data);
}
interruptFlag&=data;
memory[offset + IFG]=interruptFlag;
cpu.flagInterrupt(interrupt,this,(interruptFlag & interruptEnable) > 0);
}
 else {
}
break;
case IES:
break;
case IE:
interruptEnable=data;
break;
case ISEL:
}
}

Fixed version (ground truth):
public void write(int address,int data,boolean word,long cycles){
  memory[address]=data & 0xff;
  if (word) {
    memory[address + 1]=(data >> 8) & 0xff;
  }
  int iAddress=address - offset;
  if (DEBUG) {
    try {
      System.out.println("String_Node_Str" + getName() + "String_Node_Str"+ (interrupt > 0 ? iNames[iAddress] : names[iAddress])+ "String_Node_Str"+ Utils.hex8(address)+ "String_Node_Str"+ Utils.hex8(data)+ "String_Node_Str"+ Utils.binary8(data)+ "String_Node_Str"+ word);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
switch (iAddress) {
case IN:
    break;
case OUT:
  out=data;
if (listener != null) {
  listener.portWrite(this,out | (~dirReg) & 0xff);
}
break;
case DIR:
dirReg=data;
if (listener != null) {
listener.portWrite(this,out | (~dirReg) & 0xff);
}
break;
case SEL:
if (interrupt > 0) {
if (DEBUG) {
System.out.println(getName() + "String_Node_Str" + data);
}
interruptFlag&=data;
memory[offset + IFG]=interruptFlag;
cpu.flagInterrupt(interrupt,this,(interruptFlag & interruptEnable) > 0);
}
 else {
}
break;
case IES:
break;
case IE:
interruptEnable=data;
break;
case ISEL:
}
}
Program: 5715
Project: 5715
Buggy source:
public void setFIFOP(boolean fifop){
  fifopState=fifop;
  if ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) {
    fifopPort.setPinState(fifopPin,fifop ? 0 : 1);
  }
 else {
    fifopPort.setPinState(fifopPin,fifop ? 1 : 0);
  }
}

Fixed version (ground truth):
public void setFIFOP(boolean fifop){
  if ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) {
    fifopPort.setPinState(fifopPin,fifop ? 0 : 1);
  }
 else {
    fifopPort.setPinState(fifopPin,fifop ? 1 : 0);
  }
}
Program: 5716
Project: 5716
Buggy source:
public void setVRegOn(boolean on){
  if (this.on == on)   return;
  if (on) {
    cpu.scheduleTimeEventMillis(vregEvent,0.1);
  }
 else {
    this.on=on;
    setState(STATE_VREG_OFF);
  }
}

Fixed version (ground truth):
public void setVRegOn(boolean on){
  if (this.on == on)   return;
  if (on) {
    cpu.scheduleTimeEventMillis(vregEvent,0.1);
    System.out.println(getName() + "String_Node_Str" + cpu.cycles+ "String_Node_Str"+ vregEvent.getTime()+ "String_Node_Str"+ cpu.getTime());
  }
 else {
    this.on=on;
    setState(STATE_VREG_OFF);
  }
}
Program: 5717
Project: 5717
Buggy source:
public void write(int address,int value,boolean word,long cycles){
switch (address) {
case ADC12CTL0:
    adc12ctl0=value;
  shTime0=SHTBITS[(value >> 8) & 0x0f];
shTime1=SHTBITS[(value >> 12) & 0x0f];
adc12On=(value & 0x10) > 0;
enableConversion=(value & 0x02) > 0;
startConversion=(value & 0x01) > 0;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + shTime0+ "String_Node_Str"+ shTime1+ "String_Node_Str"+ enableConversion+ "String_Node_Str"+ startConversion+ "String_Node_Str"+ adc12On);
if (adc12On && enableConversion && startConversion) {
convert();
}
break;
case ADC12CTL1:
adc12ctl1=value;
startMem=(value >> 12) & 0xf;
shSource=(value >> 10) & 0x3;
adcDiv=((value >> 5) & 0x7) + 1;
conSeq=(value >> 1) & 0x03;
adcSSel=(value >> 3) & 0x03;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + startMem+ "String_Node_Str"+ shSource+ "String_Node_Str"+ conSeq+ "String_Node_Str"+ adcDiv+ "String_Node_Str"+ adcSSel);
break;
case ADC12IE:
adc12ie=value;
break;
case ADC12IFG:
adc12ifg=value;
break;
default :
if (address >= ADC12MCTL0 && address <= ADC12MCTL15) {
adc12mctl[address - ADC12MCTL0]=value & 0xff;
System.out.println("String_Node_Str" + (address - ADC12MCTL0) + "String_Node_Str"+ (value & 0xf));
if ((value & 0x80) != 0) {
System.out.println("String_Node_Str" + (address - ADC12MCTL0) + "String_Node_Str");
}
}
}
}

Fixed version (ground truth):
public void write(int address,int value,boolean word,long cycles){
switch (address) {
case ADC12CTL0:
    adc12ctl0=value;
  shTime0=SHTBITS[(value >> 8) & 0x0f];
shTime1=SHTBITS[(value >> 12) & 0x0f];
adc12On=(value & 0x10) > 0;
enableConversion=(value & 0x02) > 0;
startConversion=(value & 0x01) > 0;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + shTime0+ "String_Node_Str"+ shTime1+ "String_Node_Str"+ enableConversion+ "String_Node_Str"+ startConversion+ "String_Node_Str"+ adc12On);
if (adc12On && enableConversion && startConversion) {
adcTrigger.time=core.getTime();
convert();
}
break;
case ADC12CTL1:
adc12ctl1=value;
startMem=(value >> 12) & 0xf;
shSource=(value >> 10) & 0x3;
adcDiv=((value >> 5) & 0x7) + 1;
conSeq=(value >> 1) & 0x03;
adcSSel=(value >> 3) & 0x03;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + startMem+ "String_Node_Str"+ shSource+ "String_Node_Str"+ conSeq+ "String_Node_Str"+ adcDiv+ "String_Node_Str"+ adcSSel);
break;
case ADC12IE:
adc12ie=value;
break;
case ADC12IFG:
adc12ifg=value;
break;
default :
if (address >= ADC12MCTL0 && address <= ADC12MCTL15) {
adc12mctl[address - ADC12MCTL0]=value & 0xff;
System.out.println("String_Node_Str" + (address - ADC12MCTL0) + "String_Node_Str"+ (value & 0xf));
if ((value & 0x80) != 0) {
System.out.println("String_Node_Str" + (address - ADC12MCTL0) + "String_Node_Str");
}
}
}
}
Program: 5718
Project: 5718
Buggy source:
public void receivedByte(byte data){
  if (cca)   setClear(false);
  if (stateMachine == STATE_RX_SFD_SEARCH) {
    if (data == 0) {
      zero_symbols++;
      return;
    }
    if (zero_symbols == 4) {
      if (data == 0x7A) {
        setSFD(true);
        if (DEBUG)         System.out.println("String_Node_Str");
        rxread=0;
        setState(STATE_RX_FRAME);
      }
 else {
        zero_symbols=0;
      }
    }
  }
 else   if (stateMachine == STATE_RX_FRAME) {
    if (rxfifo_len == 128) {
      setRxOverflow();
    }
 else {
      memory[RAM_RXFIFO + rxfifo_write_pos++]=data & 0xFF;
      rxfifo_len++;
      if (rxfifo_write_pos == 128) {
        if (DEBUG)         System.out.println("String_Node_Str");
        rxfifo_write_pos=0;
      }
      if (rxread == 0) {
        rxlen=(int)data;
        if (DEBUG)         System.out.println("String_Node_Str" + rxlen);
        setFIFO(true);
      }
      if (rxread++ == rxlen) {
        memory[RAM_RXFIFO + (rxfifo_write_pos - 2)]=(registers[REG_RSSI]) & 0xff;
        memory[RAM_RXFIFO + (rxfifo_write_pos - 1)]=37 | 0x80;
        setFIFOP(true);
        setSFD(false);
        if (DEBUG)         System.out.println("String_Node_Str");
        setState(STATE_RX_WAIT);
      }
    }
  }
}

Fixed version (ground truth):
public void receivedByte(byte data){
  if (cca)   setClear(false);
  if (stateMachine == STATE_RX_WAIT) {
    setState(STATE_RX_SFD_SEARCH);
  }
  if (stateMachine == STATE_RX_SFD_SEARCH) {
    if (data == 0) {
      zero_symbols++;
      return;
    }
    if (zero_symbols == 4) {
      if (data == 0x7A) {
        setSFD(true);
        if (DEBUG)         System.out.println("String_Node_Str");
        rxread=0;
        setState(STATE_RX_FRAME);
      }
 else {
        zero_symbols=0;
      }
    }
  }
 else   if (stateMachine == STATE_RX_FRAME) {
    if (rxfifo_len == 128) {
      setRxOverflow();
    }
 else {
      memory[RAM_RXFIFO + rxfifo_write_pos++]=data & 0xFF;
      rxfifo_len++;
      if (rxfifo_write_pos == 128) {
        if (DEBUG)         System.out.println("String_Node_Str");
        rxfifo_write_pos=0;
      }
      if (rxread == 0) {
        rxlen=(int)data;
        if (DEBUG)         System.out.println("String_Node_Str" + rxlen);
        setFIFO(true);
      }
      if (rxread++ == rxlen) {
        memory[RAM_RXFIFO + (rxfifo_write_pos - 2)]=(registers[REG_RSSI]) & 0xff;
        memory[RAM_RXFIFO + (rxfifo_write_pos - 1)]=37 | 0x80;
        setFIFOP(true);
        setSFD(false);
        if (DEBUG)         System.out.println("String_Node_Str");
        setState(STATE_RX_WAIT);
      }
    }
  }
}
Program: 5720
Project: 5720
Buggy source:
public void write(int dstAddress,int dst,boolean word){
  if (breakPoints[dstAddress] != null) {
    breakPoints[dstAddress].cpuAction(CPUMonitor.MEMORY_WRITE,dstAddress,dst);
  }
  if (dstAddress <= 0x200 && memOut[dstAddress] != null) {
    if (!word)     dst&=0xff;
    memOut[dstAddress].write(dstAddress,dst,word,cycles);
  }
 else {
    memory[dstAddress]=dst & 0xff;
    if (word) {
      memory[dstAddress + 1]=(dst >> 8) & 0xff;
    }
  }
}

Fixed version (ground truth):
public void write(int dstAddress,int dst,boolean word){
  if (breakPoints[dstAddress] != null) {
    breakPoints[dstAddress].cpuAction(CPUMonitor.MEMORY_WRITE,dstAddress,dst);
  }
  if (dstAddress < 0x1ff && memOut[dstAddress] != null) {
    if (!word)     dst&=0xff;
    memOut[dstAddress].write(dstAddress,dst,word,cycles);
  }
 else {
    memory[dstAddress]=dst & 0xff;
    if (word) {
      memory[dstAddress + 1]=(dst >> 8) & 0xff;
    }
  }
}
Program: 5721
Project: 5721
Buggy source:
public int read(int address,boolean word){
  int val=0;
  if (address < 0x200 && memIn[address] != null) {
    val=memIn[address].read(address,word,cycles);
  }
 else {
    address&=0xffff;
    val=memory[address] & 0xff;
    if (word) {
      val|=(memory[(address + 1) & 0xffff] << 8);
    }
  }
  return val;
}

Fixed version (ground truth):
public int read(int address,boolean word){
  int val=0;
  if (address < 0x1ff && memIn[address] != null) {
    val=memIn[address].read(address,word,cycles);
  }
 else {
    address&=0xffff;
    val=memory[address] & 0xff;
    if (word) {
      val|=(memory[(address + 1) & 0xffff] << 8);
    }
  }
  return val;
}
Program: 5722
Project: 5722
Buggy source:
private void calculateNextEventTime(long cycles){
  long time=nextTimerTrigger;
  int smallest=-1;
  for (int i=0; i < expCaptureTime.length; i++) {
    long ct=expCaptureTime[i];
    if (ct > 0 && ct < time) {
      time=ct;
      smallest=i;
    }
  }
  if (time == 0) {
    time=cycles + 1000;
  }
  if (timerTrigger.scheduledIn == null) {
    core.scheduleCycleEvent(timerTrigger,time);
  }
 else   if (timerTrigger.time > time) {
    core.scheduleCycleEvent(timerTrigger,time);
  }
}

Fixed version (ground truth):
private void calculateNextEventTime(long cycles){
  if (mode == STOP) {
    return;
  }
  long time=nextTimerTrigger;
  int smallest=-1;
  for (int i=0; i < noCompare; i++) {
    long ct=expCaptureTime[i];
    if (ct > 0 && ct < time) {
      time=ct;
      smallest=i;
    }
  }
  if (time == 0) {
    time=cycles + 1000;
  }
  if (timerTrigger.scheduledIn == null) {
    System.out.println(getName() + "String_Node_Str" + time+ "String_Node_Str"+ smallest+ "String_Node_Str"+ (smallest > 0 ? expCaptureTime[smallest] + "String_Node_Str" + expCompare[smallest] : nextTimerTrigger)+ "String_Node_Str"+ cycles);
    core.scheduleCycleEvent(timerTrigger,time);
  }
 else   if (timerTrigger.time > time) {
    System.out.println(getName() + "String_Node_Str" + time+ "String_Node_Str"+ cycles);
    core.scheduleCycleEvent(timerTrigger,time);
  }
}
Program: 5723
Project: 5723
Buggy source:
public void triggerInterrupts(){
  boolean trigger=false;
  int tIndex=0;
  for (int i=0, n=noCompare; i < n; i++) {
    boolean newTrigger=(tcctl[i] & CC_TRIGGER_INT) == CC_TRIGGER_INT;
    trigger=trigger | newTrigger;
    if (i == 0) {
      core.flagInterrupt(ccr0Vector,this,trigger);
      if (trigger) {
        lastTIV=0;
        return;
      }
    }
 else {
      if (newTrigger) {
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + (i * 2));
        }
        tIndex=i;
      }
    }
    if (trigger) {
      lastTIV=memory[type == TIMER_A ? TAIV : TBIV]=tIndex * 2;
    }
  }
  if (!trigger) {
    if (interruptEnable && interruptPending) {
      trigger=true;
      lastTIV=memory[type == TIMER_A ? TAIV : TBIV]=timerOverflow;
    }
  }
  core.flagInterrupt(ccr1Vector,this,trigger);
}

Fixed version (ground truth):
public void triggerInterrupts(long cycles){
  boolean trigger=false;
  int tIndex=0;
  for (int i=0, n=noCompare; i < n; i++) {
    boolean newTrigger=(tcctl[i] & CC_TRIGGER_INT) == CC_TRIGGER_INT;
    trigger=trigger | newTrigger;
    if (i == 0) {
      core.flagInterrupt(ccr0Vector,this,trigger);
      if (trigger) {
        lastTIV=0;
        return;
      }
    }
 else {
      if (newTrigger) {
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + (i * 2)+ "String_Node_Str"+ cycles);
        }
        tIndex=i;
      }
    }
    if (trigger) {
      lastTIV=memory[type == TIMER_A ? TAIV : TBIV]=tIndex * 2;
    }
  }
  if (!trigger) {
    if (interruptEnable && interruptPending) {
      trigger=true;
      lastTIV=memory[type == TIMER_A ? TAIV : TBIV]=timerOverflow;
    }
  }
  core.flagInterrupt(ccr1Vector,this,trigger);
}
Program: 5724
Project: 5724
Buggy source:
public int read(int address,boolean word,long cycles){
  if (address == TAIV || address == TBIV) {
    int val=lastTIV;
    resetTIV();
    return val;
  }
  int val=0;
  int index=address - offset;
switch (index) {
case TR:
    val=updateCounter(cycles);
  break;
case TCTL:
val=tctl;
if (interruptPending) {
val|=1;
}
 else {
val&=0xfffe;
}
if (DEBUG) System.out.println(getName() + "String_Node_Str" + name[type]+ "String_Node_Str"+ inputDivider+ "String_Node_Str"+ getSourceName(clockSource)+ "String_Node_Str"+ interruptEnable+ "String_Node_Str"+ interruptPending+ "String_Node_Str"+ mode);
break;
case TCCTL0:
case TCCTL1:
case TCCTL2:
case TCCTL3:
case TCCTL4:
case TCCTL5:
case TCCTL6:
int i=(index - TCCTL0) / 2;
val=tcctl[i];
break;
case TCCR0:
case TCCR1:
case TCCR2:
case TCCR3:
case TCCR4:
case TCCR5:
case TCCR6:
i=(index - TCCR0) / 2;
val=tccr[i];
break;
default :
System.out.println("String_Node_Str");
}
if (DEBUG && false) {
System.out.println(getName() + "String_Node_Str" + getName(address)+ "String_Node_Str"+ Utils.hex16(address)+ "String_Node_Str"+ Utils.hex16(val)+ "String_Node_Str"+ val+ "String_Node_Str");
}
return val & 0xffff;
}

Fixed version (ground truth):
public int read(int address,boolean word,long cycles){
  if (address == TAIV || address == TBIV) {
    int val=lastTIV;
    resetTIV(cycles);
    return val;
  }
  int val=0;
  int index=address - offset;
switch (index) {
case TR:
    val=updateCounter(cycles);
  break;
case TCTL:
val=tctl;
if (interruptPending) {
val|=1;
}
 else {
val&=0xfffe;
}
if (DEBUG) System.out.println(getName() + "String_Node_Str" + name[type]+ "String_Node_Str"+ inputDivider+ "String_Node_Str"+ getSourceName(clockSource)+ "String_Node_Str"+ interruptEnable+ "String_Node_Str"+ interruptPending+ "String_Node_Str"+ mode);
break;
case TCCTL0:
case TCCTL1:
case TCCTL2:
case TCCTL3:
case TCCTL4:
case TCCTL5:
case TCCTL6:
int i=(index - TCCTL0) / 2;
val=tcctl[i];
break;
case TCCR0:
case TCCR1:
case TCCR2:
case TCCR3:
case TCCR4:
case TCCR5:
case TCCR6:
i=(index - TCCR0) / 2;
val=tccr[i];
break;
default :
System.out.println("String_Node_Str");
}
if (DEBUG && false) {
System.out.println(getName() + "String_Node_Str" + getName(address)+ "String_Node_Str"+ Utils.hex16(address)+ "String_Node_Str"+ Utils.hex16(val)+ "String_Node_Str"+ val+ "String_Node_Str");
}
return val & 0xffff;
}
Program: 5725
Project: 5725
Buggy source:
private void resetTIV(){
  if (lastTIV == timerOverflow) {
    interruptPending=false;
    lastTIV=0;
    if (DEBUG) {
      System.out.println(getName() + "String_Node_Str");
    }
    triggerInterrupts();
  }
  if (lastTIV / 2 < noCompare) {
    if (DEBUG) {
      System.out.println(getName() + "String_Node_Str" + lastTIV);
    }
    tcctl[lastTIV / 2]&=~CC_IFG;
    triggerInterrupts();
  }
}

Fixed version (ground truth):
private void resetTIV(long cycles){
  if (lastTIV == timerOverflow) {
    interruptPending=false;
    lastTIV=0;
    if (DEBUG) {
      System.out.println(getName() + "String_Node_Str");
    }
    triggerInterrupts(cycles);
  }
  if (lastTIV / 2 < noCompare) {
    if (DEBUG) {
      System.out.println(getName() + "String_Node_Str" + lastTIV);
    }
    tcctl[lastTIV / 2]&=~CC_IFG;
    triggerInterrupts(cycles);
  }
}
Program: 5726
Project: 5726
Buggy source:
public void reset(int type){
  for (int i=0, n=expCompare.length; i < n; i++) {
    expCompare[i]=-1;
    expCaptureTime[i]=-1;
    expCapInterval[i]=0;
    outMode[i]=0;
    capMode[i]=0;
    inputSel[i]=0;
    inputSrc[i]=0;
    captureOn[i]=false;
  }
  for (int i=0; i < tcctl.length; i++) {
    tcctl[i]=0;
    tccr[i]=0;
  }
  tctl=0;
  lastTIV=0;
  interruptEnable=false;
  interruptPending=false;
  counter=0;
  counterPassed=0;
  counterStart=0;
  clockSource=0;
  cyclesMultiplicator=1;
  mode=STOP;
  nextTimerTrigger=0;
  inputDivider=1;
}

Fixed version (ground truth):
public void reset(int type){
  for (int i=0, n=expCompare.length; i < n; i++) {
    expCompare[i]=-1;
    expCaptureTime[i]=-1;
    expCapInterval[i]=0;
    outMode[i]=0;
    capMode[i]=0;
    inputSel[i]=0;
    inputSrc[i]=0;
    captureOn[i]=false;
  }
  for (int i=0; i < tcctl.length; i++) {
    tcctl[i]=0;
    tccr[i]=0;
  }
  tctl=0;
  lastTIV=0;
  interruptEnable=false;
  interruptPending=false;
  counter=0;
  counterPassed=0;
  counterStart=0;
  initialCounter=0;
  clockSource=0;
  cyclesMultiplicator=1;
  mode=STOP;
  nextTimerTrigger=0;
  inputDivider=1;
}
Program: 5727
Project: 5727
Buggy source:
private void updateTimers(long cycles){
  if (cycles >= nextTimerTrigger) {
    interruptPending=true;
    nextTimerTrigger=(long)(nextTimerTrigger + 0x10000 * cyclesMultiplicator);
  }
  for (int i=0, n=noCompare; i < n; i++) {
    if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) {
      if (DEBUG) {
        System.out.println(getName() + "String_Node_Str" + i+ "String_Node_Str"+ cycles+ "String_Node_Str"+ expCaptureTime[i]+ "String_Node_Str"+ Utils.hex16(expCompare[i])+ "String_Node_Str"+ Utils.hex16(updateCounter(cycles)));
      }
      tcctl[i]|=CC_IFG;
      if (captureOn[i]) {
        tccr[i]=expCompare[i];
        expCompare[i]=(expCompare[i] + expCapInterval[i]) & 0xffff;
        expCaptureTime[i]+=expCapInterval[i] * cyclesMultiplicator;
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + expCaptureTime[i]);
        }
      }
 else {
        expCaptureTime[i]=expCaptureTime[i] + (long)(0x10000 * cyclesMultiplicator);
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + expCaptureTime[i]);
        }
      }
      if (DEBUG) {
        System.out.println("String_Node_Str" + Utils.hex16(offset + TCCTL0 + i * 2 + 1));
      }
    }
  }
  triggerInterrupts();
  calculateNextEventTime(cycles);
}

Fixed version (ground truth):
private void updateTimers(long cycles){
  if (mode == STOP) {
    System.out.println("String_Node_Str");
    return;
  }
  if (cycles >= nextTimerTrigger) {
    interruptPending=true;
    nextTimerTrigger=(long)(nextTimerTrigger + 0x10000 * cyclesMultiplicator);
  }
  for (int i=0, n=noCompare; i < n; i++) {
    if (expCaptureTime[i] != -1 && cycles >= expCaptureTime[i]) {
      if (DEBUG) {
        System.out.println(getName() + (captureOn[i] ? "String_Node_Str" : "String_Node_Str") + i+ "String_Node_Str"+ cycles+ "String_Node_Str"+ expCaptureTime[i]+ "String_Node_Str"+ Utils.hex16(expCompare[i])+ "String_Node_Str"+ Utils.hex16(updateCounter(cycles)));
      }
      tcctl[i]|=CC_IFG;
      if (captureOn[i]) {
        tccr[i]=expCompare[i];
        expCompare[i]=(expCompare[i] + expCapInterval[i]) & 0xffff;
        expCaptureTime[i]+=expCapInterval[i] * cyclesMultiplicator;
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + expCaptureTime[i]);
        }
      }
 else {
        expCaptureTime[i]=expCaptureTime[i] + (long)(0x10000 * cyclesMultiplicator);
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + expCaptureTime[i]);
        }
      }
      if (DEBUG) {
        System.out.println("String_Node_Str" + Utils.hex16(offset + TCCTL0 + i * 2 + 1));
      }
    }
  }
  triggerInterrupts(cycles);
  calculateNextEventTime(cycles);
}