Program: 40202
Project: 40202
Buggy source:
@Override public IR makeIR(final IMethod method,Context context,SSAOptions options){
  if (method instanceof Retranslatable) {
    @SuppressWarnings("String_Node_Str") final Value<Integer> v=(Value<Integer>)context.get(ArgumentCountContext.ARGUMENT_COUNT);
    final Retranslatable m=(Retranslatable)method;
    if (v != null) {
      final JavaScriptLoader myloader=(JavaScriptLoader)method.getDeclaringClass().getClassLoader();
class FixedArgumentsRewriter extends CAstBasicRewriter {
        private final CAstEntity e=m.getEntity();
        public FixedArgumentsRewriter(        CAst Ast){
          super(Ast,false);
        }
        private boolean isNamedVar(        CAstNode n,        String name){
          if (n.getKind() == CAstNode.VAR) {
            String nm=(String)n.getChild(0).getValue();
            return nm.equals(name);
          }
          return false;
        }
        private Object getIndexFromArgumentRef(        CAstNode n){
          if (n.getKind() == CAstNode.OBJECT_REF || n.getKind() == CAstNode.ARRAY_REF) {
            if (isNamedVar(n.getChild(0),"String_Node_Str")) {
              return n.getChild(1).getValue();
            }
          }
          return null;
        }
        private Object getIndexFromBaseVar(        CAstNode n){
          if (n.getKind() == CAstNode.BLOCK_EXPR) {
            if (n.getChildCount() == 2) {
              CAstNode c1=n.getChild(0);
              if (c1.getKind() == CAstNode.ASSIGN) {
                if (isNamedVar(c1.getChild(0),"String_Node_Str")) {
                  if (isNamedVar(c1.getChild(1),"String_Node_Str")) {
                    CAstNode c2=n.getChild(1);
                    if (c2.getKind() == CAstNode.OBJECT_REF || c2.getKind() == CAstNode.ARRAY_REF) {
                      if (isNamedVar(c2.getChild(0),"String_Node_Str")) {
                        return c2.getChild(1).getValue();
                      }
                    }
                  }
                }
              }
            }
          }
          return null;
        }
        private Object getStaticArgumentIndex(        CAstNode n){
          Object x=getIndexFromArgumentRef(n);
          if (x != null) {
            return x;
          }
 else {
            return getIndexFromBaseVar(n);
          }
        }
        private CAstNode handleArgumentRef(        CAstNode n){
          Object x=getStaticArgumentIndex(n);
          if (x != null) {
            if (x instanceof Number && ((Number)x).intValue() < v.getValue() - 2) {
              int arg=((Number)x).intValue() + 3;
              if (arg < e.getArgumentCount()) {
                return Ast.makeNode(CAstNode.VAR,Ast.makeConstant(e.getArgumentNames()[arg]));
              }
 else {
                return Ast.makeNode(CAstNode.VAR,Ast.makeConstant("String_Node_Str" + arg));
              }
            }
 else             if (x instanceof String && "String_Node_Str".equals(x)) {
              return Ast.makeConstant(v.getValue());
            }
          }
          return null;
        }
        @Override protected CAstNode copyNodes(        CAstNode root,        CAstControlFlowMap cfg,        NonCopyingContext context,        Map<Pair<CAstNode,NoKey>,CAstNode> nodeMap){
          CAstNode result=null;
          if (root.getKind() == CAstNode.ARRAY_REF || root.getKind() == CAstNode.OBJECT_REF || root.getKind() == CAstNode.BLOCK_EXPR) {
            result=handleArgumentRef(root);
          }
 else           if (root.getKind() == CAstNode.CONSTANT) {
            result=Ast.makeConstant(root.getValue());
          }
 else           if (root.getKind() == CAstNode.OPERATOR) {
            result=root;
          }
          if (result == null) {
            CAstNode children[]=new CAstNode[root.getChildCount()];
            for (int i=0; i < children.length; i++) {
              children[i]=copyNodes(root.getChild(i),cfg,context,nodeMap);
            }
            for (            Object label : cfg.getTargetLabels(root)) {
              if (label instanceof CAstNode) {
                copyNodes((CAstNode)label,cfg,context,nodeMap);
              }
            }
            CAstNode copy=Ast.makeNode(root.getKind(),children);
            result=copy;
          }
          nodeMap.put(Pair.make(root,context.key()),result);
          return result;
        }
      }
      final FixedArgumentsRewriter args=new FixedArgumentsRewriter(new CAstImpl());
      final JSConstantFoldingRewriter fold=new JSConstantFoldingRewriter(new CAstImpl());
class ArgumentativeTranslator extends JSAstTranslator {
        public ArgumentativeTranslator(        JavaScriptLoader loader){
          super(loader);
        }
        private CAstEntity codeBodyEntity;
        private IMethod specializedCode;
        @Override protected int getArgumentCount(        CAstEntity f){
          return Math.max(super.getArgumentCount(f),v.getValue());
        }
        @Override protected String[] getArgumentNames(        CAstEntity f){
          if (super.getArgumentCount(f) >= v.getValue()) {
            return super.getArgumentNames(f);
          }
 else {
            String[] argNames=new String[v.getValue()];
            System.arraycopy(super.getArgumentNames(f),0,argNames,0,super.getArgumentCount(f));
            for (int i=super.getArgumentCount(f); i < argNames.length; i++) {
              argNames[i]="String_Node_Str" + (i + 1);
            }
            return argNames;
          }
        }
        @Override protected String composeEntityName(        WalkContext parent,        CAstEntity f){
          if (f == codeBodyEntity) {
            return super.composeEntityName(parent,f) + "String_Node_Str" + v.getValue().intValue();
          }
 else {
            return super.composeEntityName(parent,f);
          }
        }
        @Override protected void defineFunction(        CAstEntity N,        WalkContext definingContext,        AbstractCFG cfg,        SymbolTable symtab,        boolean hasCatchBlock,        TypeReference[][] caughtTypes,        boolean hasMonitorOp,        AstLexicalInformation LI,        DebuggingInformation debugInfo){
          if (N == codeBodyEntity) {
            specializedCode=myloader.makeCodeBodyCode(cfg,symtab,hasCatchBlock,caughtTypes,hasMonitorOp,LI,debugInfo,method.getDeclaringClass());
          }
 else {
            super.defineFunction(N,definingContext,cfg,symtab,hasCatchBlock,caughtTypes,hasMonitorOp,LI,debugInfo);
          }
        }
        @Override public void translate(        CAstEntity N,        WalkContext context){
          if (N == m.getEntity()) {
            codeBodyEntity=fold.rewrite(args.rewrite(N));
            super.translate(codeBodyEntity,context);
          }
 else {
            super.translate(N,context);
          }
        }
      }
      ArgumentativeTranslator a=new ArgumentativeTranslator(myloader);
      m.retranslate(a);
      return super.makeIR(a.specializedCode,context,options);
    }
  }
  return super.makeIR(method,context,options);
}

