nus-yam/ex-repair huggingface dataset:
Program: 133178
Project: 133178
Buggy source:
/** 
 * Do the inlining
 * @param logger
 * @param block
 * @param it iterator positioned at function call instruction
 * @param fnCall
 * @param toInline
 */
private void inlineCall(Logger logger,Program prog,Function contextFunction,Block block,ListIterator<Instruction> it,FunctionCall fnCall,Function toInline){
  it.remove();
  Block inlineBlock=toInline.getMainblock().clone(BlockType.NESTED_BLOCK,null,null);
  Map<String,Arg> renames=new HashMap<String,Arg>();
  List<Var> passIn=new ArrayList<Var>();
  List<Var> outArrays=new ArrayList<Var>();
  assert(fnCall.getOutputs().size() == toInline.getOutputList().size());
  assert(fnCall.getInputs().size() == toInline.getInputList().size());
  for (int i=0; i < fnCall.getInputs().size(); i++) {
    Arg inputVal=fnCall.getInput(i);
    Var inArg=toInline.getInputList().get(i);
    renames.put(inArg.name(),inputVal);
    if (inputVal.isVar()) {
      passIn.add(inputVal.getVar());
    }
    inlineBlock.removeCleanups(inArg);
  }
  for (int i=0; i < fnCall.getOutputs().size(); i++) {
    Var outVar=fnCall.getOutput(i);
    Var outArg=toInline.getOutputList().get(i);
    renames.put(outArg.name(),Arg.createVar(outVar));
    passIn.add(outVar);
    if (Types.isArray(outVar.type())) {
      outArrays.add(outVar);
    }
    inlineBlock.removeCleanups(outArg);
  }
  Block insertBlock;
  ListIterator<Instruction> insertPos;
  chooseUniqueNames(prog,contextFunction,inlineBlock,renames);
  inlineBlock.renameVars(renames,false);
  if (fnCall.getMode() == TaskMode.SYNC) {
    insertBlock=block;
    insertPos=it;
  }
 else {
    WaitMode waitMode=WaitMode.TASK_DISPATCH;
    WaitStatement wait=new WaitStatement(contextFunction.getName() + "String_Node_Str" + toInline.getName()+ "String_Node_Str",toInline.getBlockingInputs(),passIn,outArrays,waitMode,false,fnCall.getMode());
    block.addContinuation(wait);
    insertBlock=wait.getBlock();
    insertPos=insertBlock.instructionIterator();
  }
  insertBlock.insertInline(inlineBlock,insertPos);
  logger.debug("String_Node_Str" + fnCall.getFunctionName() + "String_Node_Str"+ contextFunction.getName());
  blacklist.add(Pair.create(contextFunction.getName(),fnCall.getFunctionName()));
}

Fixed version (ground truth):
/** 
 * Do the inlining
 * @param logger
 * @param block
 * @param it iterator positioned at function call instruction
 * @param fnCall
 * @param toInline
 */
private void inlineCall(Logger logger,Program prog,Function contextFunction,Block block,ListIterator<Instruction> it,FunctionCall fnCall,Function toInline){
}
Program: 133179
Project: 133179
Buggy source:
@Override public void optimize(Logger logger,Program program) throws UserException {
  boolean changed;
  do {
    FuncCallFinder finder=new FuncCallFinder();
    TreeWalk.walk(logger,program,finder);
    pruneBuiltins(logger,program,finder);
    Pair<MultiMap<String,String>,Set<String>> actions=selectInlineFunctions(program,finder);
    MultiMap<String,String> inlineLocations=actions.val1;
    Set<String> toRemove=actions.val2;
    logger.debug("String_Node_Str" + inlineLocations.toString());
    logger.debug("String_Node_Str" + toRemove.toString());
    changed=doInlining(logger,program,inlineLocations,toRemove);
    logger.debug("String_Node_Str" + changed);
  }
 while (changed);
}

Fixed version (ground truth):
@Override public void optimize(Logger logger,Program program) throws UserException {
  boolean changed;
  int i=0;
  do {
    FuncCallFinder finder=new FuncCallFinder();
    TreeWalk.walk(logger,program,finder);
    pruneBuiltins(logger,program,finder);
    Pair<MultiMap<String,String>,Set<String>> actions=selectInlineFunctions(program,finder);
    MultiMap<String,String> inlineLocations=actions.val1;
    Set<String> toRemove=actions.val2;
    logger.debug("String_Node_Str" + inlineLocations.toString());
    logger.debug("String_Node_Str" + toRemove.toString());
    changed=doInlining(logger,program,inlineLocations,toRemove);
    logger.debug("String_Node_Str" + changed);
    i++;
  }
 while (changed && i < MAX_ITERS_PER_PASS);
}
Program: 133180
Project: 133180
Buggy source:
/** 
 * Set up renames for local variables in inline block
 * @param inlineBlock
 * @param replacements updated with new renames
 */
