Program: 186751
Project: 186751
Buggy source:
/** 
 * Check if the invokesite can be modified in a way so that the parameters are passed in the correct order
 * @param invokeSite the invokesite to inline.
 * @param invokee the invoked method.
 * @param invokeMap the map to store the analyzer results
 * @return true if the prologue can be changed to match the expected behaviour
 */
private boolean analyzeInvokeSite(InvokeSite invokeSite,MethodInfo invokee,InvokeMap invokeMap){
  MethodInfo invoker=invokeSite.getInvoker();
  ConstantPoolGen invokerCpg=invoker.getConstantPoolGen();
  ConstantPoolGen invokeeCpg=invokee.getConstantPoolGen();
  InstructionHandle invoke=invokeSite.getInstructionHandle();
  Type[] ret=StackHelper.produceStack(invokerCpg,invoke.getInstruction());
  boolean match=(ret.length == 1 && TypeHelper.canAssign(invokee.getType(),ret[0]));
  if (!match && !invokee.getType().equals(Type.VOID)) {
    return false;
  }
  Type[] args=StackHelper.consumeStack(invokerCpg,invoke.getInstruction());
  List<Instruction> oldPrologue=new LinkedList<Instruction>();
  int cnt=0;
  InstructionHandle current=invoke;
  while (cnt < args.length) {
    if (current.hasTargeters()) {
      break;
    }
    current=current.getPrev();
    Instruction instr=current.getInstruction();
    if (!(instr instanceof PushInstruction) || (instr instanceof DUP) || (instr instanceof DUP2)) {
      break;
    }
    cnt++;
    oldPrologue.add(0,instr);
  }
  int offset=args.length - cnt;
  for (int i=0; i < offset; i++) {
    ValueInfo value=invokeMap.getParams().get(i);
    if (!value.isParamReference() || value.getParamNr() != i) {
      return false;
    }
  }
  invokeMap.setOldPrologueLength(cnt);
  for (int i=offset; i < invokeMap.getParams().size(); i++) {
    ValueInfo value=invokeMap.getParams().get(i);
    if (value.isThisReference() || value.isParamReference()) {
      int argNum=value.getParamNr();
      if (!invokee.isStatic()) {
        argNum++;
      }
      if (argNum < offset) {
        return false;
      }
      Instruction instr=oldPrologue.get(argNum - offset).copy();
      invokeMap.addPrologue(instr);
    }
 else     if (value.isConstantValue()) {
      Instruction instr=value.getConstantValue().createPushInstruction(invoker.getConstantPoolGen());
      invokeMap.addPrologue(instr);
    }
 else     if (!value.isContinued()) {
      throw new AssertionError("String_Node_Str");
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Check if the invokesite can be modified in a way so that the parameters are passed in the correct order
 * @param invokeSite the invokesite to inline.
 * @param invokee the invoked method.
 * @param invokeMap the map to store the analyzer results
 * @return true if the prologue can be changed to match the expected behaviour
 */
private boolean analyzeInvokeSite(InvokeSite invokeSite,MethodInfo invokee,InvokeMap invokeMap){
  MethodInfo invoker=invokeSite.getInvoker();
  ConstantPoolGen invokerCpg=invoker.getConstantPoolGen();
  InstructionHandle invoke=invokeSite.getInstructionHandle();
  Type[] ret=StackHelper.produceStack(invokerCpg,invoke.getInstruction());
  boolean match=(ret.length == 1 && TypeHelper.canAssign(invokee.getType(),ret[0]));
  if (!match && !invokee.getType().equals(Type.VOID)) {
    return false;
  }
  Type[] args=StackHelper.consumeStack(invokerCpg,invoke.getInstruction());
  List<Instruction> oldPrologue=new LinkedList<Instruction>();
  int cnt=0;
  InstructionHandle current=invoke;
  while (cnt < args.length) {
    if (current.hasTargeters()) {
      break;
    }
    current=current.getPrev();
    Instruction instr=current.getInstruction();
    if (!(instr instanceof PushInstruction) || (instr instanceof DUP) || (instr instanceof DUP2)) {
      break;
    }
    cnt++;
    oldPrologue.add(0,instr);
  }
  invokeMap.setOldPrologueLength(cnt);
  List<ValueInfo> params=invokeMap.getParams();
  int offset=args.length - cnt;
  for (int i=0; i < offset; i++) {
    if (i >= params.size()) {
      Type t=args[i];
      invokeMap.addPrologue(t.getSize() == 2 ? new POP2() : new POP());
    }
 else {
      ValueInfo value=params.get(i);
      int argNum=value.getParamNr();
      if (invokee.isStatic()) {
        argNum++;
      }
      if (argNum != i) {
        return false;
      }
    }
  }
  for (int i=offset; i < params.size(); i++) {
    ValueInfo value=params.get(i);
    if (value.isThisReference() || value.isParamReference()) {
      int argNum=value.getParamNr();
      if (!invokee.isStatic()) {
        argNum++;
      }
      if (argNum < offset) {
        return false;
      }
      Instruction instr=oldPrologue.get(argNum - offset).copy();
      invokeMap.addPrologue(instr);
    }
 else     if (value.isConstantValue() || value.isStaticFieldReference()) {
      Instruction instr=value.getConstantValue().createPushInstruction(invoker.getConstantPoolGen());
      invokeMap.addPrologue(instr);
    }
 else     if (!value.isContinued()) {
      throw new AssertionError("String_Node_Str");
    }
  }
  return true;
}