Program: 150201
Project: 150201
Buggy source:
/** 
 * Expand a checkcast instruction into the LIR sequence that implements the  dynamic type check, raising a ClassCastException when the type check  fails. Ref may contain a null ptr at runtime.
 * @param s a CHECKCAST or CHECKCAST_UNRESOLVED instruction to expand 
 * @param ir the enclosing OPT_IR
 * @return the last OPT_Instruction in the generated LIR sequence.
 */
static OPT_Instruction checkcast(OPT_Instruction s,OPT_IR ir){
  OPT_Operand ref=TypeCheck.getClearRef(s);
  VM_TypeReference LHStype=TypeCheck.getType(s).getTypeRef();
  OPT_RegisterOperand guard=ir.regpool.makeTempValidation();
  OPT_Instruction nullCond=IfCmp.create(REF_IFCMP,guard,ref.copy(),new OPT_NullConstantOperand(),OPT_ConditionOperand.EQUAL(),null,new OPT_BranchProfileOperand());
  s.insertBefore(nullCond);
  OPT_BasicBlock myBlock=s.getBasicBlock();
  OPT_BasicBlock failBlock=myBlock.createSubBlock(s.bcIndex,ir,.0001f);
  OPT_BasicBlock instanceOfBlock=myBlock.splitNodeAt(nullCond,ir);
  OPT_BasicBlock succBlock=instanceOfBlock.splitNodeAt(s,ir);
  IfCmp.setTarget(nullCond,succBlock.makeJumpTarget());
  myBlock.insertOut(instanceOfBlock);
  myBlock.insertOut(succBlock);
  instanceOfBlock.insertOut(failBlock);
  instanceOfBlock.insertOut(succBlock);
  ir.cfg.linkInCodeOrder(myBlock,instanceOfBlock);
  ir.cfg.linkInCodeOrder(instanceOfBlock,succBlock);
  ir.cfg.addLastInCodeOrder(failBlock);
  OPT_Instruction raiseError=Trap.create(TRAP,null,OPT_TrapCodeOperand.CheckCast());
  raiseError.copyPosition(s);
  failBlock.appendInstruction(raiseError);
  OPT_RegisterOperand RHStib=getTIB(s,ir,ref,guard.copyD2U());
  return generateBranchingTypeCheck(s,ir,ref,LHStype,RHStib,succBlock,failBlock,null);
}

Fixed version (ground truth):
/** 
 * Expand a checkcast instruction into the LIR sequence that implements the  dynamic type check, raising a ClassCastException when the type check  fails. Ref may contain a null ptr at runtime.
 * @param s a CHECKCAST or CHECKCAST_UNRESOLVED instruction to expand 
 * @param ir the enclosing OPT_IR
 * @return the last OPT_Instruction in the generated LIR sequence.
 */
static OPT_Instruction checkcast(OPT_Instruction s,OPT_IR ir){
  OPT_Operand ref=TypeCheck.getClearRef(s);
  VM_TypeReference LHStype=TypeCheck.getType(s).getTypeRef();
  OPT_RegisterOperand guard=ir.regpool.makeTempValidation();
  OPT_Instruction nullCond=IfCmp.create(REF_IFCMP,guard,ref.copy(),new OPT_NullConstantOperand(),OPT_ConditionOperand.EQUAL(),null,new OPT_BranchProfileOperand());
  s.insertBefore(nullCond);
  OPT_BasicBlock myBlock=s.getBasicBlock();
  OPT_BasicBlock failBlock=myBlock.createSubBlock(s.bcIndex,ir,.0001f);
  OPT_BasicBlock instanceOfBlock=myBlock.splitNodeAt(nullCond,ir);
  OPT_BasicBlock succBlock=instanceOfBlock.splitNodeAt(s,ir);
  IfCmp.setTarget(nullCond,succBlock.makeJumpTarget());
  myBlock.insertOut(instanceOfBlock);
  myBlock.insertOut(succBlock);
  instanceOfBlock.insertOut(failBlock);
  instanceOfBlock.insertOut(succBlock);
  ir.cfg.linkInCodeOrder(myBlock,instanceOfBlock);
  ir.cfg.linkInCodeOrder(instanceOfBlock,succBlock);
  ir.cfg.addLastInCodeOrder(failBlock);
  OPT_Instruction raiseError=Trap.create(TRAP,null,OPT_TrapCodeOperand.CheckCast());
  raiseError.copyPosition(s);
  failBlock.appendInstruction(raiseError);
  OPT_RegisterOperand RHStib=getTIB(s,ir,ref,guard.copyD2U());
  return generateBranchingTypeCheck(s,ir,ref,LHStype,RHStib,succBlock,failBlock,null,OPT_BranchProfileOperand.never());
}