nus-yam/ex-repair huggingface dataset:
Program: 5729
Project: 5729
Buggy source:
private int updateCounter(long cycles){
  double divider=1;
  if (clockSource == SRC_ACLK) {
    divider=1.0 * core.smclkFrq / core.aclkFrq;
  }
  divider=divider * inputDivider;
  long cycctr=cycles - counterStart;
  double tick=cycctr / divider;
  counterPassed=(int)(divider * (tick - (long)(tick)));
switch (mode) {
case CONTIN:
    counter=((int)tick) & 0xffff;
  break;
case UP:
counter=((int)tick) % tccr[0];
break;
case UPDWN:
counter=((int)tick) % (tccr[0] * 2);
if (counter > tccr[0]) {
counter=2 * tccr[0] - counter;
}
}
if (DEBUG) {
System.out.println(getName() + "String_Node_Str" + cycctr+ "String_Node_Str"+ divider+ "String_Node_Str"+ mode+ "String_Node_Str"+ counter);
}
return counter;
}

Fixed version (ground truth):
private int updateCounter(long cycles){
  if (mode == STOP)   return counter;
  double divider=1;
  if (clockSource == SRC_ACLK) {
    divider=1.0 * core.smclkFrq / core.aclkFrq;
  }
  divider=divider * inputDivider;
  long cycctr=cycles - counterStart;
  double tick=cycctr / divider;
  counterPassed=(int)(divider * (tick - (long)(tick)));
switch (mode) {
case CONTIN:
    counter=((int)tick + initialCounter) & 0xffff;
  break;
case UP:
counter=((int)tick + initialCounter) % tccr[0];
break;
case UPDWN:
counter=((int)tick + initialCounter) % (tccr[0] * 2);
if (counter > tccr[0]) {
counter=2 * tccr[0] - counter;
}
}
if (DEBUG) {
System.out.println(getName() + "String_Node_Str" + cycctr+ "String_Node_Str"+ divider+ "String_Node_Str"+ mode+ "String_Node_Str"+ counter);
}
return counter;
}
Program: 5732
Project: 5732
Buggy source:
public void flagInterrupt(int interrupt,IOUnit source,boolean triggerIR){
  if (triggerIR) {
    interruptSource[interrupt]=source;
    if (debugInterrupts) {
      System.out.println("String_Node_Str" + source.getName());
    }
    if (interrupt > interruptMax) {
      interruptMax=interrupt;
      if (interruptMax == 15) {
        interruptsEnabled=true;
      }
    }
  }
 else {
    if (interruptSource[interrupt] == source) {
      if (debugInterrupts) {
        System.out.println("String_Node_Str" + source.getName());
      }
      interruptSource[interrupt]=null;
    }
  }
}

Fixed version (ground truth):
public void flagInterrupt(int interrupt,IOUnit source,boolean triggerIR){
  if (triggerIR) {
    interruptSource[interrupt]=source;
    if (debugInterrupts) {
      if (source != null) {
        System.out.println("String_Node_Str" + source.getName());
      }
 else {
        System.out.println("String_Node_Str");
      }
    }
    if (interrupt > interruptMax) {
      interruptMax=interrupt;
      if (interruptMax == 15) {
        interruptsEnabled=true;
      }
    }
  }
 else {
    if (interruptSource[interrupt] == source) {
      if (debugInterrupts) {
        System.out.println("String_Node_Str" + source.getName());
      }
      interruptSource[interrupt]=null;
    }
  }
}
Program: 5733
Project: 5733
Buggy source:
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;
}

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);
    }
  }
  if (breakPoints[address] != null) {
    breakPoints[address].cpuAction(CPUMonitor.MEMORY_READ,address,val);
  }
  return val;
}
Program: 5735
Project: 5735
Buggy source:
public void step(){
  if (!cpu.isRunning()) {
    cpu.step();
  }
}

Fixed version (ground truth):
public void step(int nr){
  if (!cpu.isRunning()) {
    cpu.stepInstructions(nr);
  }
}
Program: 5736
Project: 5736
Buggy source:
public void dataSent(int[] data){
  if (connections.size() > 0) {
    for (int i=0; i < data.length; i++) {
      buf[i]=(byte)data[i];
    }
    ConnectionThread[] cthr=connections.toArray(new ConnectionThread[connections.size()]);
    for (int i=0; i < cthr.length; i++) {
      if (cthr[i].isClosed()) {
        connections.remove(cthr);
      }
 else {
        try {
          cthr[i].output.write((byte)data.length);
          cthr[i].output.write(buf);
          if (DEBUG)           System.out.println("String_Node_Str" + data.length + "String_Node_Str");
        }
 catch (        IOException e) {
          e.printStackTrace();
          cthr[i].close();
        }
      }
    }
  }
}

