Program: 85338
Project: 85338
Buggy source:
/** 
 * Creates an intermediate jump instruction between the original jump instruction and its target
 * @param targetInsPos The jump target index
 * @param jumpInsPos The position of the jump instruction
 * @param stmtV The statement visitor used for constructing the instructions
 * @param instructions The list of Dalvik instructions
 * @param labelAssigner The label assigner to be used for creating new labels
 */
private void insertIntermediateJump(int targetInsPos,int jumpInsPos,StmtVisitor stmtV,List<BuilderInstruction> instructions,LabelAssigner labelAssigner){
  BuilderInstruction originalJumpInstruction=instructions.get(jumpInsPos);
  Insn originalJumpInsn=stmtV.getInsnForInstruction(originalJumpInstruction);
  if (originalJumpInsn == null)   return;
  if (!(originalJumpInsn instanceof InsnWithOffset))   throw new RuntimeException("String_Node_Str");
  InsnWithOffset offsetInsn=(InsnWithOffset)originalJumpInsn;
  int distance=Math.max(targetInsPos,jumpInsPos) - Math.min(targetInsPos,jumpInsPos);
  if (distance == 0)   return;
  int newJumpIdx=Math.min(targetInsPos,jumpInsPos) + (distance / 2);
  int sign=(int)Math.signum(targetInsPos - jumpInsPos);
  if (distance > offsetInsn.getMaxJumpOffset())   newJumpIdx=jumpInsPos + sign;
  while (stmtV.getStmtForInstruction(instructions.get(newJumpIdx)) == null) {
    newJumpIdx+=sign;
    if (newJumpIdx < 0 || newJumpIdx >= instructions.size())     throw new RuntimeException("String_Node_Str" + "String_Node_Str");
  }
  NopStmt nop=Jimple.v().newNopStmt();
  Insn30t newJump=new Insn30t(Opcode.GOTO_32);
  newJump.setTarget(stmtV.getStmtForInstruction(instructions.get(targetInsPos)));
  BuilderInstruction newJumpInstruction=newJump.getRealInsn(labelAssigner);
  instructions.add(newJumpIdx,newJumpInstruction);
  stmtV.fakeNewInsn(nop,newJump,newJumpInstruction);
  if (newJumpIdx < jumpInsPos)   jumpInsPos++;
  if (newJumpIdx < targetInsPos)   targetInsPos++;
  offsetInsn.setTarget(nop);
  BuilderInstruction replacementJumpInstruction=offsetInsn.getRealInsn(labelAssigner);
  instructions.add(jumpInsPos,replacementJumpInstruction);
  instructions.remove(originalJumpInstruction);
  stmtV.fakeNewInsn(stmtV.getStmtForInstruction(originalJumpInstruction),originalJumpInsn,replacementJumpInstruction);
  Stmt afterNewJump=stmtV.getStmtForInstruction(instructions.get(newJumpIdx + 1));
  Insn10t jumpAround=new Insn10t(Opcode.GOTO);
  jumpAround.setTarget(afterNewJump);
  BuilderInstruction jumpAroundInstruction=jumpAround.getRealInsn(labelAssigner);
  instructions.add(newJumpIdx,jumpAroundInstruction);
}

Fixed version (ground truth):
/** 
 * Creates an intermediate jump instruction between the original jump instruction and its target
 * @param targetInsPos The jump target index
 * @param jumpInsPos The position of the jump instruction
 * @param stmtV The statement visitor used for constructing the instructions
 * @param instructions The list of Dalvik instructions
 * @param labelAssigner The label assigner to be used for creating new labels
 */
private void insertIntermediateJump(int targetInsPos,int jumpInsPos,StmtVisitor stmtV,List<BuilderInstruction> instructions,LabelAssigner labelAssigner){
}