Fixed version (ground truth):
@Override public IR makeIR(final IMethod method,Context context,SSAOptions options){
  if (method instanceof Retranslatable) {
    @SuppressWarnings("String_Node_Str") final Value<Integer> v=(Value<Integer>)context.get(ArgumentCountContext.ARGUMENT_COUNT);
    final Retranslatable m=(Retranslatable)method;
    if (v != null) {
      final JavaScriptLoader myloader=(JavaScriptLoader)method.getDeclaringClass().getClassLoader();
class FixedArgumentsRewriter extends CAstBasicRewriter {
        private final CAstEntity e=m.getEntity();
        public FixedArgumentsRewriter(        CAst Ast){
          super(Ast,false);
        }
        private boolean isNamedVar(        CAstNode n,        String name){
          if (n.getKind() == CAstNode.VAR) {
            String nm=(String)n.getChild(0).getValue();
            return nm.equals(name);
          }
          return false;
        }
        private boolean isNamedVar(        CAstNode n,        Pattern namePattern){
          if (n.getKind() == CAstNode.VAR) {
            String nm=(String)n.getChild(0).getValue();
            return namePattern.matcher(nm).matches();
          }
          return false;
        }
        private Object getIndexFromArgumentRef(        CAstNode n){
          if (n.getKind() == CAstNode.OBJECT_REF || n.getKind() == CAstNode.ARRAY_REF) {
            if (isNamedVar(n.getChild(0),"String_Node_Str")) {
              return n.getChild(1).getValue();
            }
          }
          return null;
        }
        private Object getIndexFromBaseVar(        CAstNode n){
          if (n.getKind() == CAstNode.BLOCK_EXPR) {
            if (n.getChildCount() == 2) {
              CAstNode c1=n.getChild(0);
              if (c1.getKind() == CAstNode.ASSIGN) {
                if (isNamedVar(c1.getChild(0),baseNameRegex)) {
                  if (isNamedVar(c1.getChild(1),"String_Node_Str")) {
                    CAstNode c2=n.getChild(1);
                    if (c2.getKind() == CAstNode.OBJECT_REF || c2.getKind() == CAstNode.ARRAY_REF) {
                      if (isNamedVar(c2.getChild(0),baseNameRegex)) {
                        return c2.getChild(1).getValue();
                      }
                    }
                  }
                }
              }
            }
          }
          return null;
        }
        private Object getStaticArgumentIndex(        CAstNode n){
          Object x=getIndexFromArgumentRef(n);
          if (x != null) {
            return x;
          }
 else {
            return getIndexFromBaseVar(n);
          }
        }
        private CAstNode handleArgumentRef(        CAstNode n){
          Object x=getStaticArgumentIndex(n);
          if (x != null) {
            if (x instanceof Number && ((Number)x).intValue() < v.getValue() - 2) {
              int arg=((Number)x).intValue() + 2;
              if (arg < e.getArgumentCount()) {
                return Ast.makeNode(CAstNode.VAR,Ast.makeConstant(e.getArgumentNames()[arg]));
              }
 else {
                return Ast.makeNode(CAstNode.VAR,Ast.makeConstant("String_Node_Str" + arg));
              }
            }
 else             if (x instanceof String && "String_Node_Str".equals(x)) {
              return Ast.makeConstant(v.getValue());
            }
          }
          return null;
        }
        @Override protected CAstNode copyNodes(        CAstNode root,        CAstControlFlowMap cfg,        NonCopyingContext context,        Map<Pair<CAstNode,NoKey>,CAstNode> nodeMap){
          CAstNode result=null;
          if (root.getKind() == CAstNode.ARRAY_REF || root.getKind() == CAstNode.OBJECT_REF || root.getKind() == CAstNode.BLOCK_EXPR) {
            result=handleArgumentRef(root);
          }
 else           if (root.getKind() == CAstNode.CONSTANT) {
            result=Ast.makeConstant(root.getValue());
          }
 else           if (root.getKind() == CAstNode.OPERATOR) {
            result=root;
          }
          if (result == null) {
            CAstNode children[]=new CAstNode[root.getChildCount()];
            for (int i=0; i < children.length; i++) {
              children[i]=copyNodes(root.getChild(i),cfg,context,nodeMap);
            }
            for (            Object label : cfg.getTargetLabels(root)) {
              if (label instanceof CAstNode) {
                copyNodes((CAstNode)label,cfg,context,nodeMap);
              }
            }
            CAstNode copy=Ast.makeNode(root.getKind(),children);
            result=copy;
          }
          nodeMap.put(Pair.make(root,context.key()),result);
          return result;
        }
      }
      final FixedArgumentsRewriter args=new FixedArgumentsRewriter(new CAstImpl());
      final JSConstantFoldingRewriter fold=new JSConstantFoldingRewriter(new CAstImpl());
class ArgumentativeTranslator extends JSAstTranslator {
        public ArgumentativeTranslator(        JavaScriptLoader loader){
          super(loader);
        }
        private CAstEntity codeBodyEntity;
        private IMethod specializedCode;
        @Override protected int getArgumentCount(        CAstEntity f){
          return Math.max(super.getArgumentCount(f),v.getValue());
        }
        @Override protected String[] getArgumentNames(        CAstEntity f){
          if (super.getArgumentCount(f) >= v.getValue()) {
            return super.getArgumentNames(f);
          }
 else {
            String[] argNames=new String[v.getValue()];
            System.arraycopy(super.getArgumentNames(f),0,argNames,0,super.getArgumentCount(f));
            for (int i=super.getArgumentCount(f); i < argNames.length; i++) {
              argNames[i]="String_Node_Str" + i;
            }
            return argNames;
          }
        }
        @Override protected String composeEntityName(        WalkContext parent,        CAstEntity f){
          if (f == codeBodyEntity) {
            return super.composeEntityName(parent,f) + "String_Node_Str" + v.getValue().intValue();
          }
 else {
            return super.composeEntityName(parent,f);
          }
        }
        @Override protected void defineFunction(        CAstEntity N,        WalkContext definingContext,        AbstractCFG cfg,        SymbolTable symtab,        boolean hasCatchBlock,        TypeReference[][] caughtTypes,        boolean hasMonitorOp,        AstLexicalInformation LI,        DebuggingInformation debugInfo){
          if (N == codeBodyEntity) {
            specializedCode=myloader.makeCodeBodyCode(cfg,symtab,hasCatchBlock,caughtTypes,hasMonitorOp,LI,debugInfo,method.getDeclaringClass());
          }
 else {
            super.defineFunction(N,definingContext,cfg,symtab,hasCatchBlock,caughtTypes,hasMonitorOp,LI,debugInfo);
          }
        }
        @Override public void translate(        CAstEntity N,        WalkContext context){
          if (N == m.getEntity()) {
            codeBodyEntity=fold.rewrite(args.rewrite(N));
            super.translate(codeBodyEntity,context);
          }
 else {
            super.translate(N,context);
          }
        }
      }
      ArgumentativeTranslator a=new ArgumentativeTranslator(myloader);
      m.retranslate(a);
      return super.makeIR(a.specializedCode,context,options);
    }
  }
  return super.makeIR(method,context,options);
}