private void chooseUniqueNames(Program prog,Function f,Block inlineBlock,Map<String,Arg> replacements){
  Set<String> excludedNames=new HashSet<String>();
  excludedNames.addAll(prog.getGlobalConsts().keySet());
  Deque<Block> blocks=new ArrayDeque<Block>();
  blocks.add(inlineBlock);
  while (!blocks.isEmpty()) {
    Block block=blocks.pop();
    for (    Var v : block.getVariables()) {
      if (v.defType() != DefType.GLOBAL_CONST) {
        updateName(f,replacements,excludedNames,v);
      }
    }
    for (    Continuation c : block.getContinuations()) {
      List<Var> constructVars=c.constructDefinedVars();
      if (constructVars != null) {
        for (        Var cv : constructVars) {
          updateName(f,replacements,excludedNames,cv);
        }
      }
      for (      Block inner : c.getBlocks()) {
        blocks.push(inner);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Set up renames for local variables in inline block
 * @param prog program
 * @param targetFunction function block being inlined into
 * @param inlineBlock block to be inlined
 * @param replacements updated with new renames
 */
private void chooseUniqueNames(Program prog,Function targetFunction,Block inlineBlock,Map<String,Arg> replacements){
  Set<String> excludedNames=new HashSet<String>();
  excludedNames.addAll(prog.getGlobalConsts().keySet());
  Deque<Block> blocks=new ArrayDeque<Block>();
  blocks.add(inlineBlock);
  while (!blocks.isEmpty()) {
    Block block=blocks.pop();
    for (    Var v : block.getVariables()) {
      if (v.defType() != DefType.GLOBAL_CONST) {
        updateName(targetFunction,replacements,excludedNames,v);
      }
    }
    for (    Continuation c : block.getContinuations()) {
      List<Var> constructVars=c.constructDefinedVars();
      if (constructVars != null) {
        for (        Var cv : constructVars) {
          updateName(targetFunction,replacements,excludedNames,cv);
        }
      }
      for (      Block inner : c.getBlocks()) {
        blocks.push(inner);
      }
    }
  }
}
Program: 133181
Project: 133181
Buggy source:
private void doInlining(Logger logger,Program prog,String contextFunction,Block block,Map<String,Function> toInline){
  ListIterator<Instruction> it=block.instructionIterator();
  while (it.hasNext()) {
    Instruction inst=it.next();
    if (isFunctionCall(inst)) {
      FunctionCall fcall=(FunctionCall)inst;
      if (toInline.containsKey(fcall.getFunctionName())) {
        inlineCall(logger,prog,contextFunction,block,it,fcall,toInline.get(fcall.getFunctionName()));
      }
    }
  }
  for (  Continuation c : block.getContinuations()) {
    for (    Block cb : c.getBlocks()) {
      doInlining(logger,prog,contextFunction,cb,toInline);
    }
  }
}

Fixed version (ground truth):
private void doInlining(Logger logger,Program prog,Function contextFunction,Block block,Map<String,Function> toInline){
  ListIterator<Instruction> it=block.instructionIterator();
  while (it.hasNext()) {
    Instruction inst=it.next();
    if (isFunctionCall(inst)) {
      FunctionCall fcall=(FunctionCall)inst;
      if (toInline.containsKey(fcall.getFunctionName())) {
        inlineCall(logger,prog,contextFunction,block,it,fcall,toInline.get(fcall.getFunctionName()));
      }
    }
  }
  for (  Continuation c : block.getContinuations()) {
    for (    Block cb : c.getBlocks()) {
      doInlining(logger,prog,contextFunction,cb,toInline);
    }
  }
}
Program: 133183
Project: 133183
Buggy source:
private void checkUniqueVarNames(Logger logger,Program program,Function fn,Block block,Set<String> usedNames){
  for (  Var v : block.getVariables()) {
    checkVarUnique(logger,program,fn,usedNames,v);
  }
  for (  Continuation c : block.getContinuations()) {
    List<Var> constructDefined=c.constructDefinedVars();
    if (constructDefined != null) {
      for (      Var v : constructDefined) {
        checkVarUnique(logger,program,fn,usedNames,v);
      }
    }
    for (    Block inner : c.getBlocks()) {
      checkUniqueVarNames(logger,program,fn,inner,usedNames);
    }
  }
}

Fixed version (ground truth):
private void checkUniqueVarNames(Logger logger,Program program,Function fn,Block block,Set<String> usedNames){
  for (  Var v : block.getVariables()) {
    checkVarUnique(logger,program,fn,usedNames,v);
  }
  checkCleanups(fn,block);
  for (  Continuation c : block.getContinuations()) {
    List<Var> constructDefined=c.constructDefinedVars();
    if (constructDefined != null) {
      for (      Var v : constructDefined) {
        checkVarUnique(logger,program,fn,usedNames,v);
      }
    }
    for (    Block inner : c.getBlocks()) {
      checkUniqueVarNames(logger,program,fn,inner,usedNames);
    }
  }
}
Program: 133184
Project: 133184
Buggy source:
public static ArrayList<Continuation> cloneContinuations(List<Continuation> conts){
  ArrayList<Continuation> newContinuations=new ArrayList<Continuation>(conts.size());
  for (  Continuation old : conts) {
    newContinuations.add(old.clone());
  }
  return newContinuations;
}

Fixed version (ground truth):
public static ArrayList<Continuation> cloneContinuations(List<Continuation> conts,Block parent){
  ArrayList<Continuation> newContinuations=new ArrayList<Continuation>(conts.size());
  for (  Continuation old : conts) {
    Continuation newC=old.clone();
    newC.setParent(parent);
    newContinuations.add(newC);
  }
  return newContinuations;
}
Program: 133186
Project: 133186
Buggy source:
/** 
 */
private void findCycleFree(MultiMap<String,String> candidates,Set<String> visited,Set<String> toRemove,MultiMap<String,String> newCandidates,Deque<String> callStack,String curr){
  List<String> callers=candidates.get(curr);
  if (callers == null || callers.size() == 0) {
    return;
  }
  if (visited.contains(curr)) {
    return;
  }
  visited.add(curr);
  for (  String caller : callers) {
    if (callStack.contains(caller) || caller.equals(curr)) {
    }
 else {
      newCandidates.put(curr,caller);
      callStack.push(curr);
      findCycleFree(candidates,visited,toRemove,newCandidates,callStack,caller);
      callStack.pop();
    }
  }
}

Fixed version (ground truth):
/** 
 */
private void findCycleFree(MultiMap<String,String> candidates,Set<String> visited,Set<String> toRemove,MultiMap<String,String> newCandidates,Deque<String> callStack,String curr){
  if (blacklist.contains(curr))   return;
  List<String> callers=candidates.get(curr);
  if (callers == null || callers.size() == 0) {
    return;
  }
  if (visited.contains(curr))   return;
  visited.add(curr);
  for (  String caller : callers) {
    if (callStack.contains(caller) || caller.equals(curr)) {
    }
 else     if (blacklist.contains(Pair.create(caller,curr))) {
    }
 else {
      newCandidates.put(curr,caller);
      callStack.push(curr);
      findCycleFree(candidates,visited,toRemove,newCandidates,callStack,caller);
      callStack.pop();
    }
  }
}
Program: 133187
Project: 133187
Buggy source:
/** 
 * Optimize the program and return a new one NOTE: the input might be modified in-place
 * @param icOutput where to log IC between optimiation steps.  Null for no output 
 * @return
 * @throws InvalidWriteException 
 */
public static Program optimize(Logger logger,PrintStream icOutput,Program prog) throws UserException {
  boolean logIC=icOutput != null;
  if (logIC) {
    prog.log(icOutput,"String_Node_Str");
  }
  long nIterations;
  try {
    nIterations=Settings.getLong(Settings.OPT_MAX_ITERATIONS);
  }
 catch (  InvalidOptionException ex) {
    throw new STCRuntimeError(ex.getMessage());
  }
  preprocess(icOutput,logger,prog);
  for (long iteration=0; iteration < nIterations; iteration++) {
    iterate(icOutput,logger,prog,iteration,nIterations);
  }
  postprocess(icOutput,logger,prog,nIterations);
  if (logIC) {
    prog.log(icOutput,"String_Node_Str");
  }
  return prog;
}

Fixed version (ground truth):
/** 
 * Optimize the program and return a new one NOTE: the input might be modified in-place
 * @param icOutput where to log IC between optimiation steps.  Null for no output 
 * @return
 * @throws InvalidWriteException 
 */
public static Program optimize(Logger logger,PrintStream icOutput,Program prog) throws UserException {
  boolean logIC=icOutput != null;
  if (logIC) {
    prog.log(icOutput,"String_Node_Str");
  }
  long nIterations;
  try {
    nIterations=Settings.getLong(Settings.OPT_MAX_ITERATIONS);
  }
 catch (  InvalidOptionException ex) {
    throw new STCRuntimeError(ex.getMessage());
  }
  preprocess(icOutput,logger,prog);
  iterate(icOutput,logger,prog,nIterations);
  postprocess(icOutput,logger,prog,nIterations);
  if (logIC) {
    prog.log(icOutput,"String_Node_Str");
  }
  return prog;
}
Program: 133188
Project: 133188
Buggy source:
/** 
 * Do one iteration of the iterative optimizer passes
 * @param icOutput
 * @param logger
 * @param prog
 * @param iteration
 * @param nIterations
 * @throws Exception
 */
private static void iterate(PrintStream icOutput,Logger logger,Program prog,long iteration,long nIterations) throws UserException {
  OptimizerPipeline pipe=new OptimizerPipeline(icOutput);
  pipe.addPass(new FunctionInline());
  pipe.addPass(new ConstantFold());
  if (iteration == 0) {
    pipe.addPass(new LoopUnroller());
  }
  pipe.addPass(new HoistLoops());
  pipe.addPass(new ForwardDataflow());
  pipe.addPass(new ContinuationFusion());
  if (iteration == nIterations - 2) {
    pipe.addPass(new Pipeline());
    pipe.addPass(new Validate());
  }
  boolean doWaitMerges=(iteration == nIterations - 1);
  pipe.addPass(new WaitCoalescer(doWaitMerges));
  pipe.addPass(new Validate());
  pipe.runPipeline(logger,prog,iteration);
}

Fixed version (ground truth):
/** 
 * Do one iteration of the iterative optimizer passes
 * @param icOutput
 * @param logger
 * @param prog
 * @param iteration
 * @param nIterations
 * @throws Exception
 */
private static void iterate(PrintStream icOutput,Logger logger,Program prog,long nIterations) throws UserException {
  FunctionInline inliner=new FunctionInline();
  for (long iteration=0; iteration < nIterations; iteration++) {
    OptimizerPipeline pipe=new OptimizerPipeline(icOutput);
    pipe.addPass(inliner);
    pipe.addPass(new ConstantFold());
    if (iteration == 0) {
      pipe.addPass(new LoopUnroller());
    }
    pipe.addPass(new HoistLoops());
    pipe.addPass(new ForwardDataflow());
    pipe.addPass(new ContinuationFusion());
    if (iteration == nIterations - 2) {
      pipe.addPass(new Pipeline());
      pipe.addPass(new Validate());
    }
    boolean doWaitMerges=(iteration == nIterations - 1);
    pipe.addPass(new WaitCoalescer(doWaitMerges));
    pipe.addPass(new Validate());
    pipe.runPipeline(logger,prog,iteration);
  }
}
Program: 133189
Project: 133189
Buggy source:
public Block clone(BlockType newType,Continuation parentCont,Function parentFunction){
  return new Block(newType,parentCont,parentFunction,ICUtil.cloneInstructions(this.instructions),new ArrayList<Var>(this.variables),ICUtil.cloneContinuations(this.continuations),new ArrayList<CleanupAction>(this.cleanupActions));
}

Fixed version (ground truth):
public Block clone(BlockType newType,Continuation parentCont,Function parentFunction){
  Block cloned=new Block(newType,parentCont,parentFunction,ICUtil.cloneInstructions(this.instructions),new ArrayList<Var>(this.variables),new ArrayList<Continuation>(),new ArrayList<CleanupAction>(this.cleanupActions));
  for (  Continuation c : this.continuations) {
    cloned.addContinuation(c.clone());
  }
  return cloned;
}
Program: 133190
Project: 133190
Buggy source:
/** 
 * block operates on a BLOCK node of the AST. This should be called for every logical code block (e.g. function bodies, condition bodies, etc) in the program
 * @param context a new context for this block
 * @param closeArgs whether to close input or output argumentsdeclared in block
 */
private void block(Context context,SwiftAST tree,boolean closeArgs) throws UserException {
  LogHelper.trace(context,"String_Node_Str");
  if (tree.getType() != ExMParser.BLOCK) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + tree.getLine() + "String_Node_Str"+ tree.getCharPositionInLine());
  }
  VariableUsageInfo blockVu=tree.checkedGetVariableUsage();
  for (  SwiftAST stmt : tree.children()) {
    walkStatement(context,stmt,blockVu);
  }
  closeBlockVariables(context,closeArgs);
  LogHelper.trace(context,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * block operates on a BLOCK node of the AST. This should be called for every logical code block (e.g. function bodies, condition bodies, etc) in the program
 * @param context a new context for this block
 * @param noRefCount vars that shouldn't have refcoutn decremented onblock exit
 */
private void block(Context context,SwiftAST tree,Collection<Var> noRefcount) throws UserException {
  LogHelper.trace(context,"String_Node_Str");
  if (tree.getType() != ExMParser.BLOCK) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + tree.getLine() + "String_Node_Str"+ tree.getCharPositionInLine());
  }
  VariableUsageInfo blockVu=tree.checkedGetVariableUsage();
  for (  SwiftAST stmt : tree.children()) {
    walkStatement(context,stmt,blockVu);
  }
  cleanupBlockVars(context,noRefcount);
  LogHelper.trace(context,"String_Node_Str");
}
Program: 133191
Project: 133191
Buggy source:
/** 
 * Compile the function, assuming it is already defined in context 
 */
private void compileFunction(Context context,SwiftAST tree) throws UserException {
  String function=tree.child(0).getText();
  LogHelper.debug(context,"String_Node_Str" + function);
  assert(context.isFunction(function));
  assert(context.hasFunctionProp(function,FnProp.COMPOSITE));
  SwiftAST outputs=tree.child(1);
  SwiftAST inputs=tree.child(2);
  SwiftAST block=tree.child(3);
  FunctionDecl fdecl=FunctionDecl.fromAST(context,function,inputs,outputs,Collections.<String>emptySet());
  List<Var> iList=fdecl.getInVars();
  List<Var> oList=fdecl.getOutVars();
  context.syncFilePos(tree,lineMapping);
  varAnalyzer.analyzeVariableUsage(context,function,iList,oList,block);
  LocalContext functionContext=new LocalContext(context,function);
  functionContext.setNested(false);
  functionContext.addDeclaredVariables(iList);
  functionContext.addDeclaredVariables(oList);
  TaskMode mode=context.hasFunctionProp(function,FnProp.SYNC) ? TaskMode.SYNC : TaskMode.CONTROL;
  backend.startFunction(function,oList,iList,mode);
  if (mode != TaskMode.SYNC) {
    VariableUsageInfo vu=block.getVariableUsage();
    for (    Var o : oList) {
      flagDeclaredVarForClosing(functionContext,o,vu);
    }
  }
  block(functionContext,block,false);
  backend.endFunction();
  LogHelper.debug(context,"String_Node_Str" + function);
}

Fixed version (ground truth):
/** 
 * Compile the function, assuming it is already defined in context 
 */
private void compileFunction(Context context,SwiftAST tree) throws UserException {
  String function=tree.child(0).getText();
  LogHelper.debug(context,"String_Node_Str" + function);
  assert(context.isFunction(function));
  assert(context.hasFunctionProp(function,FnProp.COMPOSITE));
  SwiftAST outputs=tree.child(1);
  SwiftAST inputs=tree.child(2);
  SwiftAST block=tree.child(3);
  FunctionDecl fdecl=FunctionDecl.fromAST(context,function,inputs,outputs,Collections.<String>emptySet());
  List<Var> iList=fdecl.getInVars();
  List<Var> oList=fdecl.getOutVars();
  context.syncFilePos(tree,lineMapping);
  varAnalyzer.analyzeVariableUsage(context,function,iList,oList,block);
  LocalContext functionContext=new LocalContext(context,function);
  functionContext.setNested(false);
  functionContext.addDeclaredVariables(iList);
  functionContext.addDeclaredVariables(oList);
  TaskMode mode=context.hasFunctionProp(function,FnProp.SYNC) ? TaskMode.SYNC : TaskMode.CONTROL;
  backend.startFunction(function,oList,iList,mode);
  if (mode != TaskMode.SYNC) {
    VariableUsageInfo vu=block.getVariableUsage();
    for (    Var o : oList) {
      flagDeclaredVarForClosing(functionContext,o,vu);
    }
  }
  Set<Var> allArgs=new HashSet<Var>();
  allArgs.addAll(iList);
  allArgs.addAll(oList);
  block(functionContext,block,allArgs);
  backend.endFunction();
  LogHelper.debug(context,"String_Node_Str" + function);
}
Program: 133193
Project: 133193
Buggy source:
/** 
 * block operates on a BLOCK node of the AST. This should be called for every logical code block (e.g. function bodies, condition bodies, etc) in the program
 * @param context a new context for this block
 */
private void block(Context context,SwiftAST tree) throws UserException {
  LogHelper.trace(context,"String_Node_Str");
  if (tree.getType() != ExMParser.BLOCK) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + tree.getLine() + "String_Node_Str"+ tree.getCharPositionInLine());
  }
  VariableUsageInfo blockVu=tree.checkedGetVariableUsage();
  for (  SwiftAST stmt : tree.children()) {
    walkStatement(context,stmt,blockVu);
  }
  closeBlockVariables(context);
  LogHelper.trace(context,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * block operates on a BLOCK node of the AST. This should be called for every logical code block (e.g. function bodies, condition bodies, etc) in the program
 * @param context a new context for this block
 * @param closeArgs whether to close input or output argumentsdeclared in block
 */
private void block(Context context,SwiftAST tree,boolean closeArgs) throws UserException {
  LogHelper.trace(context,"String_Node_Str");
  if (tree.getType() != ExMParser.BLOCK) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + tree.getLine() + "String_Node_Str"+ tree.getCharPositionInLine());
  }
  VariableUsageInfo blockVu=tree.checkedGetVariableUsage();
  for (  SwiftAST stmt : tree.children()) {
    walkStatement(context,stmt,blockVu);
  }
  closeBlockVariables(context,closeArgs);
  LogHelper.trace(context,"String_Node_Str");
}
Program: 133194
Project: 133194
Buggy source:
/** 
 * Compile the function, assuming it is already defined in context 
 */
