Program: 85185
Project: 85185
Buggy source:
/** 
 * Return the jimple equivalent of this body.
 * @param m the SootMethod that contains this body
 */
public Body jimplify(Body b,SootMethod m){
  final Jimple jimple=Jimple.v();
  final UnknownType unknownType=UnknownType.v();
  final NullConstant nullConstant=NullConstant.v();
  final Options options=Options.v();
  jBody=(JimpleBody)b;
  deferredInstructions=new ArrayList<DeferableInstruction>();
  instructionsToRetype=new HashSet<RetypeableInstruction>();
  if (IDalvikTyper.ENABLE_DVKTYPER) {
    DalvikTyper.v().clear();
  }
  List<Local> paramLocals=new LinkedList<Local>();
  if (!isStatic) {
    int thisRegister=numRegisters - numParameterRegisters - 1;
    Local thisLocal=jimple.newLocal("String_Node_Str" + thisRegister,unknownType);
    jBody.getLocals().add(thisLocal);
    registerLocals[thisRegister]=thisLocal;
    JIdentityStmt idStmt=(JIdentityStmt)jimple.newIdentityStmt(thisLocal,jimple.newThisRef(declaringClassType));
    add(idStmt);
    paramLocals.add(thisLocal);
    if (IDalvikTyper.ENABLE_DVKTYPER) {
      DalvikTyper.v().setType(idStmt.leftBox,jBody.getMethod().getDeclaringClass().getType(),false);
    }
  }
{
    int i=0;
    int parameterRegister=numRegisters - numParameterRegisters;
    for (    Type t : parameterTypes) {
      Local gen=jimple.newLocal("String_Node_Str" + parameterRegister,unknownType);
      jBody.getLocals().add(gen);
      registerLocals[parameterRegister]=gen;
      JIdentityStmt idStmt=(JIdentityStmt)jimple.newIdentityStmt(gen,jimple.newParameterRef(t,i++));
      add(idStmt);
      paramLocals.add(gen);
      if (IDalvikTyper.ENABLE_DVKTYPER) {
        DalvikTyper.v().setType(idStmt.leftBox,t,false);
      }
      if (t instanceof LongType || t instanceof DoubleType) {
        parameterRegister++;
        Local g=jimple.newLocal("String_Node_Str" + parameterRegister,unknownType);
        jBody.getLocals().add(g);
        registerLocals[parameterRegister]=g;
      }
      parameterRegister++;
    }
  }
  for (int i=0; i < (numRegisters - numParameterRegisters - (isStatic ? 0 : 1)); i++) {
    registerLocals[i]=jimple.newLocal("String_Node_Str" + i,unknownType);
    jBody.getLocals().add(registerLocals[i]);
  }
  storeResultLocal=jimple.newLocal("String_Node_Str",unknownType);
  jBody.getLocals().add(storeResultLocal);
  final boolean isOdex=dexFile instanceof DexBackedDexFile ? ((DexBackedDexFile)dexFile).isOdexFile() : false;
  ClassPath cp=null;
  if (isOdex) {
    String[] sootClasspath=options.soot_classpath().split(File.pathSeparator);
    List<String> classpathList=new ArrayList<String>();
    for (    String str : sootClasspath) {
      classpathList.add(str);
    }
    try {
      ClassPathResolver resolver=new ClassPathResolver(classpathList,classpathList,classpathList,dexFile);
      cp=new ClassPath(resolver.getResolvedClassProviders().toArray(new ClassProvider[0]));
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
  int prevLineNumber=-1;
  for (  DexlibAbstractInstruction instruction : instructions) {
    if (isOdex && instruction instanceof OdexInstruction) {
      ((OdexInstruction)instruction).deOdex(dexFile,method,cp);
    }
    if (dangling != null) {
      dangling.finalize(this,instruction);
      dangling=null;
    }
    instruction.jimplify(this);
    if (instruction.getLineNumber() > 0) {
      prevLineNumber=instruction.getLineNumber();
    }
 else {
      instruction.setLineNumber(prevLineNumber);
    }
  }
  for (  DeferableInstruction instruction : deferredInstructions) {
    instruction.deferredJimplify(this);
  }
  if (tries != null) {
    addTraps();
  }
  if (options.keep_line_number()) {
    fixLineNumbers();
  }
  instructions=null;
  instructionAtAddress.clear();
  deferredInstructions=null;
  dangling=null;
  tries=null;
  DexTrapStackFixer.v().transform(jBody);
  DexJumpChainShortener.v().transform(jBody);
  DexReturnInliner.v().transform(jBody);
  DexArrayInitReducer.v().transform(jBody);
  getLocalSplitter().transform(jBody);
  getUnreachableCodeEliminator().transform(jBody);
  DeadAssignmentEliminator.v().transform(jBody);
  UnusedLocalEliminator.v().transform(jBody);
  for (  RetypeableInstruction i : instructionsToRetype) {
    i.retype(jBody);
  }
  if (IDalvikTyper.ENABLE_DVKTYPER) {
    DexReturnValuePropagator.v().transform(jBody);
    getCopyPopagator().transform(jBody);
    DexNullThrowTransformer.v().transform(jBody);
    DalvikTyper.v().typeUntypedConstrantInDiv(jBody);
    DeadAssignmentEliminator.v().transform(jBody);
    UnusedLocalEliminator.v().transform(jBody);
    DalvikTyper.v().assignType(jBody);
    jBody.validateUses();
    jBody.validateValueBoxes();
  }
 else {
    DexNumTransformer.v().transform(jBody);
    DexReturnValuePropagator.v().transform(jBody);
    getCopyPopagator().transform(jBody);
    DexNullThrowTransformer.v().transform(jBody);
    DexNullTransformer.v().transform(jBody);
    DexIfTransformer.v().transform(jBody);
    DeadAssignmentEliminator.v().transform(jBody);
    UnusedLocalEliminator.v().transform(jBody);
    DexNullArrayRefTransformer.v().transform(jBody);
  }
  if (IDalvikTyper.ENABLE_DVKTYPER) {
    for (    Local l : jBody.getLocals()) {
      l.setType(unknownType);
    }
  }
  DexNullInstanceofTransformer.v().transform(jBody);
  TypeAssigner.v().transform(jBody);
  final RefType objectType=RefType.v("String_Node_Str");
  if (IDalvikTyper.ENABLE_DVKTYPER) {
    for (    Unit u : jBody.getUnits()) {
      if (u instanceof IfStmt) {
        ConditionExpr expr=(ConditionExpr)((IfStmt)u).getCondition();
        if (((expr instanceof EqExpr) || (expr instanceof NeExpr))) {
          Value op1=expr.getOp1();
          Value op2=expr.getOp2();
          if (op1 instanceof Constant && op2 instanceof Local) {
            Local l=(Local)op2;
            Type ltype=l.getType();
            if (ltype instanceof PrimType) {
              continue;
            }
            if (!(op1 instanceof IntConstant)) {
              continue;
            }
            IntConstant icst=(IntConstant)op1;
            int val=icst.value;
            if (val != 0) {
              continue;
            }
            expr.setOp1(nullConstant);
          }
 else           if (op1 instanceof Local && op2 instanceof Constant) {
            Local l=(Local)op1;
            Type ltype=l.getType();
            if (ltype instanceof PrimType) {
              continue;
            }
            if (!(op2 instanceof IntConstant)) {
              continue;
            }
            IntConstant icst=(IntConstant)op2;
            int val=icst.value;
            if (val != 0) {
              continue;
            }
            expr.setOp2(nullConstant);
          }
 else           if (op1 instanceof Local && op2 instanceof Local) {
          }
 else           if (op1 instanceof Constant && op2 instanceof Constant) {
            if (op1 instanceof NullConstant && op2 instanceof NumericConstant) {
              IntConstant nc=(IntConstant)op2;
              if (nc.value != 0) {
                throw new RuntimeException("String_Node_Str" + expr);
              }
              expr.setOp2(NullConstant.v());
            }
 else             if (op2 instanceof NullConstant && op1 instanceof NumericConstant) {
              IntConstant nc=(IntConstant)op1;
              if (nc.value != 0) {
                throw new RuntimeException("String_Node_Str" + expr);
              }
              expr.setOp1(nullConstant);
            }
          }
 else {
            throw new RuntimeException("String_Node_Str" + u);
          }
        }
      }
    }
    List<ValueBox> uses=jBody.getUseBoxes();
    List<ValueBox> toNullConstantify=new ArrayList<ValueBox>();
    List<Local> toRemove=new ArrayList<Local>();
    for (    Local l : jBody.getLocals()) {
      if (l.getType() instanceof NullType) {
        toRemove.add(l);
        for (        ValueBox vb : uses) {
          Value v=vb.getValue();
          if (v == l) {
            toNullConstantify.add(vb);
          }
        }
      }
    }
    for (    ValueBox vb : toNullConstantify) {
      System.out.println("String_Node_Str" + vb + "String_Node_Str");
      vb.setValue(nullConstant);
    }
    for (    Local l : toRemove) {
      System.out.println("String_Node_Str" + l);
      l.setType(objectType);
    }
  }
  LocalPacker.v().transform(jBody);
  UnusedLocalEliminator.v().transform(jBody);
  LocalNameStandardizer.v().transform(jBody);
  if (options.wrong_staticness() == Options.wrong_staticness_fix) {
    FieldStaticnessCorrector.v().transform(jBody);
    MethodStaticnessCorrector.v().transform(jBody);
  }
  TrapTightener.v().transform(jBody);
  TrapMinimizer.v().transform(jBody);
  Aggregator.v().transform(jBody);
  ConditionalBranchFolder.v().transform(jBody);
  ConstantCastEliminator.v().transform(jBody);
  IdentityCastEliminator.v().transform(jBody);
  IdentityOperationEliminator.v().transform(jBody);
  UnreachableCodeEliminator.v().transform(jBody);
  DeadAssignmentEliminator.v().transform(jBody);
  UnusedLocalEliminator.v().transform(jBody);
  NopEliminator.v().transform(jBody);
  DexReturnPacker.v().transform(jBody);
  for (  Unit u : jBody.getUnits()) {
    if (u instanceof AssignStmt) {
      AssignStmt ass=(AssignStmt)u;
      if (ass.getRightOp() instanceof CastExpr) {
        CastExpr c=(CastExpr)ass.getRightOp();
        if (c.getType() instanceof NullType) {
          ass.setRightOp(nullConstant);
        }
      }
    }
    if (u instanceof DefinitionStmt) {
      DefinitionStmt def=(DefinitionStmt)u;
      if (def.getLeftOp() instanceof Local && def.getRightOp() instanceof CaughtExceptionRef) {
        Type t=def.getLeftOp().getType();
        if (t instanceof RefType) {
          RefType rt=(RefType)t;
          if (rt.getSootClass().isPhantom() && !rt.getSootClass().hasSuperclass() && !rt.getSootClass().getName().equals("String_Node_Str")) {
            rt.getSootClass().setSuperclass(Scene.v().getSootClass("String_Node_Str"));
          }
        }
      }
    }
  }
  for (  Local l : jBody.getLocals()) {
    Type t=l.getType();
    if (t instanceof NullType) {
      l.setType(objectType);
    }
  }
  return jBody;
}

Fixed version (ground truth):
/** 
 * Return the jimple equivalent of this body.
 * @param m the SootMethod that contains this body
 */
public Body jimplify(Body b,SootMethod m){
  final Jimple jimple=Jimple.v();
  final UnknownType unknownType=UnknownType.v();
  final NullConstant nullConstant=NullConstant.v();
  final Options options=Options.v();
  jBody=(JimpleBody)b;
  deferredInstructions=new ArrayList<DeferableInstruction>();
  instructionsToRetype=new HashSet<RetypeableInstruction>();
  if (IDalvikTyper.ENABLE_DVKTYPER) {
    DalvikTyper.v().clear();
  }
  List<Local> paramLocals=new LinkedList<Local>();
  if (!isStatic) {
    int thisRegister=numRegisters - numParameterRegisters - 1;
    Local thisLocal=jimple.newLocal("String_Node_Str" + thisRegister,unknownType);
    jBody.getLocals().add(thisLocal);
    registerLocals[thisRegister]=thisLocal;
    JIdentityStmt idStmt=(JIdentityStmt)jimple.newIdentityStmt(thisLocal,jimple.newThisRef(declaringClassType));
    add(idStmt);
    paramLocals.add(thisLocal);
    if (IDalvikTyper.ENABLE_DVKTYPER) {
      DalvikTyper.v().setType(idStmt.leftBox,jBody.getMethod().getDeclaringClass().getType(),false);
    }
  }
{
    int i=0;
    int parameterRegister=numRegisters - numParameterRegisters;
    for (    Type t : parameterTypes) {
      Local gen=jimple.newLocal("String_Node_Str" + parameterRegister,unknownType);
      jBody.getLocals().add(gen);
      registerLocals[parameterRegister]=gen;
      JIdentityStmt idStmt=(JIdentityStmt)jimple.newIdentityStmt(gen,jimple.newParameterRef(t,i++));
      add(idStmt);
      paramLocals.add(gen);
      if (IDalvikTyper.ENABLE_DVKTYPER) {
        DalvikTyper.v().setType(idStmt.leftBox,t,false);
      }
      if (t instanceof LongType || t instanceof DoubleType) {
        parameterRegister++;
        Local g=jimple.newLocal("String_Node_Str" + parameterRegister,unknownType);
        jBody.getLocals().add(g);
        registerLocals[parameterRegister]=g;
      }
      parameterRegister++;
    }
  }
  for (int i=0; i < (numRegisters - numParameterRegisters - (isStatic ? 0 : 1)); i++) {
    registerLocals[i]=jimple.newLocal("String_Node_Str" + i,unknownType);
    jBody.getLocals().add(registerLocals[i]);
  }
  storeResultLocal=jimple.newLocal("String_Node_Str",unknownType);
  jBody.getLocals().add(storeResultLocal);
  final boolean isOdex=dexFile instanceof DexBackedDexFile ? ((DexBackedDexFile)dexFile).isOdexFile() : false;
  ClassPath cp=null;
  if (isOdex) {
    String[] sootClasspath=options.soot_classpath().split(File.pathSeparator);
    List<String> classpathList=new ArrayList<String>();
    for (    String str : sootClasspath) {
      classpathList.add(str);
    }
    try {
      ClassPathResolver resolver=new ClassPathResolver(classpathList,classpathList,classpathList,dexFile);
      cp=new ClassPath(resolver.getResolvedClassProviders().toArray(new ClassProvider[0]));
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
  int prevLineNumber=-1;
  for (  DexlibAbstractInstruction instruction : instructions) {
    if (isOdex && instruction instanceof OdexInstruction) {
      ((OdexInstruction)instruction).deOdex(dexFile,method,cp);
    }
    if (dangling != null) {
      dangling.finalize(this,instruction);
      dangling=null;
    }
    instruction.jimplify(this);
    if (instruction.getLineNumber() > 0) {
      prevLineNumber=instruction.getLineNumber();
    }
 else {
      instruction.setLineNumber(prevLineNumber);
    }
  }
  for (  DeferableInstruction instruction : deferredInstructions) {
    instruction.deferredJimplify(this);
  }
  if (tries != null) {
    addTraps();
  }
  if (options.keep_line_number()) {
    fixLineNumbers();
  }
  instructions=null;
  instructionAtAddress.clear();
  deferredInstructions=null;
  dangling=null;
  tries=null;
  DexTrapStackFixer.v().transform(jBody);
  DexJumpChainShortener.v().transform(jBody);
  DexReturnInliner.v().transform(jBody);
  DexArrayInitReducer.v().transform(jBody);
  getLocalSplitter().transform(jBody);
  getUnreachableCodeEliminator().transform(jBody);
  DeadAssignmentEliminator.v().transform(jBody);
  UnusedLocalEliminator.v().transform(jBody);
  for (  RetypeableInstruction i : instructionsToRetype) {
    i.retype(jBody);
  }
  if (IDalvikTyper.ENABLE_DVKTYPER) {
    DexReturnValuePropagator.v().transform(jBody);
    getCopyPopagator().transform(jBody);
    DexNullThrowTransformer.v().transform(jBody);
    DalvikTyper.v().typeUntypedConstrantInDiv(jBody);
    DeadAssignmentEliminator.v().transform(jBody);
    UnusedLocalEliminator.v().transform(jBody);
    DalvikTyper.v().assignType(jBody);
    jBody.validateUses();
    jBody.validateValueBoxes();
  }
 else {
    DexNumTransformer.v().transform(jBody);
    DexReturnValuePropagator.v().transform(jBody);
    getCopyPopagator().transform(jBody);
    DexNullThrowTransformer.v().transform(jBody);
    DexNullTransformer.v().transform(jBody);
    DexIfTransformer.v().transform(jBody);
    DeadAssignmentEliminator.v().transform(jBody);
    UnusedLocalEliminator.v().transform(jBody);
    DexNullArrayRefTransformer.v().transform(jBody);
  }
  if (IDalvikTyper.ENABLE_DVKTYPER) {
    for (    Local l : jBody.getLocals()) {
      l.setType(unknownType);
    }
  }
  DexNullInstanceofTransformer.v().transform(jBody);
  TypeAssigner.v().transform(jBody);
  final RefType objectType=RefType.v("String_Node_Str");
  if (IDalvikTyper.ENABLE_DVKTYPER) {
    for (    Unit u : jBody.getUnits()) {
      if (u instanceof IfStmt) {
        ConditionExpr expr=(ConditionExpr)((IfStmt)u).getCondition();
        if (((expr instanceof EqExpr) || (expr instanceof NeExpr))) {
          Value op1=expr.getOp1();
          Value op2=expr.getOp2();
          if (op1 instanceof Constant && op2 instanceof Local) {
            Local l=(Local)op2;
            Type ltype=l.getType();
            if (ltype instanceof PrimType) {
              continue;
            }
            if (!(op1 instanceof IntConstant)) {
              continue;
            }
            IntConstant icst=(IntConstant)op1;
            int val=icst.value;
            if (val != 0) {
              continue;
            }
            expr.setOp1(nullConstant);
          }
 else           if (op1 instanceof Local && op2 instanceof Constant) {
            Local l=(Local)op1;
            Type ltype=l.getType();
            if (ltype instanceof PrimType) {
              continue;
            }
            if (!(op2 instanceof IntConstant)) {
              continue;
            }
            IntConstant icst=(IntConstant)op2;
            int val=icst.value;
            if (val != 0) {
              continue;
            }
            expr.setOp2(nullConstant);
          }
 else           if (op1 instanceof Local && op2 instanceof Local) {
          }
 else           if (op1 instanceof Constant && op2 instanceof Constant) {
            if (op1 instanceof NullConstant && op2 instanceof NumericConstant) {
              IntConstant nc=(IntConstant)op2;
              if (nc.value != 0) {
                throw new RuntimeException("String_Node_Str" + expr);
              }
              expr.setOp2(NullConstant.v());
            }
 else             if (op2 instanceof NullConstant && op1 instanceof NumericConstant) {
              IntConstant nc=(IntConstant)op1;
              if (nc.value != 0) {
                throw new RuntimeException("String_Node_Str" + expr);
              }
              expr.setOp1(nullConstant);
            }
          }
 else {
            throw new RuntimeException("String_Node_Str" + u);
          }
        }
      }
    }
    List<ValueBox> uses=jBody.getUseBoxes();
    List<ValueBox> toNullConstantify=new ArrayList<ValueBox>();
    List<Local> toRemove=new ArrayList<Local>();
    for (    Local l : jBody.getLocals()) {
      if (l.getType() instanceof NullType) {
        toRemove.add(l);
        for (        ValueBox vb : uses) {
          Value v=vb.getValue();
          if (v == l) {
            toNullConstantify.add(vb);
          }
        }
      }
    }
    for (    ValueBox vb : toNullConstantify) {
      System.out.println("String_Node_Str" + vb + "String_Node_Str");
      vb.setValue(nullConstant);
    }
    for (    Local l : toRemove) {
      System.out.println("String_Node_Str" + l);
      l.setType(objectType);
    }
  }
  LocalPacker.v().transform(jBody);
  UnusedLocalEliminator.v().transform(jBody);
  LocalNameStandardizer.v().transform(jBody);
  if (Options.v().wrong_staticness() == Options.wrong_staticness_fix || Options.v().wrong_staticness() == Options.wrong_staticness_fixstrict) {
    FieldStaticnessCorrector.v().transform(jBody);
    MethodStaticnessCorrector.v().transform(jBody);
  }
  TrapTightener.v().transform(jBody);
  TrapMinimizer.v().transform(jBody);
  Aggregator.v().transform(jBody);
  ConditionalBranchFolder.v().transform(jBody);
  ConstantCastEliminator.v().transform(jBody);
  IdentityCastEliminator.v().transform(jBody);
  IdentityOperationEliminator.v().transform(jBody);
  UnreachableCodeEliminator.v().transform(jBody);
  DeadAssignmentEliminator.v().transform(jBody);
  UnusedLocalEliminator.v().transform(jBody);
  NopEliminator.v().transform(jBody);
  DexReturnPacker.v().transform(jBody);
  for (  Unit u : jBody.getUnits()) {
    if (u instanceof AssignStmt) {
      AssignStmt ass=(AssignStmt)u;
      if (ass.getRightOp() instanceof CastExpr) {
        CastExpr c=(CastExpr)ass.getRightOp();
        if (c.getType() instanceof NullType) {
          ass.setRightOp(nullConstant);
        }
      }
    }
    if (u instanceof DefinitionStmt) {
      DefinitionStmt def=(DefinitionStmt)u;
      if (def.getLeftOp() instanceof Local && def.getRightOp() instanceof CaughtExceptionRef) {
        Type t=def.getLeftOp().getType();
        if (t instanceof RefType) {
          RefType rt=(RefType)t;
          if (rt.getSootClass().isPhantom() && !rt.getSootClass().hasSuperclass() && !rt.getSootClass().getName().equals("String_Node_Str")) {
            rt.getSootClass().setSuperclass(Scene.v().getSootClass("String_Node_Str"));
          }
        }
      }
    }
  }
  for (  Local l : jBody.getLocals()) {
    Type t=l.getType();
    if (t instanceof NullType) {
      l.setType(objectType);
    }
  }
  return jBody;
}