Program: 61646
Project: 61646
Buggy source:
public ConvertOutput toSourceOutput(String path,GraphPart part,boolean processJumps,boolean isStatic,int scriptIndex,int classIndex,HashMap<Integer,GraphTargetItem> localRegs,TranslateStack stack,ScopeStack scopeStack,ABC abc,AVM2ConstantPool constants,List<MethodInfo> method_info,MethodBody body,int start,int end,HashMap<Integer,String> localRegNames,List<String> fullyQualifiedNames,boolean[] visited,HashMap<Integer,Integer> localRegAssigmentIps,HashMap<Integer,List<Integer>> refs) throws ConvertException, InterruptedException {
  boolean debugMode=DEBUG_MODE;
  if (debugMode) {
    System.out.println("String_Node_Str" + start + "String_Node_Str"+ end+ "String_Node_Str"+ code.get(start).toString()+ "String_Node_Str"+ code.get(end).toString());
  }
  if (visited == null) {
    visited=new boolean[code.size()];
  }
  toSourceCount++;
  if (toSourceLimit > 0) {
    if (toSourceCount > toSourceLimit) {
      throw new ConvertException("String_Node_Str" + toSourceLimit + "String_Node_Str",start);
    }
  }
  List<GraphTargetItem> output=new ArrayList<>();
  int ip=start;
  iploop:   while (ip <= end) {
    if (ignoredIns.contains(ip)) {
      ip++;
      continue;
    }
    boolean processTry=processJumps;
    int ipfix=fixIPAfterDebugLine(ip);
    int maxend=-1;
    if (ip > end) {
      break;
    }
    if (unknownJumps.contains(ip)) {
      unknownJumps.remove(Integer.valueOf(ip));
      throw new UnknownJumpException(stack,ip,output);
    }
    if (visited[ip]) {
      logger.warning("String_Node_Str" + Helper.formatAddress(pos2adr(ip)) + "String_Node_Str"+ ip);
      break;
    }
    visited[ip]=true;
    AVM2Instruction ins=code.get(ip);
    if (debugMode) {
      System.err.println("String_Node_Str" + ip + "String_Node_Str"+ ins.toString()+ "String_Node_Str"+ stack.toString()+ "String_Node_Str"+ scopeStack.toString());
    }
    if (ins.definition instanceof NewFunctionIns) {
      if (ip + 1 <= end) {
        if (code.get(ip + 1).definition instanceof PopIns) {
          ip+=2;
          continue;
        }
      }
    }
    if ((ins.definition instanceof GetLocalTypeIns) && (!output.isEmpty()) && (output.get(output.size() - 1) instanceof SetLocalAVM2Item)&& (((SetLocalAVM2Item)output.get(output.size() - 1)).regIndex == ((GetLocalTypeIns)ins.definition).getRegisterId(ins))&& isKilled(((SetLocalAVM2Item)output.get(output.size() - 1)).regIndex,start,end)) {
      SetLocalAVM2Item slt=(SetLocalAVM2Item)output.remove(output.size() - 1);
      stack.push(slt.getValue());
      ip++;
    }
 else     if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end) && (isKilled(((SetLocalTypeIns)ins.definition).getRegisterId(ins),ip,end))) {
      AVM2Instruction insAfter=code.get(ip + 1);
      if ((insAfter.definition instanceof GetLocalTypeIns) && (((GetLocalTypeIns)insAfter.definition).getRegisterId(insAfter) == ((SetLocalTypeIns)ins.definition).getRegisterId(ins))) {
        GraphTargetItem before=stack.peek();
        ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
        stack.push(before);
        ip+=2;
        continue iploop;
      }
 else {
        ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
        ip++;
        continue iploop;
      }
    }
 else     if (ins.definition instanceof DupIns) {
      int nextPos;
      do {
        AVM2Instruction insAfter=code.get(ip + 1);
        AVM2Instruction insBefore=ins;
        if (ip - 1 >= start) {
          insBefore=code.get(ip - 1);
        }
        if (insAfter.definition instanceof ConvertBIns) {
          ip++;
          insAfter=code.get(ip + 1);
        }
        boolean isAnd;
        if (processJumps && (insAfter.definition instanceof IfFalseIns)) {
          isAnd=true;
        }
 else         if (processJumps && (insAfter.definition instanceof IfTrueIns)) {
          isAnd=false;
        }
 else         if (insAfter.definition instanceof SetLocalTypeIns) {
          int reg=(((SetLocalTypeIns)insAfter.definition).getRegisterId(insAfter));
          for (int t=ip + 1; t <= end - 1; t++) {
            if (code.get(t).definition instanceof KillIns) {
              if (code.get(t).operands[0] == reg) {
                break;
              }
            }
            if (code.get(t).definition instanceof GetLocalTypeIns) {
              if (((GetLocalTypeIns)code.get(t).definition).getRegisterId(code.get(t)) == reg) {
                if (code.get(t + 1).definition instanceof KillIns) {
                  if (code.get(t + 1).operands[0] == reg) {
                    ConvertOutput assignment=toSourceOutput(path,part,processJumps,isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,abc,constants,method_info,body,ip + 2,t - 1,localRegNames,fullyQualifiedNames,visited,localRegAssigmentIps,refs);
                    GraphTargetItem tar=assignment.output.remove(assignment.output.size() - 1);
                    tar.firstPart=part;
                    stack.push(tar);
                    ip=t + 2;
                    continue iploop;
                  }
                }
              }
            }
          }
          if (!isKilled(reg,0,end)) {
            for (int i=ip; i >= start; i--) {
              if (code.get(i).definition instanceof DupIns) {
                if (stack.isEmpty()) {
                  break;
                }
                GraphTargetItem v=stack.pop();
                stack.push(new LocalRegAVM2Item(ins,reg,v));
                stack.push(v);
              }
 else {
                break;
              }
            }
          }
 else {
            ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
          }
          ip++;
          break;
        }
 else {
          ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
          ip++;
          break;
        }
      }
 while (ins.definition instanceof DupIns);
    }
 else     if ((ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ThrowIns)) {
      ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
      break;
    }
 else     if (ins.definition instanceof NewFunctionIns) {
      String functionName="String_Node_Str";
      if ((ip >= start + 2) && (ip <= end - 4)) {
        AVM2Instruction prev2=code.get(ip - 2);
        if (prev2.definition instanceof NewObjectIns) {
          if (prev2.operands[0] == 0) {
            if (code.get(ip - 1).definition instanceof PushWithIns) {
              boolean hasDup=false;
              int plus=0;
              if (code.get(ip + 1).definition instanceof DupIns) {
                hasDup=true;
                plus=1;
              }
              AVM2Instruction psco=code.get(ip + 1 + plus);
              if (psco.definition instanceof GetScopeObjectIns) {
                if (psco.operands[0] == scopeStack.size() - 1) {
                  if (code.get(ip + plus + 2).definition instanceof SwapIns) {
                    if (code.get(ip + plus + 4).definition instanceof PopScopeIns) {
                      if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) {
                        functionName=abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(constants,fullyQualifiedNames,true);
                        scopeStack.pop();
                        output.remove(output.size() - 1);
                        ip=ip + plus + 4;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
      NewFunctionAVM2Item nft=(NewFunctionAVM2Item)stack.peek();
      nft.functionName=functionName;
      ip++;
    }
 else {
      try {
        ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
      }
 catch (      RuntimeException re) {
        throw re;
      }
      ip++;
    }
  }
  if (debugMode) {
    System.out.println("String_Node_Str" + start + "String_Node_Str"+ end+ "String_Node_Str"+ code.get(start).toString()+ "String_Node_Str"+ code.get(end).toString());
  }
  return new ConvertOutput(stack,output);
}

Fixed version (ground truth):
public ConvertOutput toSourceOutput(String path,GraphPart part,boolean processJumps,boolean isStatic,int scriptIndex,int classIndex,HashMap<Integer,GraphTargetItem> localRegs,TranslateStack stack,ScopeStack scopeStack,ABC abc,AVM2ConstantPool constants,List<MethodInfo> method_info,MethodBody body,int start,int end,HashMap<Integer,String> localRegNames,List<String> fullyQualifiedNames,boolean[] visited,HashMap<Integer,Integer> localRegAssigmentIps,HashMap<Integer,List<Integer>> refs) throws ConvertException, InterruptedException {
  calcKilledStats(body);
  boolean debugMode=DEBUG_MODE;
  if (debugMode) {
    System.out.println("String_Node_Str" + start + "String_Node_Str"+ end+ "String_Node_Str"+ code.get(start).toString()+ "String_Node_Str"+ code.get(end).toString());
  }
  if (visited == null) {
    visited=new boolean[code.size()];
  }
  toSourceCount++;
  if (toSourceLimit > 0) {
    if (toSourceCount > toSourceLimit) {
      throw new ConvertException("String_Node_Str" + toSourceLimit + "String_Node_Str",start);
    }
  }
  List<GraphTargetItem> output=new ArrayList<>();
  int ip=start;
  iploop:   while (ip <= end) {
    if (ignoredIns.contains(ip)) {
      ip++;
      continue;
    }
    boolean processTry=processJumps;
    int ipfix=fixIPAfterDebugLine(ip);
    int maxend=-1;
    if (ip > end) {
      break;
    }
    if (unknownJumps.contains(ip)) {
      unknownJumps.remove(Integer.valueOf(ip));
      throw new UnknownJumpException(stack,ip,output);
    }
    if (visited[ip]) {
      logger.warning("String_Node_Str" + Helper.formatAddress(pos2adr(ip)) + "String_Node_Str"+ ip);
      break;
    }
    visited[ip]=true;
    AVM2Instruction ins=code.get(ip);
    if (debugMode) {
      System.err.println("String_Node_Str" + ip + "String_Node_Str"+ ins.toString()+ "String_Node_Str"+ stack.toString()+ "String_Node_Str"+ scopeStack.toString());
    }
    if (ins.definition instanceof NewFunctionIns) {
      if (ip + 1 <= end) {
        if (code.get(ip + 1).definition instanceof PopIns) {
          ip+=2;
          continue;
        }
      }
    }
    if ((ins.definition instanceof GetLocalTypeIns) && (!output.isEmpty()) && (output.get(output.size() - 1) instanceof SetLocalAVM2Item)&& (((SetLocalAVM2Item)output.get(output.size() - 1)).regIndex == ((GetLocalTypeIns)ins.definition).getRegisterId(ins))&& isKilled(((SetLocalAVM2Item)output.get(output.size() - 1)).regIndex,start,end)) {
      SetLocalAVM2Item slt=(SetLocalAVM2Item)output.remove(output.size() - 1);
      stack.push(slt.getValue());
      ip++;
    }
 else     if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end) && (isKilled(((SetLocalTypeIns)ins.definition).getRegisterId(ins),ip,end))) {
      AVM2Instruction insAfter=code.get(ip + 1);
      if ((insAfter.definition instanceof GetLocalTypeIns) && (((GetLocalTypeIns)insAfter.definition).getRegisterId(insAfter) == ((SetLocalTypeIns)ins.definition).getRegisterId(ins))) {
        GraphTargetItem before=stack.peek();
        ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
        stack.push(before);
        ip+=2;
        continue iploop;
      }
 else {
        ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
        ip++;
        continue iploop;
      }
    }
 else     if (ins.definition instanceof DupIns) {
      int nextPos;
      do {
        AVM2Instruction insAfter=code.get(ip + 1);
        AVM2Instruction insBefore=ins;
        if (ip - 1 >= start) {
          insBefore=code.get(ip - 1);
        }
        if (insAfter.definition instanceof ConvertBIns) {
          ip++;
          insAfter=code.get(ip + 1);
        }
        boolean isAnd;
        if (processJumps && (insAfter.definition instanceof IfFalseIns)) {
          isAnd=true;
        }
 else         if (processJumps && (insAfter.definition instanceof IfTrueIns)) {
          isAnd=false;
        }
 else         if (insAfter.definition instanceof SetLocalTypeIns) {
          int reg=(((SetLocalTypeIns)insAfter.definition).getRegisterId(insAfter));
          for (int t=ip + 1; t <= end - 1; t++) {
            if (code.get(t).definition instanceof KillIns) {
              if (code.get(t).operands[0] == reg) {
                break;
              }
            }
            if (code.get(t).definition instanceof GetLocalTypeIns) {
              if (((GetLocalTypeIns)code.get(t).definition).getRegisterId(code.get(t)) == reg) {
                if (code.get(t + 1).definition instanceof KillIns) {
                  if (code.get(t + 1).operands[0] == reg) {
                    ConvertOutput assignment=toSourceOutput(path,part,processJumps,isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,abc,constants,method_info,body,ip + 2,t - 1,localRegNames,fullyQualifiedNames,visited,localRegAssigmentIps,refs);
                    GraphTargetItem tar=assignment.output.remove(assignment.output.size() - 1);
                    tar.firstPart=part;
                    stack.push(tar);
                    ip=t + 2;
                    continue iploop;
                  }
                }
              }
            }
          }
          if (!isKilled(reg,0,end)) {
            for (int i=ip; i >= start; i--) {
              if (code.get(i).definition instanceof DupIns) {
                if (stack.isEmpty()) {
                  break;
                }
                GraphTargetItem v=stack.pop();
                stack.push(new LocalRegAVM2Item(ins,reg,v));
                stack.push(v);
              }
 else {
                break;
              }
            }
          }
 else {
            ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
          }
          ip++;
          break;
        }
 else {
          ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
          ip++;
          break;
        }
      }
 while (ins.definition instanceof DupIns);
    }
 else     if ((ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ThrowIns)) {
      ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
      break;
    }
 else     if (ins.definition instanceof NewFunctionIns) {
      String functionName="String_Node_Str";
      if ((ip >= start + 2) && (ip <= end - 4)) {
        AVM2Instruction prev2=code.get(ip - 2);
        if (prev2.definition instanceof NewObjectIns) {
          if (prev2.operands[0] == 0) {
            if (code.get(ip - 1).definition instanceof PushWithIns) {
              boolean hasDup=false;
              int plus=0;
              if (code.get(ip + 1).definition instanceof DupIns) {
                hasDup=true;
                plus=1;
              }
              AVM2Instruction psco=code.get(ip + 1 + plus);
              if (psco.definition instanceof GetScopeObjectIns) {
                if (psco.operands[0] == scopeStack.size() - 1) {
                  if (code.get(ip + plus + 2).definition instanceof SwapIns) {
                    if (code.get(ip + plus + 4).definition instanceof PopScopeIns) {
                      if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) {
                        functionName=abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(constants,fullyQualifiedNames,true);
                        scopeStack.pop();
                        output.remove(output.size() - 1);
                        ip=ip + plus + 4;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
      NewFunctionAVM2Item nft=(NewFunctionAVM2Item)stack.peek();
      nft.functionName=functionName;
      ip++;
    }
 else {
      try {
        ins.definition.translate(isStatic,scriptIndex,classIndex,localRegs,stack,scopeStack,constants,ins,method_info,output,body,abc,localRegNames,fullyQualifiedNames,path,localRegAssigmentIps,ip,refs,this);
      }
 catch (      RuntimeException re) {
        throw re;
      }
      ip++;
    }
  }
  if (debugMode) {
    System.out.println("String_Node_Str" + start + "String_Node_Str"+ end+ "String_Node_Str"+ code.get(start).toString()+ "String_Node_Str"+ code.get(end).toString());
  }
  return new ConvertOutput(stack,output);
}