private void compileFunction(Context context,SwiftAST tree) throws UserException {
  String function=tree.child(0).getText();
  LogHelper.debug(context,"String_Node_Str" + function);
  assert(context.isFunction(function));
  assert(context.hasFunctionProp(function,FnProp.COMPOSITE));
  SwiftAST outputs=tree.child(1);
  SwiftAST inputs=tree.child(2);
  SwiftAST block=tree.child(3);
  FunctionDecl fdecl=FunctionDecl.fromAST(context,function,inputs,outputs,Collections.<String>emptySet());
  List<Var> iList=fdecl.getInVars();
  List<Var> oList=fdecl.getOutVars();
  context.syncFilePos(tree,lineMapping);
  varAnalyzer.analyzeVariableUsage(context,function,iList,oList,block);
  LocalContext functionContext=new LocalContext(context,function);
  functionContext.setNested(false);
  functionContext.addDeclaredVariables(iList);
  functionContext.addDeclaredVariables(oList);
  TaskMode mode=context.hasFunctionProp(function,FnProp.SYNC) ? TaskMode.SYNC : TaskMode.CONTROL;
  backend.startFunction(function,oList,iList,mode);
  VariableUsageInfo vu=block.getVariableUsage();
  for (  Var o : oList) {
    flagDeclaredVarForClosing(functionContext,o,vu);
  }
  block(functionContext,block);
  backend.endFunction();
  LogHelper.debug(context,"String_Node_Str" + function);
}