Fixed version (ground truth):
public void dataSent(int[] data){
  if (connections.size() > 0) {
    for (int i=0; i < data.length; i++) {
      buf[i]=(byte)data[i];
    }
    ConnectionThread[] cthr=connections.toArray(new ConnectionThread[connections.size()]);
    for (int i=0; i < cthr.length; i++) {
      if (cthr[i].isClosed()) {
        connections.remove(cthr);
      }
 else {
        try {
          cthr[i].output.write((byte)data.length);
          cthr[i].output.write(buf,0,data.length);
          if (DEBUG) {
            System.out.println("String_Node_Str" + data.length + "String_Node_Str");
            printPacket(buf,data.length);
          }
        }
 catch (        IOException e) {
          e.printStackTrace();
          cthr[i].close();
        }
      }
    }
  }
}
Program: 5737
Project: 5737
Buggy source:
@Override public void run(){
  if (DEBUG)   System.out.println("String_Node_Str");
  while (socket != null) {
    int len;
    try {
      len=input.read();
      if (len > 0) {
        input.readFully(buffer,0,len);
        if (DEBUG)         System.out.println("String_Node_Str" + len + "String_Node_Str");
        dataReceived(buffer,len);
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
      socket=null;
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  if (DEBUG)   System.out.println("String_Node_Str");
  while (socket != null) {
    int len;
    try {
      len=input.read();
      if (len > 0) {
        input.readFully(buffer,0,len);
        if (DEBUG) {
          System.out.println("String_Node_Str" + len + "String_Node_Str");
          printPacket(buffer,len);
        }
        dataReceived(buffer,len);
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
      socket=null;
    }
  }
}
Program: 5738
Project: 5738
Buggy source:
private boolean removePid(int pid){
  for (int i=0; i < currentAsyncCommands.size(); i++) {
    CommandContext[] contexts=currentAsyncCommands.get(i);
    CommandContext cmd=contexts[0];
    if (pid == cmd.getPID()) {
      for (int j=0; j < contexts.length; j++) {
        Command command=contexts[i].getCommand();
        if (command instanceof AsyncCommand && !contexts[i].hasExited()) {
          AsyncCommand ac=(AsyncCommand)command;
          ac.stopCommand(contexts[i]);
        }
      }
      currentAsyncCommands.remove(contexts);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean removePid(int pid){
  CommandContext[] contexts=null;
synchronized (currentAsyncCommands) {
    for (int i=0, n=currentAsyncCommands.size(); i < n; i++) {
      CommandContext[] cntx=currentAsyncCommands.get(i);
      if (pid == cntx[0].getPID()) {
        contexts=cntx;
        currentAsyncCommands.remove(cntx);
        break;
      }
    }
  }
  if (contexts != null) {
    for (int i=0; i < contexts.length; i++) {
      Command command=contexts[i].getCommand();
      if (command instanceof AsyncCommand && !contexts[i].hasExited()) {
        AsyncCommand ac=(AsyncCommand)command;
        ac.stopCommand(contexts[i]);
      }
    }
    return true;
  }
  return false;
}
Program: 5739
Project: 5739
Buggy source:
public void run(){
  String lastLine=null;
  while (!exit) {
    try {
      out.print("String_Node_Str");
      out.flush();
      String line=readLine(inReader);
      if (((char)27 + "String_Node_Str").equals(line)) {
        line=lastLine;
      }
      if (line != null && line.length() > 0) {
        lastLine=line;
        String[][] parts;
        try {
          parts=CommandParser.parseCommandLine(line);
        }
 catch (        Exception e) {
          err.println("String_Node_Str");
          e.printStackTrace(err);
          parts=null;
        }
        if (parts != null && parts.length > 0 && checkCommands(parts) == 0) {
          CommandContext[] commands=new CommandContext[parts.length];
          boolean error=false;
          int pid=-1;
          for (int i=0; i < parts.length; i++) {
            String[] args=parts[i];
            Command cmd=getCommand(args[0]);
            if (i == 0 && cmd instanceof AsyncCommand) {
              pid=++pidCounter;
            }
            commands[i]=new CommandContext(this,mapTable,line,args,pid,cmd);
            if (i > 0) {
              PrintStream po=new PrintStream(new LineOutputStream((LineListener)commands[i].getCommand()));
              commands[i - 1].setOutput(po,err);
            }
            if (i == parts.length - 1) {
              commands[i].setOutput(out,err);
            }
          }
          for (int i=parts.length - 1; i >= 0; i--) {
            try {
              int code=commands[i].getCommand().executeCommand(commands[i]);
              if (code != 0) {
                err.println("String_Node_Str" + commands[i].getCommandName() + "String_Node_Str"+ code);
                error=true;
              }
            }
 catch (            Exception e) {
              err.println("String_Node_Str" + e.getMessage());
              e.printStackTrace(err);
              error=true;
            }
          }
          if (error) {
          }
 else           if (pid >= 0) {
            currentAsyncCommands.add(commands);
          }
        }
      }
    }
 catch (    IOException e) {
      e.printStackTrace(err);
      err.println("String_Node_Str");
      exit=true;
    }
  }
}

Fixed version (ground truth):
public void run(){
  String lastLine=null;
  while (!exit) {
    try {
      out.print("String_Node_Str");
      out.flush();
      String line=readLine(inReader);
      if (((char)27 + "String_Node_Str").equals(line)) {
        line=lastLine;
      }
      if (line != null && line.length() > 0) {
        lastLine=line;
        executeCommand(line);
      }
    }
 catch (    IOException e) {
      e.printStackTrace(err);
      err.println("String_Node_Str");
      exit=true;
    }
  }
}
Program: 5740
Project: 5740
Buggy source:
private void removePid(int pid){
  System.out.println("String_Node_Str" + pid);
  for (int i=0; i < currentAsyncCommands.size(); i++) {
    CommandContext[] contexts=currentAsyncCommands.get(i);
    CommandContext cmd=contexts[0];
    if (pid == cmd.getPID()) {
      for (int j=0; j < contexts.length; j++) {
        Command command=contexts[i].getCommand();
        if (command instanceof AsyncCommand && !contexts[i].hasExited()) {
          AsyncCommand ac=(AsyncCommand)command;
          ac.stopCommand(contexts[i]);
        }
      }
      currentAsyncCommands.remove(contexts);
      break;
    }
  }
}

Fixed version (ground truth):
private boolean removePid(int pid){
  for (int i=0; i < currentAsyncCommands.size(); i++) {
    CommandContext[] contexts=currentAsyncCommands.get(i);
    CommandContext cmd=contexts[0];
    if (pid == cmd.getPID()) {
      for (int j=0; j < contexts.length; j++) {
        Command command=contexts[i].getCommand();
        if (command instanceof AsyncCommand && !contexts[i].hasExited()) {
          AsyncCommand ac=(AsyncCommand)command;
          ac.stopCommand(contexts[i]);
        }
      }
      currentAsyncCommands.remove(contexts);
      return true;
    }
  }
  return false;
}
Program: 5741
Project: 5741
Buggy source:
public int executeCommand(CommandContext context){
  int pid=context.getArgumentAsInt(0);
  removePid(pid);
  return 0;
}

Fixed version (ground truth):
public int executeCommand(CommandContext context){
  int pid=context.getArgumentAsInt(0);
  if (removePid(pid)) {
    return 0;
  }
  context.err.println("String_Node_Str");
  return 1;
}
Program: 5743
Project: 5743
Buggy source:
public void setupNode(){
  setupNodePorts();
  if (!config.getPropertyAsBoolean("String_Node_Str",false)) {
    gui=new ESBGui(this);
    DataChart dataChart=new DataChart("String_Node_Str","String_Node_Str");
    DataSourceSampler dss=dataChart.setupChipFrame(cpu);
    dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",TR1001.MODE_RX_ON));
    dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",TR1001.MODE_TXRX_ON));
    dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",MSP430.MODE_ACTIVE));
  }
  stats.addMonitor(this);
  stats.addMonitor(radio);
  stats.addMonitor(cpu);
}

Fixed version (ground truth):
public void setupNode(){
  setupNodePorts();
  stats.addMonitor(this);
  stats.addMonitor(radio);
  stats.addMonitor(cpu);
  if (!config.getPropertyAsBoolean("String_Node_Str",false)) {
    gui=new ESBGui(this);
    DataChart dataChart=new DataChart("String_Node_Str","String_Node_Str");
    DataSourceSampler dss=dataChart.setupChipFrame(cpu);
    dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",TR1001.MODE_RX_ON));
    dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",TR1001.MODE_TXRX_ON));
    dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",MSP430.MODE_ACTIVE));
  }
}
Program: 5744
Project: 5744
Buggy source:
public void interruptServiced(int vector){
  if (vector == ccr0Vector) {
    core.flagInterrupt(ccr0Vector,this,false);
  }
  if (MSP430Core.debugInterrupts) {
    System.out.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public void interruptServiced(int vector){
  if (vector == ccr0Vector) {
    core.flagInterrupt(ccr0Vector,this,false);
    tcctl[0]&=~CC_IFG;
  }
  if (MSP430Core.debugInterrupts) {
    System.out.println("String_Node_Str");
  }
}
Program: 5746
Project: 5746
Buggy source:
public void interruptServiced(int vector){
  if (MSP430Core.debugInterrupts) {
    System.out.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public void interruptServiced(int vector){
  if (vector == ccr0Vector) {
    core.flagInterrupt(ccr0Vector,this,false);
  }
  if (MSP430Core.debugInterrupts) {
    System.out.println("String_Node_Str");
  }
}
Program: 5747
Project: 5747
Buggy source:
private void calculateNextEventTime(long cycles){
  long time=nextTimerTrigger;
  for (int i=0; i < expCaptureTime.length; i++) {
    long ct=expCaptureTime[i];
    if (ct > 0 && ct < time) {
      time=ct;
    }
  }
  if (time == 0) {
    time=cycles + 1000;
  }
  if (!timerTrigger.scheduled) {
    core.scheduleCycleEvent(timerTrigger,time);
  }
 else   if (timerTrigger.time > time) {
    core.scheduleCycleEvent(timerTrigger,time);
  }
}

Fixed version (ground truth):
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.scheduled) {
    core.scheduleCycleEvent(timerTrigger,time);
  }
 else   if (timerTrigger.time > time) {
    core.scheduleCycleEvent(timerTrigger,time);
  }
}
Program: 5748
Project: 5748
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(type == TIMER_A ? TACCR0_VECTOR : TBCCR0_VECTOR,this,trigger);
      if (trigger) {
        lastTIV=memory[type == TIMER_A ? TAIV : TBIV]=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(type == TIMER_A ? TACCR1_VECTOR : TBCCR1_VECTOR,this,trigger);
}

Fixed version (ground truth):
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=memory[type == TIMER_A ? TAIV : TBIV]=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);
}
Program: 5749
Project: 5749
Buggy source:
/** 
 * Creates a new <code>Timer</code> instance.
 */
public Timer(MSP430Core core,int[] srcMap,int[] memory,int offset){
  super(memory,offset);
  this.srcMap=srcMap;
  this.core=core;
  noCompare=(srcMap.length / 4) - 1;
  if (DEBUG) {
    System.out.println("String_Node_Str" + noCompare);
  }
  if (srcMap == TIMER_Ax149) {
    type=TIMER_A;
    timerOverflow=0x0a;
  }
 else {
    type=TIMER_B;
    timerOverflow=0x0e;
  }
  reset();
}

Fixed version (ground truth):
/** 
 * Creates a new <code>Timer</code> instance.
 */
public Timer(MSP430Core core,int[] srcMap,int[] memory,int offset){
  super(memory,offset);
  this.srcMap=srcMap;
  this.core=core;
  noCompare=(srcMap.length / 4) - 1;
  if (DEBUG) {
    System.out.println("String_Node_Str" + noCompare);
  }
  if (srcMap == TIMER_Ax149) {
    type=TIMER_A;
    timerOverflow=0x0a;
  }
 else {
    type=TIMER_B;
    timerOverflow=0x0e;
  }
  ccr0Vector=type == TIMER_A ? TACCR0_VECTOR : TBCCR0_VECTOR;
  ccr1Vector=type == TIMER_A ? TACCR1_VECTOR : TBCCR1_VECTOR;
  reset();
}
Program: 5750
Project: 5750
Buggy source:
public void addEvent(TimeEvent event){
  if (event.scheduled) {
    removeEvent(event);
  }
  eventCount++;
  if (first == null) {
    first=event;
  }
 else {
    TimeEvent pos=first;
    TimeEvent lastPos=first;
    while (pos != null && pos.time < event.time) {
      lastPos=pos;
      pos=pos.nextEvent;
    }
    if (pos == first) {
      event.nextEvent=pos;
      first=event;
    }
 else {
      event.nextEvent=pos;
      lastPos.nextEvent=event;
    }
  }
  if (first != null) {
    nextTime=first.time;
  }
 else {
    nextTime=0;
  }
  event.scheduled=true;
}

Fixed version (ground truth):
public void addEvent(TimeEvent event){
  if (event.scheduled) {
    removeEvent(event);
  }
  if (first == null) {
    first=event;
  }
 else {
    TimeEvent pos=first;
    TimeEvent lastPos=first;
    while (pos != null && pos.time < event.time) {
      lastPos=pos;
      pos=pos.nextEvent;
    }
    if (pos == first) {
      event.nextEvent=pos;
      first=event;
    }
 else {
      event.nextEvent=pos;
      lastPos.nextEvent=event;
    }
  }
  if (first != null) {
    nextTime=first.time;
  }
 else {
    nextTime=0;
  }
  event.scheduled=true;
  eventCount++;
}
Program: 5751
Project: 5751
Buggy source:
public TimeEvent popFirst(){
  TimeEvent tmp=first;
  if (tmp != null) {
    first=tmp.nextEvent;
    tmp.nextEvent=null;
  }
  if (first != null) {
    nextTime=first.time;
  }
 else {
    nextTime=0;
  }
  tmp.scheduled=false;
  return tmp;
}

Fixed version (ground truth):
public TimeEvent popFirst(){
  TimeEvent tmp=first;
  if (tmp != null) {
    first=tmp.nextEvent;
    tmp.nextEvent=null;
  }
  if (first != null) {
    nextTime=first.time;
  }
 else {
    nextTime=0;
  }
  tmp.scheduled=false;
  eventCount--;
  return tmp;
}
Program: 5753
Project: 5753
Buggy source:
public void setupNode(){
  String fileName=firmwareFile;
  int ix=fileName.lastIndexOf('.');
  if (ix > 0) {
    fileName=fileName.substring(0,ix);
  }
  fileName=fileName + "String_Node_Str";
  System.out.println("String_Node_Str" + fileName);
  this.flashFile=flashFile;
  setupNodePorts();
  stats.addMonitor(this);
  stats.addMonitor(radio);
  stats.addMonitor(cpu);
  cpu.scheduleCycleEvent(new TimeEvent(0){
    public void execute(    long t){
      System.out.println("String_Node_Str" + t + "String_Node_Str"+ SkyNode.this.cpu.getTimeMillis());
      SkyNode.this.cpu.scheduleCycleEvent(this,time + 1000000);
    }
  }
,1000000);
  radio.setPacketListener(new PacketListener(){
    public void transmissionEnded(    int[] receivedData){
      System.out.println(getName() + "String_Node_Str" + SkyNode.this.cpu.getTimeMillis());
    }
    public void transmissionStarted(){
      System.out.println(getName() + "String_Node_Str" + SkyNode.this.cpu.getTimeMillis());
    }
  }
);
  gui=new SkyGui(this);
  DataChart dataChart=new DataChart("String_Node_Str","String_Node_Str");
  DataSourceSampler dss=dataChart.setupChipFrame(cpu);
  dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",0,OperatingModeStatistics.OP_INVERT));
  dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",CC2420.MODE_RX_ON));
  dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",CC2420.MODE_TXRX_ON));
  dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",MSP430.MODE_ACTIVE));
}

Fixed version (ground truth):
public void setupNode(){
  String fileName=firmwareFile;
  int ix=fileName.lastIndexOf('.');
  if (ix > 0) {
    fileName=fileName.substring(0,ix);
  }
  fileName=fileName + "String_Node_Str";
  System.out.println("String_Node_Str" + fileName);
  this.flashFile=flashFile;
  setupNodePorts();
  stats.addMonitor(this);
  stats.addMonitor(radio);
  stats.addMonitor(cpu);
  radio.setPacketListener(new PacketListener(){
    public void transmissionEnded(    int[] receivedData){
      System.out.println(getName() + "String_Node_Str" + SkyNode.this.cpu.getTimeMillis());
    }
    public void transmissionStarted(){
      System.out.println(getName() + "String_Node_Str" + SkyNode.this.cpu.getTimeMillis());
    }
  }
);
  gui=new SkyGui(this);
  DataChart dataChart=new DataChart("String_Node_Str","String_Node_Str");
  DataSourceSampler dss=dataChart.setupChipFrame(cpu);
  dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",0,OperatingModeStatistics.OP_INVERT));
  dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",CC2420.MODE_RX_ON));
  dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",CC2420.MODE_TXRX_ON));
  dataChart.addDataSource(dss,"String_Node_Str",stats.getDataSource("String_Node_Str",MSP430.MODE_ACTIVE));
}
Program: 5754
Project: 5754
Buggy source:
public void setIncomingPacket(int[] packet){
  int adr=RAM_RXFIFO;
  memory[adr++]=packet.length + 2;
  for (int i=0, n=packet.length; i < n; i++) {
    memory[adr++]=packet[i] & 0xff;
  }
  memory[adr++]=(202) & 0xff;
  memory[adr++]=(37) | 0x80;
  rxPacket=true;
  rxCursor=0;
  rxLen=adr;
  updateFifopPin();
}

Fixed version (ground truth):
public void setIncomingPacket(int[] packet){
  int adr=RAM_RXFIFO;
  memory[adr++]=packet.length + 2;
  for (  int element : packet) {
    memory[adr++]=element & 0xff;
  }
  memory[adr++]=(202) & 0xff;
  memory[adr++]=(37) | 0x80;
  rxPacket=true;
  rxCursor=0;
  rxLen=adr;
  updateFifopPin();
}
Program: 5755
Project: 5755
Buggy source:
private void flushRX(){
  if (DEBUG)   System.out.println("String_Node_Str" + rxPacket + "String_Node_Str"+ rxLen);
  rxPacket=false;
  rxCursor=0;
  rxLen=0;
  updateFifopPin();
}

Fixed version (ground truth):
private void flushRX(){
  if (DEBUG) {
    System.out.println("String_Node_Str" + rxPacket + "String_Node_Str"+ rxLen);
  }
  rxPacket=false;
  rxCursor=0;
  rxLen=0;
  updateFifopPin();
}
Program: 5757
Project: 5757
Buggy source:
public void execute(long t){
  if (DEBUG)   System.out.println(getName() + "String_Node_Str");
  if (packetListener != null) {
    int len=memory[RAM_TXFIFO];
    int[] data=new int[len];
    System.arraycopy(memory,RAM_TXFIFO + 1,data,0,len);
    packetListener.transmissionEnded(data);
  }
}

Fixed version (ground truth):
public void execute(long t){
  if (DEBUG) {
    System.out.println(getName() + "String_Node_Str");
  }
  if (packetListener != null) {
    int len=memory[RAM_TXFIFO];
    int[] data=new int[len];
    System.arraycopy(memory,RAM_TXFIFO + 1,data,0,len);
    packetListener.transmissionEnded(data);
  }
}
Program: 5758
Project: 5758
Buggy source:
private void strobe(int data){
  if (DEBUG)   System.out.println("String_Node_Str" + Utils.hex8(data));
switch (data) {
case REG_SRXON:
    if (DEBUG)     System.out.println("String_Node_Str");
  setMode(MODE_RX_ON);
break;
case REG_SRFOFF:
if (DEBUG) System.out.println("String_Node_Str");
setMode(MODE_TXRX_OFF);
break;
case REG_STXON:
if (DEBUG) System.out.println("String_Node_Str");
setMode(MODE_TXRX_ON);
transmitPacket();
break;
case REG_STXONCCA:
if (DEBUG) System.out.println("String_Node_Str");
setMode(MODE_TXRX_ON);
transmitPacket();
break;
case REG_SFLUSHRX:
flushRX();
break;
case REG_SFLUSHTX:
flushTX();
break;
}
}

Fixed version (ground truth):
private void strobe(int data){
  if (DEBUG) {
    System.out.println("String_Node_Str" + Utils.hex8(data));
  }
switch (data) {
case REG_SRXON:
    setActiveFrequency(registers[REG_FSCTRL]);
  if (DEBUG) {
    System.out.println("String_Node_Str");
  }
setMode(MODE_RX_ON);
break;
case REG_SRFOFF:
if (DEBUG) {
System.out.println("String_Node_Str");
}
setMode(MODE_TXRX_OFF);
break;
case REG_STXON:
setActiveFrequency(registers[REG_FSCTRL]);
if (DEBUG) {
System.out.println("String_Node_Str");
}
setMode(MODE_TXRX_ON);
transmitPacket();
break;
case REG_STXONCCA:
setActiveFrequency(registers[REG_FSCTRL]);
if (DEBUG) {
System.out.println("String_Node_Str");
}
setMode(MODE_TXRX_ON);
transmitPacket();
break;
case REG_SFLUSHRX:
flushRX();
break;
case REG_SFLUSHTX:
flushTX();
break;
default :
if (DEBUG) {
System.out.println("String_Node_Str" + data);
}
}
}
Program: 5759
Project: 5759
Buggy source:
public void setChipSelect(boolean select){
  chipSelect=select;
  if (!chipSelect)   state=WAITING;
  if (DEBUG)   System.out.println("String_Node_Str" + chipSelect);
}

Fixed version (ground truth):
public void setChipSelect(boolean select){
  chipSelect=select;
  if (!chipSelect) {
    state=WAITING;
  }
  if (DEBUG) {
    System.out.println("String_Node_Str" + chipSelect);
  }
}
Program: 5760
Project: 5760
Buggy source:
private void transmitPacket(){
  int len=memory[RAM_TXFIFO];
  int kBps=250000 / 8;
  double time=1.0 * len / kBps;
  if (DEBUG)   System.out.println(getName() + "String_Node_Str" + len+ "String_Node_Str"+ time+ "String_Node_Str");
  if (packetListener != null) {
    packetListener.transmissionStarted();
    cpu.scheduleTimeEventMillis(transmissionEvent,1000 * time);
  }
}

Fixed version (ground truth):
private void transmitPacket(){
  int len=memory[RAM_TXFIFO];
  int kBps=250000 / 8;
  double time=1.0 * len / kBps;
  if (DEBUG) {
    System.out.println(getName() + "String_Node_Str" + len+ "String_Node_Str"+ time+ "String_Node_Str");
  }
  if (packetListener != null) {
    packetListener.transmissionStarted();
    cpu.scheduleTimeEventMillis(transmissionEvent,1000 * time);
  }
}
Program: 5761
Project: 5761
Buggy source:
public void run(){
  while (!exit) {
    try {
      out.print("String_Node_Str");
      String line=inReader.readLine();
      if (line != null && line.length() > 0) {
        String[] parts=line.split("String_Node_Str");
        Command cmd=commands.get(parts[0]);
        if (cmd == null) {
          out.println("String_Node_Str" + parts[0]);
        }
 else {
          CommandContext cc=new CommandContext(mapTable,parts,in,out,err);
          try {
            cmd.executeCommand(cc);
          }
 catch (          Exception e) {
            err.println("String_Node_Str" + e.getMessage());
            e.printStackTrace(err);
          }
        }
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
      err.println("String_Node_Str");
      exit=true;
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (!exit) {
    try {
      out.print("String_Node_Str");
      out.flush();
      String line=readLine(inReader);
      if (line != null && line.length() > 0) {
        String[] parts=line.split("String_Node_Str");
        Command cmd=commands.get(parts[0]);
        if (cmd == null) {
          out.println("String_Node_Str" + parts[0]);
        }
 else {
          CommandContext cc=new CommandContext(mapTable,parts,in,out,err);
          try {
            cmd.executeCommand(cc);
          }
 catch (          Exception e) {
            err.println("String_Node_Str" + e.getMessage());
            e.printStackTrace(err);
          }
        }
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
      err.println("String_Node_Str");
      exit=true;
    }
  }
}
Program: 5763
Project: 5763
Buggy source:
public void cpuAction(int type,int adr,int data){
  context.out.println("String_Node_Str" + adr + "String_Node_Str"+ data);
}

Fixed version (ground truth):
public void cpuAction(int type,int adr,int data){
  int pc=cpu.readRegister(0);
  String adrStr=getSymOrAddr(context,adr);
  String pcStr=getSymOrAddrELF(elf,pc);
  context.out.println("String_Node_Str" + pcStr + "String_Node_Str"+ adrStr+ "String_Node_Str"+ data);
}
Program: 5764
Project: 5764
Buggy source:
public int executeCommand(final CommandContext context){
  int baddr=context.getArgumentAsAddress(0);
  cpu.setBreakPoint(baddr,new CPUMonitor(){
    public void cpuAction(    int type,    int adr,    int data){
      context.out.println("String_Node_Str" + adr + "String_Node_Str"+ data);
    }
  }
);
  context.out.println("String_Node_Str" + baddr);
  return 0;
}

Fixed version (ground truth):
public int executeCommand(final CommandContext context){
  String regExp=context.getArgument(0);
  MapEntry[] entries=context.getMapTable().getEntries(regExp);
  for (int i=0; i < entries.length; i++) {
    MapEntry mapEntry=entries[i];
    context.out.println("String_Node_Str" + mapEntry.getName() + "String_Node_Str"+ Utils.hex16(mapEntry.getAddress()));
  }
  return 0;
}
Program: 5766
Project: 5766
Buggy source:
public ArrayList<MapEntry> getAllEntries(){
  ArrayList<MapEntry> allEntries=new ArrayList<MapEntry>();
  for (int address=0; address < entries.length; address++) {
    MapEntry entry=getEntry(address);
    if (entry != null) {
      allEntries.add(entry);
    }
  }
  return allEntries;
}

Fixed version (ground truth):
public MapEntry[] getAllEntries(){
  ArrayList<MapEntry> allEntries=new ArrayList<MapEntry>();
  for (int address=0; address < entries.length; address++) {
    MapEntry entry=getEntry(address);
    if (entry != null) {
      allEntries.add(entry);
    }
  }
  return allEntries.toArray(new MapEntry[allEntries.size()]);
}
Program: 5767
Project: 5767
Buggy source:
private void writeBack(int address,byte[] data){
  try {
    if (DEBUG)     System.out.println("String_Node_Str" + Integer.toHexString(address));
    file.seek(address & 0xfff00);
    file.write(data);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void writeBack(int address,byte[] data){
  try {
    byte[] tmp=new byte[data.length];
    if (DEBUG)     System.out.println("String_Node_Str" + Integer.toHexString(address));
    file.seek(address & 0xfff00);
    for (int i=0; i < data.length; i++) {
      tmp[i]=(byte)(~data[i] & 0xff);
    }
    file.write(tmp);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 5768
Project: 5768
Buggy source:
private void ensureLoaded(int address){
  if (loadedAddress < 0 || ((loadedAddress & 0xfff00) != (address & 0xfff00))) {
    try {
      if (DEBUG)       System.out.println("String_Node_Str" + (address & 0xfff00));
      file.seek(address & 0xfff00);
      file.readFully(readMemory);
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    loadedAddress=address & 0xfff00;
  }
}

Fixed version (ground truth):
private void ensureLoaded(int address){
  if (loadedAddress < 0 || ((loadedAddress & 0xfff00) != (address & 0xfff00))) {
    try {
      if (DEBUG)       System.out.println("String_Node_Str" + (address & 0xfff00));
      file.seek(address & 0xfff00);
      file.readFully(readMemory);
      for (int i=0; i < readMemory.length; i++) {
        readMemory[i]=(byte)(~readMemory[i] & 0xff);
      }
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    loadedAddress=address & 0xfff00;
  }
}
Program: 5769
Project: 5769
Buggy source:
public void write(int address,int data,boolean word,long cycles){
  if (DEBUG) {
    System.out.println("String_Node_Str" + Utils.hex16(address) + "String_Node_Str"+ data+ "String_Node_Str"+ word);
  }
  if (MSP430Constants.DEBUGGING_LEVEL > 0) {
    System.out.println("String_Node_Str" + Integer.toString(address,16) + "String_Node_Str"+ data);
  }
switch (address) {
case MPY:
    mpy=data;
  if (DEBUG)   System.out.println(getName() + "String_Node_Str" + data);
lastWriteOP=address;
break;
case MPYS:
mpys=data;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + data);
lastWriteOP=address;
break;
case MAC:
mac=data;
currentSum=0;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + data);
lastWriteOP=address;
break;
case MACS:
macs=data;
currentSum=0;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + data);
lastWriteOP=address;
break;
case OP2:
if (DEBUG) System.out.println(getName() + "String_Node_Str" + data);
sumext=0;
op2=data;
int o1=mpy;
boolean signMode=false;
boolean sum=false;
if (lastWriteOP == MPYS) {
o1=MPYS;
signMode=true;
}
 else if (lastWriteOP == MAC) {
o1=mac;
sum=true;
}
 else if (lastWriteOP == MACS) {
o1=macs;
signMode=true;
sum=true;
}
if (signMode) {
if (((o1 ^ op2) & 0x8000) > 0) {
sumext=0xffff;
}
}
int res=o1 * op2;
if (sum) {
currentSum+=res;
res=currentSum;
}
resHi=(res >> 16) & 0xffff;
resLo=res & 0xffff;
if (DEBUG) System.out.println("String_Node_Str" + res);
break;
}
}

Fixed version (ground truth):
public void write(int address,int data,boolean word,long cycles){
  if (DEBUG) {
    System.out.println("String_Node_Str" + Utils.hex16(address) + "String_Node_Str"+ data+ "String_Node_Str"+ word);
  }
  if (MSP430Constants.DEBUGGING_LEVEL > 0) {
    System.out.println("String_Node_Str" + Integer.toString(address,16) + "String_Node_Str"+ data);
  }
switch (address) {
case MPY:
    mpy=data;
  if (DEBUG)   System.out.println(getName() + "String_Node_Str" + data);
lastWriteOP=address;
break;
case MPYS:
mpys=data;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + data);
lastWriteOP=address;
break;
case MAC:
mac=data;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + data);
lastWriteOP=address;
break;
case MACS:
macs=data;
if (DEBUG) System.out.println(getName() + "String_Node_Str" + data);
lastWriteOP=address;
break;
case RESLO:
resLo=data;
break;
case RESHI:
resHi=data;
break;
case OP2:
if (DEBUG) System.out.println(getName() + "String_Node_Str" + data);
sumext=0;
op2=data;
int o1=mpy;
boolean signMode=false;
boolean sum=false;
if (lastWriteOP == MPYS) {
o1=mpys;
signMode=true;
}
 else if (lastWriteOP == MAC) {
o1=mac;
sum=true;
}
 else if (lastWriteOP == MACS) {
o1=macs;
signMode=true;
sum=true;
}
if (signMode) {
if (((o1 ^ op2) & 0x8000) > 0) {
sumext=0xffff;
}
}
long res=o1 * op2;
System.out.println("String_Node_Str" + o1 + "String_Node_Str"+ op2+ "String_Node_Str"+ res);
if (sum) {
currentSum=(resHi << 16) + resLo;
currentSum+=res;
res=currentSum;
}
resHi=(int)((res >> 16) & 0xffff);
resLo=(int)(res & 0xffff);
if (DEBUG) System.out.println("String_Node_Str" + res);
break;
}
}
Program: 5770
Project: 5770
Buggy source:
public static void main(String[] args) throws Exception {
  ELF elf=readELF(args[0]);
  if (args.length < 2) {
    for (int i=0, n=elf.shnum; i < n; i++) {
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ elf.sections[i]);
      if ("String_Node_Str".equals(elf.sections[i].getSectionName()) || "String_Node_Str".equals(elf.sections[i].getSectionName())) {
        int adr=elf.sections[i].offset;
        System.out.println("String_Node_Str");
        for (int j=0, m=2000; j < m; j++) {
          System.out.print((char)elf.elfData[adr++]);
          if (i % 20 == 19) {
            System.out.println("String_Node_Str");
          }
        }
      }
      System.out.println("String_Node_Str");
    }
  }
  elf.getMap();
  if (args.length > 1) {
    DebugInfo dbg=elf.getDebugInfo(Integer.parseInt(args[1]));
    if (dbg != null) {
      System.out.println("String_Node_Str" + dbg.getFile());
      System.out.println("String_Node_Str" + dbg.getFunction());
      System.out.println("String_Node_Str" + dbg.getLine());
    }
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  ELF elf=readELF(args[0]);
  if (args.length < 2) {
    for (int i=0, n=elf.shnum; i < n; i++) {
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ elf.sections[i]);
      if ("String_Node_Str".equals(elf.sections[i].getSectionName()) || "String_Node_Str".equals(elf.sections[i].getSectionName())) {
        int adr=elf.sections[i].offset;
        System.out.println("String_Node_Str");
        for (int j=0, m=2000; j < m; j++) {
          System.out.print((char)elf.elfData[adr++]);
          if (i % 20 == 19) {
            System.out.println();
          }
        }
      }
      System.out.println();
    }
  }
  elf.getMap();
  if (args.length > 1) {
    DebugInfo dbg=elf.getDebugInfo(Integer.parseInt(args[1]));
    if (dbg != null) {
      System.out.println("String_Node_Str" + dbg.getFile());
      System.out.println("String_Node_Str" + dbg.getFunction());
      System.out.println("String_Node_Str" + dbg.getLine());
    }
  }
}
Program: 5773
Project: 5773
Buggy source:
public void execute(long t){
  System.out.println(getName() + "String_Node_Str");
  if (packetListener != null) {
    int len=memory[RAM_TXFIFO];
    int[] data=new int[len];
    System.arraycopy(memory,RAM_TXFIFO + 1,data,0,len);
    packetListener.transmissionEnded(data);
  }
}

Fixed version (ground truth):
public void execute(long t){
  if (DEBUG)   System.out.println(getName() + "String_Node_Str");
  if (packetListener != null) {
    int len=memory[RAM_TXFIFO];
    int[] data=new int[len];
    System.arraycopy(memory,RAM_TXFIFO + 1,data,0,len);
    packetListener.transmissionEnded(data);
  }
}
Program: 5774
Project: 5774
Buggy source:
private void strobe(int data){
  if (DEBUG)   System.out.println("String_Node_Str" + Utils.hex8(data));
switch (data) {
case REG_SRXON:
    setMode(MODE_RX_ON);
  break;
case REG_SRFOFF:
setMode(MODE_TXRX_OFF);
break;
case REG_STXON:
setMode(MODE_TXRX_ON);
transmitPacket();
break;
case REG_STXONCCA:
setMode(MODE_TXRX_ON);
transmitPacket();
break;
case REG_SFLUSHRX:
flushRX();
break;
case REG_SFLUSHTX:
flushTX();
break;
}
}

Fixed version (ground truth):
private void strobe(int data){
  if (DEBUG)   System.out.println("String_Node_Str" + Utils.hex8(data));
switch (data) {
case REG_SRXON:
    if (DEBUG)     System.out.println("String_Node_Str");
  setMode(MODE_RX_ON);
break;
case REG_SRFOFF:
if (DEBUG) System.out.println("String_Node_Str");
setMode(MODE_TXRX_OFF);
break;
case REG_STXON:
if (DEBUG) System.out.println("String_Node_Str");
setMode(MODE_TXRX_ON);
transmitPacket();
break;
case REG_STXONCCA:
if (DEBUG) System.out.println("String_Node_Str");
setMode(MODE_TXRX_ON);
transmitPacket();
break;
case REG_SFLUSHRX:
flushRX();
break;
case REG_SFLUSHTX:
flushTX();
break;
}
}
Program: 5775
Project: 5775
Buggy source:
public void setChipSelect(boolean select){
  chipSelect=select;
  if (!chipSelect)   state=WAITING;
}

Fixed version (ground truth):
public void setChipSelect(boolean select){
  chipSelect=select;
  if (!chipSelect)   state=WAITING;
  if (DEBUG)   System.out.println("String_Node_Str" + chipSelect);
}
Program: 5776
Project: 5776
Buggy source:
private void transmitPacket(){
  int len=memory[RAM_TXFIFO];
  int kBps=250000 / 8;
  double time=1.0 * len / kBps;
  System.out.println(getName() + "String_Node_Str" + len+ "String_Node_Str"+ time+ "String_Node_Str");
  if (packetListener != null) {
    packetListener.transmissionStarted();
    cpu.scheduleTimeEventMillis(transmissionEvent,1000 * time);
  }
}

Fixed version (ground truth):
private void transmitPacket(){
  int len=memory[RAM_TXFIFO];
  int kBps=250000 / 8;
  double time=1.0 * len / kBps;
  if (DEBUG)   System.out.println(getName() + "String_Node_Str" + len+ "String_Node_Str"+ time+ "String_Node_Str");
  if (packetListener != null) {
    packetListener.transmissionStarted();
    cpu.scheduleTimeEventMillis(transmissionEvent,1000 * time);
  }
}
Program: 5778
Project: 5778
Buggy source:
public void portWrite(IOPort source,int data){
  if (source == port5) {
    redLed=(data & RED_LED) == 0;
    blueLed=(data & BLUE_LED) == 0;
    greenLed=(data & GREEN_LED) == 0;
    int newMode=(redLed ? 1 : 0) + (greenLed ? 1 : 0) + (blueLed ? 1 : 0);
    if (mode != newMode) {
      mode=newMode;
      modeChanged(mode);
    }
    if (gui != null) {
      gui.repaint();
    }
  }
 else   if (source == port4) {
    radio.setChipSelect((data & CC2420_CHIP_SELECT) == 0);
    flash.portWrite(source,data);
  }
}

Fixed version (ground truth):
public void portWrite(IOPort source,int data){
  if (source == port5) {
    redLed=(data & RED_LED) == 0;
    blueLed=(data & BLUE_LED) == 0;
    greenLed=(data & GREEN_LED) == 0;
    int newMode=(redLed ? 1 : 0) + (greenLed ? 1 : 0) + (blueLed ? 1 : 0);
    if (mode != newMode) {
      mode=newMode;
      modeChanged(mode);
    }
    if (gui != null) {
      gui.repaint();
    }
  }
 else   if (source == port4) {
    radio.setChipSelect((data & CC2420_CHIP_SELECT) == 0);
    radio.setVRegOn((data & CC2420_VREG) != 0);
    flash.portWrite(source,data);
  }
}
Program: 5779
Project: 5779
Buggy source:
private void sectorErase(int address){
  int sectorAddress=address & 0xf0000;
  for (int i=0; i < buffer.length; i++) {
    buffer[i]=(byte)0xff;
  }
  blockWriteAddress=sectorAddress;
  for (int i=0; i < 0x100; i++) {
    if (DEBUG)     System.out.println("String_Node_Str" + Integer.toHexString(blockWriteAddress));
    writeBack(blockWriteAddress,buffer);
    blockWriteAddress+=0x100;
  }
}

Fixed version (ground truth):
private void sectorErase(int address){
  int sectorAddress=address & 0xf0000;
  loadedAddress=-1;
  for (int i=0; i < buffer.length; i++) {
    buffer[i]=(byte)0xff;
  }
  blockWriteAddress=sectorAddress;
  for (int i=0; i < 0x100; i++) {
    if (DEBUG)     System.out.println("String_Node_Str" + Integer.toHexString(blockWriteAddress));
    writeBack(blockWriteAddress,buffer);
    blockWriteAddress+=0x100;
  }
}
Program: 5780
Project: 5780
Buggy source:
private void ensureLoaded(int address){
  if (!((loadedAddress & 0xfff00) == (address & 0xfff00))) {
    try {
      if (DEBUG)       System.out.println("String_Node_Str" + (address & 0xfff00));
      file.seek(address & 0xfff00);
      file.readFully(readMemory);
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    loadedAddress=address & 0xfff00;
  }
}

Fixed version (ground truth):
private void ensureLoaded(int address){
  if (loadedAddress < 0 || ((loadedAddress & 0xfff00) != (address & 0xfff00))) {
    try {
      if (DEBUG)       System.out.println("String_Node_Str" + (address & 0xfff00));
      file.seek(address & 0xfff00);
      file.readFully(readMemory);
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    loadedAddress=address & 0xfff00;
  }
}
Program: 5781
Project: 5781
Buggy source:
public long getTime(){
  long diff=cycles - lastTime;
  currentTime+=(long)(diff * currentDCOFactor);
  return 0;
}

Fixed version (ground truth):
public long getTime(){
  long diff=cycles - lastTime;
  currentTime+=(long)(diff * currentDCOFactor);
  return currentTime;
}
Program: 5782
Project: 5782
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(type == TIMER_A ? TACCR0_VECTOR : TBCCR0_VECTOR,this,trigger);
      if (trigger) {
        lastTIV=memory[type == TIMER_A ? TAIV : TBIV]=0;
        trigger=false;
      }
    }
 else {
      if (newTrigger) {
        if (DEBUG) {
          System.out.println(getName() + "String_Node_Str" + (i * 2));
        }
        tIndex=i;
      }
    }
  }
  core.flagInterrupt(type == TIMER_A ? TACCR1_VECTOR : TBCCR1_VECTOR,this,trigger);
  if (trigger) {
    lastTIV=memory[type == TIMER_A ? TAIV : TBIV]=tIndex * 2;
  }
}

Fixed version (ground truth):
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(type == TIMER_A ? TACCR0_VECTOR : TBCCR0_VECTOR,this,trigger);
      if (trigger) {
        lastTIV=memory[type == TIMER_A ? TAIV : TBIV]=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(type == TIMER_A ? TACCR1_VECTOR : TBCCR1_VECTOR,this,trigger);
}
Program: 5783
Project: 5783
Buggy source:
public int read(int address,boolean word,long cycles){
  int val=memory[address];
  if (word) {
    val|=memory[(address + 1) & 0xffff] << 8;
  }
  if (address == TAIV || address == TBIV) {
    resetTIV();
  }
  if (address != 0x166) {
    if (DEBUG && false) {
      System.out.println("String_Node_Str" + Utils.hex16(address) + "String_Node_Str"+ Utils.hex16(memory[address] + (memory[address + 1] << 8))+ "String_Node_Str"+ (memory[address] + (memory[address + 1] << 8))+ "String_Node_Str");
    }
  }
  int index=address - offset;
switch (index) {
case TR:
    return updateCounter(cycles);
case TCCTL0:
case TCCTL1:
case TCCTL2:
case TCCTL3:
case TCCTL4:
case TCCTL5:
case TCCTL6:
  int i=(index - TCCTL0) / 2;
return tcctl[i];
case TCCR0:
case TCCR1:
case TCCR2:
case TCCR3:
case TCCR4:
case TCCR5:
case TCCR6:
i=(index - TCCR0) / 2;
return tccr[i];
}
return val;
}

Fixed version (ground truth):
public int read(int address,boolean word,long cycles){
  int val=memory[address];
  if (word) {
    val|=memory[(address + 1) & 0xffff] << 8;
  }
  if (address == TAIV || address == TBIV) {
    resetTIV();
  }
  int index=address - offset;
switch (index) {
case TR:
    val=updateCounter(cycles);
  break;
case TCTL:
val=tctl;
if (interruptPending) {
val|=1;
}
 else {
val&=0xfffe;
}
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;
}
if (DEBUG) {
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;
}