Program: 150215
Project: 150215
Buggy source:
private void noncommutative(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 (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.removeUse(rop1);
          OPT_DefUse.removeDef(result);
          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 (result.similar(op2)) {
    OPT_RegisterOperand tmp=ir.regpool.makeTemp(op1);
    OPT_Instruction move=Move.create(getMoveOp(tmp.type),tmp.copyRO(),op1.copy());
    s.insertBefore(move);
    OPT_DefUse.updateDUForNewInstruction(move);
    OPT_DefUse.removeDef(result);
    OPT_DefUse.recordDefUse(tmp);
    if (op1.isRegister()) {
      OPT_DefUse.removeUse(op1.asRegister());
    }
    BinaryAcc.mutate(s,opCode,tmp,op2);
    move=Move.create(getMoveOp(tmp.type),result.copyRO(),tmp.copyRO());
    s.insertAfter(move);
    OPT_DefUse.updateDUForNewInstruction(move);
  }
 else {
    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 noncommutative(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 (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.removeUse(rop1);
          OPT_DefUse.removeDef(result);
          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 (result.similar(op2)) {
    OPT_RegisterOperand tmp=ir.regpool.makeTemp(op1);
    OPT_Instruction move=Move.create(getMoveOp(tmp.type),tmp.copyRO(),op1.copy());
    s.insertBefore(move);
    OPT_DefUse.updateDUForNewInstruction(move);
    OPT_DefUse.removeDef(result);
    OPT_DefUse.recordDefUse(tmp);
    if (op1.isRegister()) {
      OPT_DefUse.removeUse(op1.asRegister());
    }
    BinaryAcc.mutate(s,opCode,tmp,op2);
    move=Move.create(getMoveOp(tmp.type),result.copyRO(),tmp.copyRO());
    s.insertAfter(move);
    OPT_DefUse.updateDUForNewInstruction(move);
  }
 else {
    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);
  }
}