Fixed version (ground truth):
/** 
 * Compile the function, assuming it is already defined in context 
 */
private void compileFunction(Context context,SwiftAST tree) throws UserException {
  String function=tree.child(0).getText();
  LogHelper.debug(context,"String_Node_Str" + function);
  assert(context.isFunction(function));
  assert(context.hasFunctionProp(function,FnProp.COMPOSITE));
  SwiftAST outputs=tree.child(1);
  SwiftAST inputs=tree.child(2);
  SwiftAST block=tree.child(3);
  FunctionDecl fdecl=FunctionDecl.fromAST(context,function,inputs,outputs,Collections.<String>emptySet());
  List<Var> iList=fdecl.getInVars();
  List<Var> oList=fdecl.getOutVars();
  context.syncFilePos(tree,lineMapping);
  varAnalyzer.analyzeVariableUsage(context,function,iList,oList,block);
  LocalContext functionContext=new LocalContext(context,function);
  functionContext.setNested(false);
  functionContext.addDeclaredVariables(iList);
  functionContext.addDeclaredVariables(oList);
  TaskMode mode=context.hasFunctionProp(function,FnProp.SYNC) ? TaskMode.SYNC : TaskMode.CONTROL;
  backend.startFunction(function,oList,iList,mode);
  if (mode != TaskMode.SYNC) {
    VariableUsageInfo vu=block.getVariableUsage();
    for (    Var o : oList) {
      flagDeclaredVarForClosing(functionContext,o,vu);
    }
  }
  block(functionContext,block,false);
  backend.endFunction();
  LogHelper.debug(context,"String_Node_Str" + function);
}
Program: 133195
Project: 133195
Buggy source:
/** 
 * Make sure all arrays in block are closed upon exiting
 * @param context
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void closeBlockVariables(Context context) throws UndefinedTypeException, UserException {
  for (  Var v : context.getArraysToClose()) {
    assert(v.defType() != DefType.INARG);
    assert(Types.isArray(v.type()));
    backend.decrWriters(v);
  }
  for (  Var v : context.getScopeVariables()) {
    if (v.storage() == VarStorage.STACK || v.storage() == VarStorage.TEMP) {
      backend.decrRef(v);
    }
  }
}

Fixed version (ground truth):
/** 
 * Make sure all arrays in block are closed upon exiting
 * @param context
 * @param closeArgs 
 * @throws UserException
 * @throws UndefinedTypeException
 */
