Program: 150217
Project: 150217
Buggy source:
private void commutative(OPT_Instruction s,OPT_Operator opCode,OPT_IR ir){
  OPT_RegisterOperand result=Binary.getClearResult(s);
  OPT_Operand op1=Binary.getClearVal1(s);
  OPT_Operand op2=Binary.getClearVal2(s);
  if (result.similar(op1)) {
    OPT_DefUse.removeUse(op1.asRegister());
    OPT_DefUse.removeDef(result);
    OPT_DefUse.recordDefUse(result);
    BinaryAcc.mutate(s,opCode,result,op2);
    return;
  }
  if (result.similar(op2)) {
    OPT_DefUse.removeUse(op2.asRegister());
    OPT_DefUse.removeDef(result);
    OPT_DefUse.recordDefUse(result);
    BinaryAcc.mutate(s,opCode,result,op1);
    return;
  }
  if (OPTIMIZE) {
    if (op1.isRegister()) {
      OPT_RegisterOperand rop1=op1.asRegister();
      if (!rop1.register.spansBasicBlock() && isDead(rop1.register)) {
        if (result.register.isSSA() && !result.register.spansBasicBlock()) {
          OPT_DefUse.removeDef(result);
          OPT_DefUse.removeUse(rop1);
          OPT_DefUse.recordDefUse(rop1);
          OPT_DefUse.mergeRegisters(ir,rop1.register,result.register);
          rop1.register.putSSA(false);
          BinaryAcc.mutate(s,opCode,rop1,op2);
          return;
        }
 else {
          OPT_DefUse.removeDef(result);
          OPT_DefUse.removeUse(rop1);
          OPT_DefUse.recordDefUse(rop1);
          BinaryAcc.mutate(s,opCode,rop1,op2);
          OPT_Instruction move=Move.create(getMoveOp(result.type),result,rop1.copy());
          OPT_DefUse.updateDUForNewInstruction(move);
          s.insertAfter(move);
          return;
        }
      }
    }
    if (op2.isRegister()) {
      OPT_RegisterOperand rop2=op2.asRegister();
      if (!rop2.register.spansBasicBlock() && isDead(rop2.register)) {
        if (result.register.isSSA() && !result.register.spansBasicBlock()) {
          OPT_DefUse.removeUse(rop2);
          OPT_DefUse.removeDef(result);
          OPT_DefUse.recordDefUse(rop2);
          OPT_DefUse.mergeRegisters(ir,rop2.register,result.register);
          rop2.register.putSSA(false);
          BinaryAcc.mutate(s,opCode,rop2,op1);
          return;
        }
 else {
          OPT_DefUse.removeDef(result);
          OPT_DefUse.removeUse(rop2);
          OPT_DefUse.recordDefUse(rop2);
          BinaryAcc.mutate(s,opCode,rop2,op1);
          OPT_Instruction move=Move.create(getMoveOp(result.type),result,rop2.copy());
          OPT_DefUse.updateDUForNewInstruction(move);
          s.insertAfter(move);
          return;
        }
      }
    }
  }
  OPT_Instruction move=Move.create(getMoveOp(result.type),result.copyRO(),op1.copy());
  OPT_DefUse.updateDUForNewInstruction(move);
  s.insertBefore(move);
  OPT_DefUse.removeDef(result);
  OPT_DefUse.recordDefUse(result);
  if (op1.isRegister()) {
    OPT_DefUse.removeUse(op1.asRegister());
  }
  BinaryAcc.mutate(s,opCode,result,op2);
}

Fixed version (ground truth):
private void commutative(OPT_Instruction s,OPT_Operator opCode,OPT_IR ir){
  OPT_RegisterOperand result=Binary.getClearResult(s);
  OPT_Operand op1=Binary.getClearVal1(s);
  OPT_Operand op2=Binary.getClearVal2(s);
  if (result.similar(op1)) {
    OPT_DefUse.removeUse(op1.asRegister());
    OPT_DefUse.removeDef(result);
    OPT_DefUse.recordDefUse(result);
    BinaryAcc.mutate(s,opCode,result,op2);
    return;
  }
  if (result.similar(op2)) {
    OPT_DefUse.removeUse(op2.asRegister());
    OPT_DefUse.removeDef(result);
    OPT_DefUse.recordDefUse(result);
    BinaryAcc.mutate(s,opCode,result,op1);
    return;
  }
  if (OPTIMIZE) {
    if (op1.isRegister()) {
      OPT_RegisterOperand rop1=op1.asRegister();
      if (!rop1.register.spansBasicBlock() && isDead(rop1.register)) {
        if (result.register.isSSA() && !result.register.spansBasicBlock() && rop1.register.isSSA()) {
          OPT_DefUse.removeDef(result);
          OPT_DefUse.removeUse(rop1);
          OPT_DefUse.recordDefUse(rop1);
          OPT_DefUse.mergeRegisters(ir,rop1.register,result.register);
          rop1.register.putSSA(false);
          BinaryAcc.mutate(s,opCode,rop1,op2);
          return;
        }
 else {
          OPT_DefUse.removeDef(result);
          OPT_DefUse.removeUse(rop1);
          OPT_DefUse.recordDefUse(rop1);
          BinaryAcc.mutate(s,opCode,rop1,op2);
          OPT_Instruction move=Move.create(getMoveOp(result.type),result,rop1.copy());
          OPT_DefUse.updateDUForNewInstruction(move);
          s.insertAfter(move);
          return;
        }
      }
    }
    if (op2.isRegister()) {
      OPT_RegisterOperand rop2=op2.asRegister();
      if (!rop2.register.spansBasicBlock() && isDead(rop2.register)) {
        if (result.register.isSSA() && !result.register.spansBasicBlock() && rop2.register.isSSA()) {
          OPT_DefUse.removeUse(rop2);
          OPT_DefUse.removeDef(result);
          OPT_DefUse.recordDefUse(rop2);
          OPT_DefUse.mergeRegisters(ir,rop2.register,result.register);
          rop2.register.putSSA(false);
          BinaryAcc.mutate(s,opCode,rop2,op1);
          return;
        }
 else {
          OPT_DefUse.removeDef(result);
          OPT_DefUse.removeUse(rop2);
          OPT_DefUse.recordDefUse(rop2);
          BinaryAcc.mutate(s,opCode,rop2,op1);
          OPT_Instruction move=Move.create(getMoveOp(result.type),result,rop2.copy());
          OPT_DefUse.updateDUForNewInstruction(move);
          s.insertAfter(move);
          return;
        }
      }
    }
  }
  OPT_Instruction move=Move.create(getMoveOp(result.type),result.copyRO(),op1.copy());
  OPT_DefUse.updateDUForNewInstruction(move);
  s.insertBefore(move);
  OPT_DefUse.removeDef(result);
  OPT_DefUse.recordDefUse(result);
  if (op1.isRegister()) {
    OPT_DefUse.removeUse(op1.asRegister());
  }
  BinaryAcc.mutate(s,opCode,result,op2);
}