private void closeBlockVariables(Context context,boolean closeArgs) throws UndefinedTypeException, UserException {
  for (  Var v : context.getArraysToClose()) {
    assert(v.defType() != DefType.INARG);
    assert(Types.isArray(v.type()));
    backend.decrWriters(v);
  }
  for (  Var v : context.getScopeVariables()) {
    if (v.storage() == VarStorage.STACK || v.storage() == VarStorage.TEMP) {
      if (closeArgs && !(v.defType() == DefType.INARG || v.defType() == DefType.OUTARG)) {
        backend.decrRef(v);
      }
    }
  }
}
Program: 133196
Project: 133196
Buggy source:
/** 
 * Do one iteration of the iterative optimizer passes
 * @param icOutput
 * @param logger
 * @param prog
 * @param iteration
 * @param nIterations
 * @throws Exception
 */
private static void iterate(PrintStream icOutput,Logger logger,Program prog,long iteration,long nIterations) throws UserException {
  OptimizerPipeline pipe=new OptimizerPipeline(icOutput);
  pipe.addPass(new FunctionInline());
  pipe.addPass(new ConstantFold());
  if (iteration == 0) {
    pipe.addPass(new LoopUnroller());
  }
  pipe.addPass(new HoistLoops());
  pipe.addPass(new ForwardDataflow());
  pipe.addPass(new ContinuationFusion());
  if (iteration == nIterations - 2) {
    pipe.addPass(new Pipeline());
  }
  boolean doWaitMerges=(iteration == nIterations - 1);
  pipe.addPass(new WaitCoalescer(doWaitMerges));
  pipe.addPass(new Validate());
  pipe.runPipeline(logger,prog,iteration);
}

Fixed version (ground truth):
/** 
 * Do one iteration of the iterative optimizer passes
 * @param icOutput
 * @param logger
 * @param prog
 * @param iteration
 * @param nIterations
 * @throws Exception
 */
private static void iterate(PrintStream icOutput,Logger logger,Program prog,long iteration,long nIterations) throws UserException {
  OptimizerPipeline pipe=new OptimizerPipeline(icOutput);
  pipe.addPass(new FunctionInline());
  pipe.addPass(new ConstantFold());
  if (iteration == 0) {
    pipe.addPass(new LoopUnroller());
  }
  pipe.addPass(new HoistLoops());
  pipe.addPass(new ForwardDataflow());
  pipe.addPass(new ContinuationFusion());
  if (iteration == nIterations - 2) {
    pipe.addPass(new Pipeline());
    pipe.addPass(new Validate());
  }
  boolean doWaitMerges=(iteration == nIterations - 1);
  pipe.addPass(new WaitCoalescer(doWaitMerges));
  pipe.addPass(new Validate());
  pipe.runPipeline(logger,prog,iteration);
}
Program: 133197
Project: 133197
Buggy source:
@Override public void functionCall(String function,List<Var> inputs,List<Var> outputs,List<Boolean> blocking,TaskMode mode,Arg priority){
  assert(priority == null || priority.isImmediateInt());
  logger.debug("String_Node_Str" + function);
  TclList iList=TclUtil.tclListOfVariables(inputs);
  TclList oList=TclUtil.tclListOfVariables(outputs);
  ArrayList<Var> blockOn=new ArrayList<Var>();
  HashSet<String> alreadyBlocking=new HashSet<String>();
  for (int i=0; i < inputs.size(); i++) {
    Var v=inputs.get(i);
    if (blocking.get(i) && !alreadyBlocking.contains(v.name())) {
      blockOn.add(v);
      alreadyBlocking.add(v.name());
    }
  }
  setPriority(priority);
  if (mode == TaskMode.CONTROL || mode == TaskMode.LOCAL) {
    pointStack.peek().append(incrementReaders(outputs,null));
    pointStack.peek().append(incrementReaders(inputs,null));
    pointStack.peek().add(Turbine.callFunction(TclNamer.swiftFuncName(function),oList,iList,TclUtil.tclListOfVariables(blockOn)));
  }
 else   if (mode == TaskMode.SYNC) {
    assert(blocking.size() == 0);
    pointStack.peek().add(Turbine.callFunctionSync(TclNamer.swiftFuncName(function),oList,iList));
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + mode);
  }
  clearPriority(priority);
}

Fixed version (ground truth):
@Override public void functionCall(String function,List<Var> inputs,List<Var> outputs,List<Boolean> blocking,TaskMode mode,Arg priority){
}
Program: 133198
Project: 133198
Buggy source:
public Type findArrayType(Context context) throws UserException {
  Type arrayType=TypeChecker.findSingleExprType(context,arrayVarTree);
  if (!Types.isArray(arrayType) && !Types.isArrayRef(arrayType)) {
    throw new TypeMismatchException(context,"String_Node_Str");
  }
  return arrayType;
}

Fixed version (ground truth):
public Type findArrayType(Context context) throws UserException {
  Type arrayType=TypeChecker.findSingleExprType(context,arrayVarTree);
  for (  Type alt : UnionType.getAlternatives(arrayType)) {
    if (Types.isArray(alt) || Types.isArrayRef(alt)) {
      return alt;
    }
  }
  throw new TypeMismatchException(context,"String_Node_Str" + "String_Node_Str" + arrayType.typeName());
}
Program: 133200
Project: 133200
Buggy source:
/** 
 * Check if an expression type can be used for function argument
 * @param argType non-polymorphic function argument type
 * @param exprType type of argument expression
 * @return true if compatible
 */
public static boolean compatibleArgTypes(Type argType,Type exprType){
  if (argType.assignableTo(exprType)) {
    return true;
  }
 else   if (Types.isRefTo(exprType,argType)) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Check if an expression type can be used for function argument
 * @param argType non-polymorphic function argument type
 * @param exprType type of argument expression
 * @return true if compatible
 */
public static boolean compatibleArgTypes(Type argType,Type exprType){
  if (exprType.assignableTo(argType)) {
    return true;
  }
 else   if (Types.isRefTo(exprType,argType)) {
    return true;
  }
 else {
    return false;
  }
}
Program: 133201
Project: 133201
Buggy source:
@Override public void addKeepOpenVars(Collection<Var> v){
  this.keepOpenVars.addAll(v);
}

Fixed version (ground truth):
@Override public void addKeepOpenVars(Collection<Var> v){
  super.addKeepOpenVars(v);
  this.loopContinue.removeKeepOpenVars(v);
  this.loopBreak.removeKeepOpenVars(v);
}
Program: 133202
Project: 133202
Buggy source:
protected void fuseIntoAbstract(AbstractLoop o,boolean insertAtTop){
  this.loopBody.insertInline(o.loopBody,insertAtTop);
  this.keepOpenVars.addAll(o.keepOpenVars);
  ICUtil.removeDuplicates(this.keepOpenVars);
  this.passedInVars.addAll(o.passedInVars);
  ICUtil.removeDuplicates(this.passedInVars);
}

Fixed version (ground truth):
protected void fuseIntoAbstract(AbstractLoop o,boolean insertAtTop){
  this.loopBody.insertInline(o.loopBody,insertAtTop);
  this.addKeepOpenVars(o.keepOpenVars);
  ICUtil.removeDuplicates(this.keepOpenVars);
  this.addPassedInVars(o.passedInVars);
  ICUtil.removeDuplicates(this.passedInVars);
}
Program: 133203
Project: 133203
Buggy source:
@Override public void addPassedInVars(Collection<Var> vars){
  assert(vars != null);
  this.passedInVars.addAll(vars);
}

Fixed version (ground truth):
@Override public void addPassedInVars(Collection<Var> vars){
  super.addPassedInVars(vars);
  this.loopContinue.removeUsedVars(vars);
  this.loopBreak.removeUsedVars(vars);
}
Program: 133204
Project: 133204
Buggy source:
@Override public void addKeepOpenVar(Var v){
  this.keepOpenVars.add(v);
}

Fixed version (ground truth):
@Override public void addKeepOpenVar(Var v){
  super.addKeepOpenVar(v);
  this.loopContinue.addKeepOpenVar(v);
  this.loopBreak.addKeepOpenVar(v);
}
Program: 133205
Project: 133205
Buggy source:
public void setLoopBreak(LoopBreak loopBreak){
}

Fixed version (ground truth):
public void setLoopBreak(LoopBreak loopBreak){
  this.loopBreak=loopBreak;
}
Program: 133206
Project: 133206
Buggy source:
public LoopBreak(List<Var> loopUsedVars,List<Var> varsToClose){
  super(Opcode.LOOP_BREAK);
  this.loopUsedVars=new ArrayList<Var>(loopUsedVars);
  this.varsToClose=new ArrayList<Var>(varsToClose);
}

Fixed version (ground truth):
public LoopBreak(List<Var> loopUsedVars,List<Var> varsToClose){
  super(Opcode.LOOP_BREAK);
  this.loopUsedVars=new ArrayList<Var>(loopUsedVars);
  this.keepOpenVars=new ArrayList<Var>(varsToClose);
}
Program: 133207
Project: 133207
Buggy source:
public LoopContinue(List<Var> newLoopVars,List<Var> usedVariables,List<Var> keepOpenVars,List<Boolean> blockingVars){
  super(Opcode.LOOP_CONTINUE);
  this.newLoopVars=new ArrayList<Var>(newLoopVars);
  this.usedVariables=new ArrayList<Var>(usedVariables);
  this.keepOpenVars=new ArrayList<Var>(keepOpenVars);
  this.blockingVars=new ArrayList<Boolean>(blockingVars);
}

Fixed version (ground truth):
public LoopContinue(List<Var> newLoopVars,List<Var> loopUsedVars,List<Var> keepOpenVars,List<Boolean> blockingVars){
  super(Opcode.LOOP_CONTINUE);
  this.newLoopVars=new ArrayList<Var>(newLoopVars);
  this.loopUsedVars=new ArrayList<Var>(loopUsedVars);
  this.keepOpenVars=new ArrayList<Var>(keepOpenVars);
  this.blockingVars=new ArrayList<Boolean>(blockingVars);
}
Program: 133208
Project: 133208
Buggy source:
public void removeUsedVar(Var variable){
  ICUtil.removeVarInList(usedVariables,variable.name());
}

Fixed version (ground truth):
public void removeUsedVar(Var variable){
  ICUtil.removeVarInList(loopUsedVars,variable.name());
}
Program: 133209
Project: 133209
Buggy source:
@Override public void removeVars(Set<String> removeVars){
  assert(!removeVars.contains(newLoopVars.get(0).name()));
  ICUtil.removeVarsInList(usedVariables,removeVars);
  ICUtil.removeVarsInList(keepOpenVars,removeVars);
  ICUtil.removeVarsInList(newLoopVars,removeVars);
}

Fixed version (ground truth):
@Override public void removeVars(Set<String> removeVars){
  assert(!removeVars.contains(newLoopVars.get(0).name()));
  ICUtil.removeVarsInList(loopUsedVars,removeVars);
  ICUtil.removeVarsInList(keepOpenVars,removeVars);
  ICUtil.removeVarsInList(newLoopVars,removeVars);
}
Program: 133210
Project: 133210
Buggy source:
public void addUsedVar(Var variable){
  this.usedVariables.add(variable);
}

Fixed version (ground truth):
public void addUsedVar(Var variable){
  this.loopUsedVars.add(variable);
}
Program: 133211
Project: 133211
Buggy source:
@Override public void startLoop(String loopName,List<Var> loopVars,List<Var> initVals,List<Var> usedVariables,List<Var> keepOpenVars,List<Boolean> blockingVars){
  ArrayList<String> loopFnArgs=new ArrayList<String>();
  ArrayList<Value> firstIterArgs=new ArrayList<Value>();
  loopFnArgs.add(Turbine.LOCAL_STACK_NAME);
  firstIterArgs.add(new Value(Turbine.LOCAL_STACK_NAME));
  for (  Var arg : loopVars) {
    loopFnArgs.add(prefixVar(arg.name()));
  }
  for (  Var init : initVals) {
    firstIterArgs.add(varToExpr(init));
  }
  for (  Var uv : usedVariables) {
    loopFnArgs.add(prefixVar(uv.name()));
    firstIterArgs.add(varToExpr(uv));
  }
  ArrayList<Value> blockingVals=new ArrayList<Value>();
  assert(blockingVars.size() == initVals.size());
  for (int i=0; i < blockingVars.size(); i++) {
    Var iv=initVals.get(i);
    if (blockingVars.get(i)) {
      blockingVals.add(varToExpr(iv));
    }
  }
  incrementAllRefs(usedVariables,keepOpenVars);
  String uniqueLoopName=uniqueTCLFunctionName(loopName);
  pointStack.peek().add(Turbine.loopRule(uniqueLoopName,firstIterArgs,blockingVals));
  Sequence loopBody=new Sequence();
  Proc loopProc=new Proc(uniqueLoopName,usedTclFunctionNames,loopFnArgs,loopBody);
  tree.add(loopProc);
  pointStack.push(loopBody);
  loopNameStack.push(uniqueLoopName);
}

Fixed version (ground truth):
@Override public void startLoop(String loopName,List<Var> loopVars,List<Var> initVals,List<Var> usedVariables,List<Var> keepOpenVars,List<Boolean> blockingVars){
  ArrayList<String> loopFnArgs=new ArrayList<String>();
  ArrayList<Value> firstIterArgs=new ArrayList<Value>();
  loopFnArgs.add(Turbine.LOCAL_STACK_NAME);
  firstIterArgs.add(new Value(Turbine.LOCAL_STACK_NAME));
  for (  Var arg : loopVars) {
    loopFnArgs.add(prefixVar(arg.name()));
  }
  for (  Var init : initVals) {
    firstIterArgs.add(varToExpr(init));
  }
  for (  Var uv : usedVariables) {
    loopFnArgs.add(prefixVar(uv.name()));
    firstIterArgs.add(varToExpr(uv));
  }
  ArrayList<Value> blockingVals=new ArrayList<Value>();
  assert(blockingVars.size() == initVals.size());
  for (int i=0; i < blockingVars.size(); i++) {
    Var iv=initVals.get(i);
    if (blockingVars.get(i)) {
      blockingVals.add(varToExpr(iv));
    }
  }
  incrementAllRefs(usedVariables,keepOpenVars);
  pointStack.peek().append(incrementReaders(initVals,null));
  String uniqueLoopName=uniqueTCLFunctionName(loopName);
  pointStack.peek().add(Turbine.loopRule(uniqueLoopName,firstIterArgs,blockingVals));
  Sequence loopBody=new Sequence();
  Proc loopProc=new Proc(uniqueLoopName,usedTclFunctionNames,loopFnArgs,loopBody);
  tree.add(loopProc);
  pointStack.push(loopBody);
  loopNameStack.push(uniqueLoopName);
}
Program: 133212
Project: 133212
Buggy source:
@Override public void loopContinue(List<Var> newVals,List<Var> usedVariables,List<Var> registeredContainers,List<Boolean> blockingVars){
  ArrayList<Value> nextIterArgs=new ArrayList<Value>();
  String loopName=loopNameStack.peek();
  nextIterArgs.add(new Value(Turbine.LOCAL_STACK_NAME));
  for (  Var v : newVals) {
    nextIterArgs.add(varToExpr(v));
  }
  for (  Var v : usedVariables) {
    nextIterArgs.add(varToExpr(v));
  }
  ArrayList<Value> blockingVals=new ArrayList<Value>();
  assert(newVals.size() == blockingVars.size());
  for (int i=0; i < newVals.size(); i++) {
    if (blockingVars.get(i)) {
      blockingVals.add(varToExpr(newVals.get(i)));
    }
  }
  pointStack.peek().add(Turbine.loopRule(loopName,nextIterArgs,blockingVals));
}

Fixed version (ground truth):
@Override public void loopContinue(List<Var> newVals,List<Var> usedVariables,List<Var> registeredContainers,List<Boolean> blockingVars){
  ArrayList<Value> nextIterArgs=new ArrayList<Value>();
  String loopName=loopNameStack.peek();
  nextIterArgs.add(new Value(Turbine.LOCAL_STACK_NAME));
  for (  Var v : newVals) {
    nextIterArgs.add(varToExpr(v));
  }
  for (  Var v : usedVariables) {
    nextIterArgs.add(varToExpr(v));
  }
  ArrayList<Value> blockingVals=new ArrayList<Value>();
  assert(newVals.size() == blockingVars.size());
  for (int i=0; i < newVals.size(); i++) {
    if (blockingVars.get(i)) {
      blockingVals.add(varToExpr(newVals.get(i)));
    }
  }
  pointStack.peek().append(incrementReaders(newVals,null));
  pointStack.peek().add(Turbine.loopRule(loopName,nextIterArgs,blockingVals));
}
Program: 133213
Project: 133213
Buggy source:
/** 
 * Union of lists with one instance of each variable by name included in result
 * @param lists
 * @return
 */
public static List<Var> varListUnion(List<Var> list1,List<Var> list2){
  ArrayList<Var> res=new ArrayList<Var>();
  Set<String> present=new HashSet<String>();
  for (  Var v : list1) {
    if (!present.contains(v.name())) {
      res.add(v);
    }
  }
  for (  Var v : list2) {
    if (!present.contains(v.name())) {
      res.add(v);
    }
  }
  return res;
}

Fixed version (ground truth):
/** 
 * Union of lists with one instance of each variable by name included in result
 * @param list1
 * @param list2
 * @return
 */
public static List<Var> varListUnion(List<Var> list1,List<Var> list2){
  ArrayList<Var> res=new ArrayList<Var>();
  Set<String> present=new HashSet<String>();
  for (  Var v : list1) {
    if (!present.contains(v.name())) {
      res.add(v);
    }
  }
  for (  Var v : list2) {
    if (!present.contains(v.name())) {
      res.add(v);
    }
  }
  return res;
}
Program: 133214
Project: 133214
Buggy source:
/** 
 * Increment readers by a TODO: handle struct and file vars
 * @param vars
 * @param incr expression for the amount of increment/decrement.  If null, assume 1
 * @param if true, then negate incr
 * @return
 */
private static Sequence incrementReaders(List<Var> vars,Expression incr,boolean negate){
  Sequence seq=new Sequence();
  for (  VarCount vc : Var.countVars(vars)) {
    Var var=vc.var;
    if (!hasRefcount(var)) {
      continue;
    }
    Expression amount;
    if (vc.count == 1 && incr == null) {
      amount=null;
    }
 else     if (incr == null) {
      amount=new LiteralInt(vc.count);
    }
 else     if (vc.count == 1 && incr != null) {
      amount=incr;
    }
 else {
      amount=Square.arithExpr(new LiteralInt(vc.count),new Token("String_Node_Str"),incr);
    }
    if (Types.isFile(var.type())) {
      if (negate) {
        seq.add(Turbine.decrFileRef(varToExpr(var),amount));
      }
 else {
        seq.add(Turbine.incrFileRef(varToExpr(var),amount));
      }
    }
 else     if (Types.isStruct(var.type())) {
    }
 else {
      if (negate) {
        seq.add(Turbine.decrRef(varToExpr(var),amount));
      }
 else {
        seq.add(Turbine.incrRef(varToExpr(var),amount));
      }
    }
  }
  return seq;
}

Fixed version (ground truth):
/** 
 * Increment readers by a TODO: handle struct and file vars
 * @param vars
 * @param incr expression for the amount of increment/decrement.  If null, assume 1
 * @param negate if true, then negate incr
 * @return
 */
private static Sequence incrementReaders(List<Var> vars,Expression incr,boolean negate){
  Sequence seq=new Sequence();
  for (  VarCount vc : Var.countVars(vars)) {
    Var var=vc.var;
    if (!hasRefcount(var)) {
      continue;
    }
    Expression amount;
    if (vc.count == 1 && incr == null) {
      amount=null;
    }
 else     if (incr == null) {
      amount=new LiteralInt(vc.count);
    }
 else     if (vc.count == 1 && incr != null) {
      amount=incr;
    }
 else {
      amount=Square.arithExpr(new LiteralInt(vc.count),new Token("String_Node_Str"),incr);
    }
    if (Types.isFile(var.type())) {
      if (negate) {
        seq.add(Turbine.decrFileRef(varToExpr(var),amount));
      }
 else {
        seq.add(Turbine.incrFileRef(varToExpr(var),amount));
      }
    }
 else     if (Types.isStruct(var.type())) {
    }
 else {
      if (negate) {
        seq.add(Turbine.decrRef(varToExpr(var),amount));
      }
 else {
        seq.add(Turbine.incrRef(varToExpr(var),amount));
      }
    }
  }
  return seq;
}
Program: 133215
Project: 133215
Buggy source:
/** 
 * Evaluates expression, creating temporary output variable if needed
 * @param type expected result type of expression
 * @return return the name of a newly created tmp variable
 * @throws UserException
 */
public Var eval(Context context,SwiftAST tree,Type type,boolean storeInStack,Map<String,String> renames) throws UserException {
  assert(type != null);
  context.syncFilePos(tree,lineMapping);
  if (tree.getType() == ExMParser.VARIABLE) {
    String varName=tree.child(0).getText();
    if (renames != null && renames.containsKey(varName)) {
      varName=renames.get(varName);
    }
    Var var=context.getDeclaredVariable(varName);
    if (var == null) {
      throw new UndefinedVariableException(context,"String_Node_Str" + varName + "String_Node_Str");
    }
    if (var.storage() == VarStorage.STACK || (!storeInStack) && var.type().equals(type)) {
      return var;
    }
  }
  if (tree.getType() == ExMParser.STRUCT_LOAD && Types.isStruct(TypeChecker.findSingleExprType(context,tree.child(0)))) {
    return lookupStructField(context,tree,type,storeInStack,null,renames);
  }
 else {
    Var tmp=varCreator.createTmp(context,type,storeInStack,false);
    ArrayList<Var> childOList=new ArrayList<Var>(1);
    childOList.add(tmp);
    evalToVars(context,tree,childOList,renames);
    return tmp;
  }
}

Fixed version (ground truth):
/** 
 * Evaluates expression, creating temporary output variable if needed
 * @param type expected result type of expression
 * @return return the name of a newly created tmp variable
 * @throws UserException
 */
public Var eval(Context context,SwiftAST tree,Type type,boolean storeInStack,Map<String,String> renames) throws UserException {
  assert(type != null);
  context.syncFilePos(tree,lineMapping);
  if (tree.getType() == ExMParser.VARIABLE) {
    String varName=tree.child(0).getText();
    if (renames != null && renames.containsKey(varName)) {
      varName=renames.get(varName);
    }
    Var var=context.getDeclaredVariable(varName);
    if (var == null) {
      throw new UndefinedVariableException(context,"String_Node_Str" + varName + "String_Node_Str");
    }
    if ((var.storage() == VarStorage.STACK || (!storeInStack)) && var.type().equals(type)) {
      return var;
    }
  }
  if (tree.getType() == ExMParser.STRUCT_LOAD && Types.isStruct(TypeChecker.findSingleExprType(context,tree.child(0)))) {
    return lookupStructField(context,tree,type,storeInStack,null,renames);
  }
 else {
    Var tmp=varCreator.createTmp(context,type,storeInStack,false);
    ArrayList<Var> childOList=new ArrayList<Var>(1);
    childOList.add(tmp);
    evalToVars(context,tree,childOList,renames);
    return tmp;
  }
}
Program: 133216
Project: 133216
Buggy source:
public static Command stringSet(String turbineDstVar,Expression src){
  return new Command(STORE_STRING,new Value(turbineDstVar),src);
}

Fixed version (ground truth):
public static Command stringSet(Value turbineDstVar,Expression src){
  return new Command(STORE_STRING,turbineDstVar,src);
}
Program: 133217
Project: 133217
Buggy source:
public static Command integerSet(String turbineDstVar,Expression src){
  return new Command(STORE_INTEGER,new Value(turbineDstVar),src);
}

Fixed version (ground truth):
public static Command integerSet(Value turbineDstVar,Expression src){
  return new Command(STORE_INTEGER,turbineDstVar,src);
}
Program: 133218
Project: 133218
Buggy source:
public static Command floatSet(String turbineDstVar,Expression src){
  Value t=new Value(turbineDstVar);
  Command c=new Command(STORE_FLOAT,t,src);
  return c;
}

Fixed version (ground truth):
public static Command floatSet(Value turbineDstVar,Expression src){
  return new Command(STORE_FLOAT,turbineDstVar,src);
}
Program: 133219
Project: 133219
Buggy source:
@Override public void assignInt(Var target,Arg src){
  assert(src.isImmediateInt());
  if (!Types.isInt(target.type())) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + target.type().toString());
  }
  pointStack.peek().add(Turbine.integerSet(prefixVar(target.name()),opargToExpr(src)));
}

Fixed version (ground truth):
@Override public void assignInt(Var target,Arg src){
  assert(src.isImmediateInt());
  if (!Types.isInt(target.type())) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + target.type().toString());
  }
  pointStack.peek().add(Turbine.integerSet(varToExpr(target),opargToExpr(src)));
}