nus-yam/ex-repair huggingface dataset:
Program: 132774
Project: 132774
Buggy source:
public static ArgCV assignCompVal(Var dst,boolean recursive){
  Type dstType=dst.type();
  if (Types.isPrimValue(dstType)) {
    BuiltinOpcode op;
switch (dstType.primType()) {
case BOOL:
      op=BuiltinOpcode.COPY_BOOL;
    break;
case INT:
  op=BuiltinOpcode.COPY_INT;
break;
case FLOAT:
op=BuiltinOpcode.COPY_FLOAT;
break;
case STRING:
op=BuiltinOpcode.COPY_STRING;
break;
case BLOB:
op=BuiltinOpcode.COPY_BLOB;
break;
case VOID:
op=BuiltinOpcode.COPY_VOID;
break;
default :
throw new STCRuntimeError("String_Node_Str" + dstType);
}
return new ArgCV(Opcode.LOCAL_OP,op,dst.asArg().asList());
}
 else {
Opcode op=Opcode.assignOpcode(dstType,recursive);
if (op != null) {
return new ArgCV(op,dst.asArg().asList());
}
}
throw new STCRuntimeError("String_Node_Str" + dst);
}

Fixed version (ground truth):
public static ArgCV assignCompVal(Var dst,boolean recursive){
  Type dstType=dst.type();
  if (Types.isPrimValue(dstType)) {
    BuiltinOpcode op;
switch (dstType.primType()) {
case BOOL:
      op=BuiltinOpcode.COPY_BOOL;
    break;
case INT:
  op=BuiltinOpcode.COPY_INT;
break;
case FLOAT:
op=BuiltinOpcode.COPY_FLOAT;
break;
case STRING:
op=BuiltinOpcode.COPY_STRING;
break;
case BLOB:
op=BuiltinOpcode.COPY_BLOB;
break;
case VOID:
op=BuiltinOpcode.COPY_VOID;
break;
default :
throw new STCRuntimeError("String_Node_Str" + dstType);
}
return new ArgCV(Opcode.LOCAL_OP,op,dst.asArg().asList());
}
 else {
Opcode op=Opcode.assignOpcode(dstType,recursive);
if (op != null) {
return new ArgCV(op,dst.asArg().asList());
}
}
throw new STCRuntimeError("String_Node_Str" + dst + (recursive ? "String_Node_Str" : "String_Node_Str"));
}
Program: 132776
Project: 132776
Buggy source:
/** 
 * Return list of ancestor datums
 * @param var
 * @return list of (ancestorKey, if part of separate structure) 
 */
public List<Pair<AliasKey,Boolean>> getAncestors(Var var){
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + var + "String_Node_Str");
  }
  List<Pair<AliasKey,Boolean>> results=new ArrayList<Pair<AliasKey,Boolean>>();
  AliasKey canonKey=getCanonical(var);
  logger.trace("String_Node_Str" + canonKey);
  boolean traversedDeref=false;
  for (int i=canonKey.pathLength() - 1; i >= 0; i--) {
    AliasKey prefix=canonKey.prefix(i);
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str" + prefix + "String_Node_Str"+ traversedDeref+ "String_Node_Str");
    }
    results.add(Pair.create(prefix,traversedDeref));
    if (canonKey.path[i] != null && canonKey.path[i].equals(Alias.DEREF_MARKER)) {
      traversedDeref=true;
    }
  }
  return results;
}

Fixed version (ground truth):
/** 
 * Return list of ancestor datums
 * @param var
 * @return list of (ancestorKey, if part of separate structure) 
 */
public List<Pair<AliasKey,Boolean>> getAncestors(Var var){
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + var + "String_Node_Str");
  }
  List<Pair<AliasKey,Boolean>> results=new ArrayList<Pair<AliasKey,Boolean>>();
  AliasKey currKey=getCanonical(var);
  boolean traversedDeref=false;
  while (currKey != null) {
    logger.trace("String_Node_Str" + currKey);
    traversedDeref=addAncestors(results,currKey,traversedDeref);
    AliasKey next=getCanonical(currKey.var);
    if (next.pathLength() > 0) {
      currKey=next;
    }
 else {
      currKey=null;
    }
  }
  return results;
}
Program: 132777
Project: 132777
Buggy source:
public long getIntLit(){
  if (kind == ArgKind.INTVAL) {
    return intlit;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind);
  }
}

Fixed version (ground truth):
public long getIntLit(){
  if (kind == ArgKind.INTVAL) {
    return intlit;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind + "String_Node_Str"+ this);
  }
}
Program: 132778
Project: 132778
Buggy source:
public String getStringLit(){
  if (kind == ArgKind.STRINGVAL) {
    return stringlit;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind);
  }
}

Fixed version (ground truth):
public String getStringLit(){
  if (kind == ArgKind.STRINGVAL) {
    return stringlit;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind + "String_Node_Str"+ this);
  }
}
Program: 132779
Project: 132779
Buggy source:
public double getFloatLit(){
  if (kind == ArgKind.FLOATVAL) {
    return floatlit;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind);
  }
}

Fixed version (ground truth):
public double getFloatLit(){
  if (kind == ArgKind.FLOATVAL) {
    return floatlit;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind + "String_Node_Str"+ this);
  }
}
Program: 132780
Project: 132780
Buggy source:
public Var getVar(){
  if (kind == ArgKind.VAR) {
    return var;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind);
  }
}

Fixed version (ground truth):
public Var getVar(){
  if (kind == ArgKind.VAR) {
    return var;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind + "String_Node_Str"+ this);
  }
}
Program: 132781
Project: 132781
Buggy source:
public boolean getBoolLit(){
  if (kind == ArgKind.BOOLVAL) {
    return boollit;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind);
  }
}

Fixed version (ground truth):
public boolean getBoolLit(){
  if (kind == ArgKind.BOOLVAL) {
    return boollit;
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + kind + "String_Node_Str"+ this);
  }
}
Program: 132782
Project: 132782
Buggy source:
/** 
 * Helper to convert struct fields to input list
 * @param struct
 * @param fieldNames
 * @return
 */
private static List<Arg> structFieldInputs(Var struct,List<Arg> fieldNames){
  List<Arg> inputs=new ArrayList<Arg>(fieldNames.size() + 1);
  inputs.add(struct.asArg());
  for (  Arg fieldName : fieldNames) {
    assert(fieldName.isStringVal());
    inputs.add(fieldName);
  }
  return inputs;
}

Fixed version (ground truth):
/** 
 * Helper to convert struct fields to input list
 * @param struct
 * @param fieldNames
 * @return
 */
private static List<Arg> structFieldInputs(Var struct,List<Arg> fieldNames){
}
Program: 132785
Project: 132785
Buggy source:
/** 
 * try to reduce to a simpler form of wait
 * @param currContext
 * @param toInline
 * @param newContext
 * @param wait
 */
private boolean tryReduce(Logger logger,Function fn,ExecContext currContext,ExecContext newContext,WaitStatement wait){
  if ((currContext == newContext && ProgressOpcodes.isCheap(wait.getBlock())) || (currContext == ExecContext.WORKER && newContext == ExecContext.CONTROL && canSwitchControlToWorker(logger,fn,wait))) {
    if (wait.getWaitVars().isEmpty()) {
      return true;
    }
 else {
      if (wait.getTarget() == TaskMode.CONTROL) {
        if (currContext == ExecContext.CONTROL) {
          wait.setTarget(TaskMode.LOCAL_CONTROL);
        }
 else {
          wait.setTarget(TaskMode.LOCAL);
        }
      }
      if (wait.getMode() == WaitMode.TASK_DISPATCH) {
        wait.setMode(WaitMode.WAIT_ONLY);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * try to reduce to a simpler form of wait
 * @param currContext
 * @param toInline
 * @param innerContext
 * @param wait
 * @return true if it should be inlined
 */
private boolean tryReduce(Logger logger,Function fn,ExecContext currContext,ExecContext innerContext,WaitStatement wait){
  if ((currContext == innerContext && ProgressOpcodes.isCheap(wait.getBlock())) || (currContext == ExecContext.WORKER && innerContext == ExecContext.CONTROL && canSwitchControlToWorker(logger,fn,wait))) {
    if (currContext == ExecContext.WORKER && innerContext == ExecContext.CONTROL) {
      replaceLocalControl(wait.getBlock());
    }
    if (wait.getWaitVars().isEmpty()) {
      return true;
    }
 else {
      if (wait.getTarget() == TaskMode.CONTROL) {
        if (currContext == ExecContext.CONTROL) {
          wait.setTarget(TaskMode.LOCAL_CONTROL);
        }
 else {
          wait.setTarget(TaskMode.LOCAL);
        }
      }
      if (wait.getMode() == WaitMode.TASK_DISPATCH) {
        wait.setMode(WaitMode.WAIT_ONLY);
      }
    }
  }
  return false;
}
Program: 132786
Project: 132786
Buggy source:
public HoistTracking getAncestor(int links){
  HoistTracking curr=this;
  for (int i=0; i < links; i++) {
    curr=this.parent;
  }
  return curr;
}

Fixed version (ground truth):
public HoistTracking getAncestor(int links){
  Logger logger=Logging.getSTCLogger();
  HoistTracking curr=this;
  for (int i=0; i < links; i++) {
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str" + this.block.getType() + "String_Node_Str"+ this.parent.block.getType());
    }
    curr=curr.parent;
  }
  return curr;
}
Program: 132787
Project: 132787
Buggy source:
/** 
 * Relocate output variables to target block
 * @param source
 * @param target
 * @param inst
 */
private static void relocateVarDefs(HoistTracking source,HoistTracking target,Instruction inst){
  assert(source != target);
  ListIterator<Var> varIt=source.block.variableIterator();
  while (varIt.hasNext()) {
    Var def=varIt.next();
    for (    Var out : inst.getOutputs()) {
      if (def.equals(out)) {
        varIt.remove();
        target.block.addVariable(def);
        moveVarCleanupAction(out,source.block,target.block);
        if (trackDeclares(out)) {
          source.declareMap.remove(out);
        }
        target.declare(out);
        break;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Relocate var defs from this block and any in-between ancestors to target block
 * @param state
 * @param inst
 * @param targetAncestor
 */
private static void relocateVarDefs(HoistTracking state,Instruction inst,HoistTracking targetAncestor){
  HoistTracking ancestor=state;
  assert(targetAncestor != null && state != targetAncestor);
  while (ancestor != targetAncestor) {
    assert(ancestor != null);
    relocateVarDefsFromBlock(ancestor,targetAncestor,inst);
    ancestor=ancestor.parent;
  }
}
Program: 132788
Project: 132788
Buggy source:
private static void doHoist(Logger logger,Instruction inst,int hoistDepth,HoistTracking state){
  assert(hoistDepth > 0);
  logger.trace("String_Node_Str" + hoistDepth + "String_Node_Str"+ inst.toString());
  state.getAncestor(hoistDepth).addInstruction(inst);
  relocateVarDefs(state,inst,hoistDepth);
  state.getAncestor(hoistDepth).updateState(inst);
}

Fixed version (ground truth):
private static void doHoist(Logger logger,Instruction inst,int hoistDepth,HoistTracking state){
  assert(hoistDepth > 0);
  logger.trace("String_Node_Str" + hoistDepth + "String_Node_Str"+ inst.toString());
  HoistTracking ancestor=state.getAncestor(hoistDepth);
  logger.trace("String_Node_Str" + ancestor.block.getType());
  ancestor.addInstruction(inst);
  relocateVarDefs(state,inst,ancestor);
  ancestor.updateState(inst);
}
Program: 132789
Project: 132789
Buggy source:
public static void fixupImmChange(Block srcBlock,Block targetBlock,Instruction oldInst,MakeImmChange change,List<Statement> instBuffer,List<Var> newOutVars,List<Var> oldOutVars,boolean storeOutputMapping){
  instBuffer.addAll(Arrays.asList(change.newInsts));
  Logger logger=Logging.getSTCLogger();
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + oldInst + "String_Node_Str"+ Arrays.asList(change.newInsts));
  }
  if (!change.isOutVarSame()) {
    Var newOut=change.newOut;
    Var oldOut=change.oldOut;
    replaceInstOutput(srcBlock,targetBlock,instBuffer,newOut,oldOut,storeOutputMapping);
  }
  if (change.storeOutputVals) {
    WrapUtil.setLocalOpOutputs(targetBlock,oldOutVars,newOutVars,instBuffer,storeOutputMapping);
  }
}

Fixed version (ground truth):
public static void fixupImmChange(Block srcBlock,Block targetBlock,Instruction oldInst,MakeImmChange change,List<Statement> instBuffer,List<Var> newOutVars,List<Var> oldOutVars,boolean storeOutputMapping){
  instBuffer.addAll(Arrays.asList(change.newInsts));
  Logger logger=Logging.getSTCLogger();
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + oldInst + "String_Node_Str"+ Arrays.asList(change.newInsts));
  }
  if (!change.isOutVarSame()) {
    Var newOut=change.newOut;
    Var oldOut=change.oldOut;
    boolean initOutput=false;
    for (    Pair<Var,InitType> init : oldInst.getInitialized()) {
      if (init.val2 == InitType.FULL && init.val1.equals(oldOut)) {
        initOutput=true;
        break;
      }
    }
    replaceInstOutput(srcBlock,targetBlock,instBuffer,newOut,oldOut,storeOutputMapping,initOutput);
  }
  if (change.storeOutputVals) {
    WrapUtil.setLocalOpOutputs(targetBlock,oldOutVars,newOutVars,instBuffer,storeOutputMapping);
  }
}
Program: 132790
Project: 132790
Buggy source:
/** 
 * Do the manipulation necessary to allow an old instruction output variable to be replaced with a new one. Assume that newOut is a value type of oldOut
 * @param srcBlock source block for instruction 
 * @param targetBlock target block for instruction
 * @param instBuffer append any fixup instructions here
 * @param newOut
 * @param oldOut
 * @param storeOutputMapping if true, assign mapping
 */
public static void replaceInstOutput(Block srcBlock,Block targetBlock,List<Statement> instBuffer,Var newOut,Var oldOut,boolean storeOutputMapping){
  boolean isDerefResult=Types.retrievedType(oldOut).assignableTo(newOut.type());
  if (isDerefResult) {
    Var oldOutReplacement;
    if (oldOut.storage() == Alloc.ALIAS) {
      oldOutReplacement=new Var(oldOut.type(),oldOut.name(),Alloc.TEMP,oldOut.defType(),oldOut.provenance(),oldOut.mappedDecl());
      replaceVarDeclaration(srcBlock,oldOut,oldOutReplacement);
      Map<Var,Arg> renames=Collections.singletonMap(oldOut,Arg.createVar(oldOutReplacement));
      for (      Statement inst : instBuffer) {
        inst.renameVars(renames,RenameMode.REPLACE_VAR);
      }
    }
 else {
      oldOutReplacement=oldOut;
    }
    WrapUtil.assignOutput(targetBlock,instBuffer,storeOutputMapping,oldOutReplacement,newOut);
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + oldOut + "String_Node_Str"+ newOut+ "String_Node_Str"+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Do the manipulation necessary to allow an old instruction output variable to be replaced with a new one. Assume that newOut is a value type of oldOut
 * @param srcBlock source block for instruction 
 * @param targetBlock target block for instruction
 * @param instBuffer append any fixup instructions here
 * @param newOut
 * @param oldOut
 * @param storeOutputMapping if true, assign mapping
 */
public static void replaceInstOutput(Block srcBlock,Block targetBlock,List<Statement> instBuffer,Var newOut,Var oldOut,boolean initialisesOutput,boolean storeOutputMapping){
  boolean isDerefResult=Types.retrievedType(oldOut).assignableTo(newOut.type());
  if (isDerefResult) {
    Var oldOutReplacement;
    if (oldOut.storage() == Alloc.ALIAS && initialisesOutput) {
      System.err.println("String_Node_Str" + oldOut);
      new Exception().printStackTrace();
      oldOutReplacement=new Var(oldOut.type(),oldOut.name(),Alloc.TEMP,oldOut.defType(),oldOut.provenance(),oldOut.mappedDecl());
      replaceVarDeclaration(srcBlock,oldOut,oldOutReplacement);
      Map<Var,Arg> renames=Collections.singletonMap(oldOut,Arg.createVar(oldOutReplacement));
      for (      Statement inst : instBuffer) {
        inst.renameVars(renames,RenameMode.REPLACE_VAR);
      }
    }
 else {
      oldOutReplacement=oldOut;
    }
    WrapUtil.assignOutput(targetBlock,instBuffer,storeOutputMapping,oldOutReplacement,newOut);
  }
 else {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + oldOut + "String_Node_Str"+ newOut+ "String_Node_Str"+ "String_Node_Str");
  }
}
Program: 132791
Project: 132791
Buggy source:
/** 
 * Create alias for a struct field
 * @param structVar
 * @param structField
 * @param alias
 */
@Override public void structCreateAlias(Var alias,Var struct,List<String> fields){
  assert(alias.storage() == Alloc.ALIAS);
  assert(Types.isStruct(struct));
  assert(Types.isStructField(struct,fields,alias));
  Expression aliasExpr=Turbine.structAlias(varToExpr(struct),structFieldIndices(struct.type(),fields));
  pointAdd(new SetVariable(prefixVar(alias),aliasExpr));
}

Fixed version (ground truth):
/** 
 * Create alias for a struct field
 * @param structVar
 * @param structField
 * @param alias
 */
@Override public void structCreateAlias(Var alias,Var struct,List<String> fields){
}
Program: 132792
Project: 132792
Buggy source:
public HoistTracking makeChild(Block childBlock,ExecContext newExecCx,int maxHoist,int maxLoopHoist){
  return new HoistTracking(this,childBlock,execCx,maxHoist,maxLoopHoist,writeMap.makeChildMap(),piecewiseWriteMap.makeChildMap(),declareMap.makeChildMap(),initializedMap.makeChildMap());
}

Fixed version (ground truth):
public HoistTracking makeChild(Block childBlock,boolean async,ExecContext newExecCx,int maxHoist,int maxLoopHoist){
  return new HoistTracking(this,childBlock,async,execCx,maxHoist,maxLoopHoist,writeMap.makeChildMap(),piecewiseWriteMap.makeChildMap(),declareMap.makeChildMap(),initializedMap.makeChildMap());
}
Program: 132793
Project: 132793
Buggy source:
@Override public void optimize(Logger logger,Program prog){
  for (  Function f : prog.getFunctions()) {
    HoistTracking global=new HoistTracking();
    for (    Var gv : prog.constants().vars()) {
      global.write(gv,false);
      global.declare(gv);
    }
    HoistTracking mainBlockState=global.makeChild(f.mainBlock(),ExecContext.CONTROL,0,0);
    for (    Var in : f.getInputList()) {
      mainBlockState.write(in,false);
      mainBlockState.declare(in);
    }
    for (    Var out : f.getOutputList()) {
      mainBlockState.declare(out);
    }
    hoistRec(logger,mainBlockState);
  }
}

Fixed version (ground truth):
@Override public void optimize(Logger logger,Program prog){
  for (  Function f : prog.getFunctions()) {
    HoistTracking global=new HoistTracking();
    for (    Var gv : prog.constants().vars()) {
      global.write(gv,false);
      global.declare(gv);
    }
    HoistTracking mainBlockState=global.makeChild(f.mainBlock(),true,ExecContext.CONTROL,0,0);
    for (    Var in : f.getInputList()) {
      mainBlockState.write(in,false);
      mainBlockState.declare(in);
    }
    for (    Var out : f.getOutputList()) {
      mainBlockState.declare(out);
    }
    hoistRec(logger,mainBlockState);
  }
}
Program: 132794
Project: 132794
Buggy source:
private HoistTracking(HoistTracking parent,Block block,ExecContext execCx,int maxHoist,int maxLoopHoist,HierarchicalMap<Var,Block> writeMap,HierarchicalMap<Var,Block> piecewiseWriteMap,HierarchicalMap<Var,Block> declareMap,HierarchicalMap<Var,Block> initializedMap){
  super();
  this.parent=parent;
  this.block=block;
  this.execCx=execCx;
  this.maxHoist=maxHoist;
  this.maxLoopHoist=maxLoopHoist;
  this.writeMap=writeMap;
  this.piecewiseWriteMap=piecewiseWriteMap;
  this.declareMap=declareMap;
  this.initializedMap=initializedMap;
}

Fixed version (ground truth):
private HoistTracking(HoistTracking parent,Block block,boolean async,ExecContext execCx,int maxHoist,int maxLoopHoist,HierarchicalMap<Var,Block> writeMap,HierarchicalMap<Var,Block> piecewiseWriteMap,HierarchicalMap<Var,Block> declareMap,HierarchicalMap<Var,Block> initializedMap){
  super();
  this.parent=parent;
  this.block=block;
  this.async=async;
  this.execCx=execCx;
  this.maxHoist=maxHoist;
  this.maxLoopHoist=maxLoopHoist;
  this.writeMap=writeMap;
  this.piecewiseWriteMap=piecewiseWriteMap;
  this.declareMap=declareMap;
  this.initializedMap=initializedMap;
}
Program: 132795
Project: 132795
Buggy source:
public void write(Var v,boolean piecewise){
  if (piecewise) {
    piecewiseWriteMap.put(v,this.block);
  }
 else {
    writeMap.put(v,this.block);
  }
}

Fixed version (ground truth):
public void write(Var v,boolean piecewise){
  HoistTracking taskRoot=this;
  while (!taskRoot.async && taskRoot.parent != null) {
    taskRoot=taskRoot.parent;
  }
  if (piecewise) {
    taskRoot.piecewiseWriteMap.put(v,this.block);
  }
 else {
    taskRoot.writeMap.put(v,this.block);
  }
}
Program: 132796
Project: 132796
Buggy source:
/** 
 * Retrieve a reference to a local handle 
 * @param dst alias variable to hold handle to referenced data
 * @param src Closed reference
 * @param acquireRead num of read refcounts to acquire
 * @param acquireWrite num of write refcounts to acquire
 * @return
 */
public static Instruction retrieveRef(Var dst,Var src,long acquireRead,long acquireWrite){
  assert(Types.isRef(src.type()));
  assert(acquireRead >= 0);
  assert(acquireWrite >= 0);
  if (acquireWrite > 0) {
    assert(Types.isAssignableRefTo(src.type(),dst.type(),true));
  }
 else {
    assert(Types.isAssignableRefTo(src.type(),dst.type()));
  }
  assert(dst.storage() == Alloc.ALIAS);
  return new TurbineOp(Opcode.LOAD_REF,dst,src.asArg());
}

Fixed version (ground truth):
/** 
 * Retrieve a reference to a local handle 
 * @param dst alias variable to hold handle to referenced data
 * @param src Closed reference
 * @param acquireRead num of read refcounts to acquire
 * @param acquireWrite num of write refcounts to acquire
 * @return
 */
public static Instruction retrieveRef(Var dst,Var src,long acquireRead,long acquireWrite){
  assert(Types.isRef(src.type()));
  assert(acquireRead >= 0);
  assert(acquireWrite >= 0);
  if (acquireWrite > 0) {
    assert(Types.isAssignableRefTo(src.type(),dst.type(),true));
  }
 else {
    assert(Types.isAssignableRefTo(src.type(),dst.type()));
  }
  assert(dst.storage() == Alloc.ALIAS);
  return new TurbineOp(Opcode.LOAD_REF,dst,src.asArg(),Arg.createIntLit(acquireRead),Arg.createIntLit(acquireWrite));
}
Program: 132797
Project: 132797
Buggy source:
public List<Var> getModifiedOutputs(){
switch (op) {
case ARR_CREATE_NESTED_IMM:
case ARR_CREATE_NESTED_FUTURE:
case AREF_CREATE_NESTED_IMM:
case AREF_CREATE_NESTED_FUTURE:
case ARRAY_CREATE_BAG:
    return Collections.singletonList(getOutput(0));
case AREF_STORE_FUTURE:
case AREF_STORE_IMM:
  return Collections.singletonList(getOutput(1));
default :
return this.getOutputs();
}
}

Fixed version (ground truth):
public List<Var> getModifiedOutputs(){
switch (op) {
case ARR_CREATE_NESTED_IMM:
case ARR_CREATE_NESTED_FUTURE:
case AREF_CREATE_NESTED_IMM:
case AREF_CREATE_NESTED_FUTURE:
case ARRAY_CREATE_BAG:
    return Collections.singletonList(getOutput(0));
default :
  return this.getOutputs();
}
}
Program: 132798
Project: 132798
Buggy source:
@Override public List<Var> tryPiggyback(Counters<Var> increments,RefCountType type){
switch (op) {
case LOAD_SCALAR:
case LOAD_FILE:
case LOAD_REF:
case LOAD_ARRAY:
case LOAD_BAG:
case LOAD_STRUCT:
case LOAD_RECURSIVE:
{
      Var inVar=getInput(0).getVar();
      if (type == RefCountType.READERS) {
        long amt=increments.getCount(inVar);
        if (amt < 0) {
          assert(getInputs().size() == 1);
          this.inputs=Arrays.asList(getInput(0),Arg.createIntLit(amt * -1));
          return inVar.asList();
        }
      }
      break;
    }
case ARR_STORE:
case ARR_COPY_IN_IMM:
case ARR_STORE_FUTURE:
case ARR_COPY_IN_FUTURE:
{
    Var arr=getOutput(0);
    if (type == RefCountType.WRITERS) {
      long amt=increments.getCount(arr);
      if (amt < 0) {
        assert(getInputs().size() == 2);
        int defaultDecr=op == Opcode.ARR_STORE ? 0 : 1;
        Arg decrArg=Arg.createIntLit(amt * -1 + defaultDecr);
        this.inputs=Arrays.asList(getInput(0),getInput(1),decrArg);
        return arr.asList();
      }
    }
    break;
  }
case ARR_CREATE_NESTED_IMM:
case ARRAY_CREATE_BAG:
{
  Var nested=getOutput(0);
  assert(getInputs().size() == 3);
  return tryPiggyBackHelper(increments,type,nested,1,2);
}
case BAG_INSERT:
{
Var bag=getOutput(0);
return tryPiggyBackHelper(increments,type,bag,-1,1);
}
default :
}
return Var.NONE;
}

Fixed version (ground truth):
@Override public List<Var> tryPiggyback(Counters<Var> increments,RefCountType type){
switch (op) {
case LOAD_SCALAR:
case LOAD_FILE:
case LOAD_ARRAY:
case LOAD_BAG:
case LOAD_STRUCT:
case LOAD_RECURSIVE:
{
      Var inVar=getInput(0).getVar();
      if (type == RefCountType.READERS) {
        long amt=increments.getCount(inVar);
        if (amt < 0) {
          assert(getInputs().size() == 1);
          this.inputs=Arrays.asList(getInput(0),Arg.createIntLit(amt * -1));
          return inVar.asList();
        }
      }
      break;
    }
case LOAD_REF:
  Var inVar=getInput(0).getVar();
if (type == RefCountType.READERS) {
  long amt=increments.getCount(inVar);
  if (amt < 0) {
    assert(getInputs().size() == 3);
    this.inputs=Arrays.asList(getInput(0),getInput(1),getInput(2),Arg.createIntLit(amt * -1));
    return inVar.asList();
  }
}
break;
case ARR_STORE:
case ARR_COPY_IN_IMM:
case ARR_STORE_FUTURE:
case ARR_COPY_IN_FUTURE:
{
Var arr=getOutput(0);
if (type == RefCountType.WRITERS) {
long amt=increments.getCount(arr);
if (amt < 0) {
  assert(getInputs().size() == 2);
  int defaultDecr=op == Opcode.ARR_STORE ? 0 : 1;
  Arg decrArg=Arg.createIntLit(amt * -1 + defaultDecr);
  this.inputs=Arrays.asList(getInput(0),getInput(1),decrArg);
  return arr.asList();
}
}
break;
}
case ARR_CREATE_NESTED_IMM:
case ARRAY_CREATE_BAG:
{
Var nested=getOutput(0);
assert(getInputs().size() == 3);
return tryPiggyBackHelper(increments,type,nested,1,2);
}
case BAG_INSERT:
{
Var bag=getOutput(0);
return tryPiggyBackHelper(increments,type,bag,-1,1);
}
default :
}
return Var.NONE;
}
Program: 132799
Project: 132799
Buggy source:
/** 
 * Represent that these are aliases for one another
 * @param var1
 * @param var2
 * @return
 */
public static ComponentAlias directAlias(Var var1,Var var2){
  return new ComponentAlias(var1,var2,Arg.NONE);
}

Fixed version (ground truth):
/** 
 * Represent that these are aliases for one another
 * @param var1
 * @param var2
 * @return
 */
public static ComponentAlias directAlias(Var var1,Var var2){
  return new ComponentAlias(var2,Arg.NONE,var1);
}
Program: 132800
Project: 132800
Buggy source:
/** 
 * Constructor for reference var being dereferenced
 * @param var
 * @param ref
 * @return
 */
public static ComponentAlias ref(Var var,Var ref){
  return new ComponentAlias(var,ref,Collections.<Arg>singletonList(null));
}

Fixed version (ground truth):
/** 
 * Constructor for reference var being dereferenced
 * @param var
 * @param ref
 * @return
 */
public static ComponentAlias ref(Var var,Var ref){
  return new ComponentAlias(ref,Collections.<Arg>singletonList(null),var);
}
Program: 132801
Project: 132801
Buggy source:
public ComponentAlias(Var part,Var whole,Arg key){
  this(part,whole,key.asList());
}

Fixed version (ground truth):
public ComponentAlias(Var whole,Arg key,Var part){
  this(whole,key.asList(),part);
}
Program: 132802
Project: 132802
Buggy source:
public Node(Var var){
  this.var=var;
}

Fixed version (ground truth):
private Node(Var var,int id){
  this.var=var;
  this.id=id;
}
Program: 132803
Project: 132803
Buggy source:
/** 
 * Get node corresponding to variable
 * @param var
 * @return
 */
private Node getVarNode(Var var){
  Node node=varNodes.get(var);
  if (node == null) {
    node=new Node(var);
    varNodes.put(var,node);
  }
  return node;
}

Fixed version (ground truth):
/** 
 * Get node corresponding to variable
 * @param var
 * @return
 */
private Node getVarNode(Var var){
  Node node=varNodes.get(var);
  if (node == null) {
    node=new Node(var,nextNodeID++);
    varNodes.put(var,node);
  }
  return node;
}
Program: 132804
Project: 132804
Buggy source:
/** 
 * Add a (potential) component relationship
 * @param part
 * @param whole enclosing structure
 * @param key relation from whole to part
 */
public void addPotentialComponent(Var part,Var whole,List<Arg> key){
  assert(!key.isEmpty());
  Node wholeNode=getVarNode(whole);
  Node partNode=getVarNode(part);
  Node curr=partNode;
  for (int i=0; i < key.size(); i++) {
    Arg keyElem=key.get(i);
    if (keyElem != null && !keyElem.isConstant()) {
      keyElem=null;
    }
    assert(keyElem == null || keyElem.isConstant());
    Node parent;
    if (i == key.size() - 1) {
      parent=wholeNode;
    }
 else {
      parent=Node.anonymous();
    }
    parents.put(curr,new Edge(parent,keyElem));
    children.put(parent,new Edge(curr,keyElem));
  }
}

Fixed version (ground truth):
/** 
 * Add a (potential) component relationship
 * @param whole enclosing structure
 * @param key relation from whole to part
 * @param part
 */
public void addPotentialComponent(Var whole,List<Arg> key,Var part){
  assert(!key.isEmpty());
  Node wholeNode=getVarNode(whole);
  Node partNode=getVarNode(part);
  if (logger.isTraceEnabled()) {
    logger.trace("String_Node_Str" + whole + "String_Node_Str"+ keyToString(key)+ "String_Node_Str"+ part);
  }
  Node curr=wholeNode;
  for (int i=0; i < key.size(); i++) {
    Arg keyElem=key.get(i);
    if (keyElem != null && !keyElem.isConstant()) {
      keyElem=null;
    }
    assert(keyElem == null || keyElem.isConstant());
    Node child;
    if (i == key.size() - 1) {
      child=partNode;
    }
 else {
      child=getAnonNode(curr,keyElem);
    }
    children.put(curr,new Edge(child,keyElem));
    parents.put(child,new Edge(curr,keyElem));
    logger.trace(child + "String_Node_Str" + keyToString(keyElem)+ "String_Node_Str"+ curr);
    curr=child;
  }
}
Program: 132805
Project: 132805
Buggy source:
public ComponentGraph(){
  this.varNodes=new HashMap<Var,Node>();
  this.parents=new MultiMap<Node,Edge>();
  this.children=new MultiMap<Node,Edge>();
  this.aliases=new MultiMap<Node,Node>();
}

Fixed version (ground truth):
public ComponentGraph(){
  this.nextNodeID=0;
  this.varNodes=new HashMap<Var,Node>();
  this.anonNodes=new HashMap<Pair<Node,Arg>,Node>();
  this.parents=new MultiMap<Node,Edge>();
  this.children=new MultiMap<Node,Edge>();
  this.aliases=new MultiMap<Node,Node>();
}
Program: 132806
Project: 132806
Buggy source:
public static Node anonymous(){
  return new Node(null);
}

Fixed version (ground truth):
public static Node anonymous(int id){
  return new Node(null,id);
}
Program: 132807
Project: 132807
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + parents + "String_Node_Str"+ children+ "String_Node_Str"+ aliases+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + keyToString(label) + "String_Node_Str"+ dst+ "String_Node_Str";
}
Program: 132809
Project: 132809
Buggy source:
public static Instruction assignOutputFile(Block block,List<Statement> instBuffer,boolean storeOutputMapping,Var file,Var fileVal){
  Instruction store;
  Arg storeFilename;
  if (storeOutputMapping) {
    Var isMapped=block.declareUnmapped(Types.V_BOOL,block.uniqueVarName(Var.OPT_VAR_PREFIX),Alloc.LOCAL,DefType.LOCAL_COMPILER,VarProvenance.unknown());
    Var storeFilenameV=block.declareUnmapped(Types.V_BOOL,block.uniqueVarName(Var.OPT_VAR_PREFIX),Alloc.LOCAL,DefType.LOCAL_COMPILER,VarProvenance.unknown());
    instBuffer.add(TurbineOp.isMapped(isMapped,file));
    instBuffer.add(Builtin.createLocal(BuiltinOpcode.NOT,storeFilenameV,isMapped.asArg()));
    storeFilename=storeFilenameV.asArg();
  }
 else {
    storeFilename=Arg.FALSE;
  }
  store=TurbineOp.assignFile(file,fileVal.asArg(),storeFilename);
  return store;
}

Fixed version (ground truth):
public static void assignOutputFile(Block block,List<Statement> instBuffer,boolean storeOutputMapping,Var file,Var fileVal){
  Arg storeFilename;
  if (storeOutputMapping) {
    Var isMapped=block.declareUnmapped(Types.V_BOOL,block.uniqueVarName(Var.OPT_VAR_PREFIX),Alloc.LOCAL,DefType.LOCAL_COMPILER,VarProvenance.unknown());
    Var storeFilenameV=block.declareUnmapped(Types.V_BOOL,block.uniqueVarName(Var.OPT_VAR_PREFIX),Alloc.LOCAL,DefType.LOCAL_COMPILER,VarProvenance.unknown());
    instBuffer.add(TurbineOp.isMapped(isMapped,file));
    instBuffer.add(Builtin.createLocal(BuiltinOpcode.NOT,storeFilenameV,isMapped.asArg()));
    storeFilename=storeFilenameV.asArg();
  }
 else {
    storeFilename=Arg.FALSE;
  }
  instBuffer.add(TurbineOp.assignFile(file,fileVal.asArg(),storeFilename));
}
Program: 132810
Project: 132810
Buggy source:
private void initialiseStruct(Context context,Var struct) throws UndefinedTypeException, DoubleDefineException {
  StructType structType=(StructType)struct.type().getImplType();
  List<List<String>> fieldPaths=new ArrayList<List<String>>();
  List<Arg> fieldVals=new ArrayList<Arg>();
  Deque<String> currFieldPath=new ArrayDeque<String>();
  int initFieldCount=initialiseStructRec(context,struct,currFieldPath,structType,fieldPaths,fieldVals);
  if (initFieldCount > 0) {
    backend.structInitFields(struct,fieldPaths,fieldVals,Arg.createIntLit(initFieldCount));
  }
}

Fixed version (ground truth):
private void initialiseStruct(Context context,Var struct) throws UndefinedTypeException, DoubleDefineException {
  StructType structType=(StructType)struct.type().getImplType();
  List<List<String>> fieldPaths=new ArrayList<List<String>>();
  List<Arg> fieldVals=new ArrayList<Arg>();
  Deque<String> currFieldPath=new ArrayDeque<String>();
  int initFieldCount=initialiseStructRec(context,struct,currFieldPath,structType,fieldPaths,fieldVals);
  if (initFieldCount > 0) {
    backend.structInitFields(VarRepr.backendVar(struct),fieldPaths,VarRepr.backendArgs(fieldVals),Arg.createIntLit(initFieldCount));
  }
}
Program: 132811
Project: 132811
Buggy source:
/** 
 * @param fieldPaths if null, not filled
 * @param fieldPathsArgs if null, not filled
 * @param fieldVals if null, not filled
 * @return writeDecr
 */
private Arg unpackStructInitArgs(Out<List<List<String>>> fieldPaths,Out<List<List<Arg>>> fieldPathsArgs,Out<List<Arg>> fieldVals){
  if (fieldPaths != null) {
    fieldPaths.val=new ArrayList<List<String>>();
  }
  if (fieldPathsArgs != null) {
    fieldPathsArgs.val=new ArrayList<List<Arg>>();
  }
  if (fieldVals != null) {
    fieldVals.val=new ArrayList<Arg>();
  }
  int pos=0;
  while (pos < inputs.size() - 1) {
    long pathLength=inputs.get(pos).getIntLit();
    assert(pathLength > 0 && pathLength <= Integer.MAX_VALUE);
    pos++;
    List<String> fieldPath=(fieldPaths == null) ? null : new ArrayList<String>((int)pathLength);
    List<Arg> fieldPathArgs=(fieldPathsArgs == null) ? null : new ArrayList<Arg>((int)pathLength);
    for (int i=0; i < pathLength; i++) {
      if (fieldPath != null) {
        fieldPath.add(inputs.get(pos).getStringLit());
      }
      if (fieldPathArgs != null) {
        fieldPathArgs.add(inputs.get(pos));
      }
      pos++;
    }
    Arg fieldVal=inputs.get(pos);
    pos++;
    if (fieldPaths != null) {
      fieldPaths.val.add(fieldPath);
    }
    if (fieldPaths != null) {
      fieldPathsArgs.val.add(fieldPathArgs);
    }
    if (fieldVals != null) {
      fieldVals.val.add(fieldVal);
    }
  }
  Arg writeDecr=getInput(pos);
  return writeDecr;
}

Fixed version (ground truth):
/** 
 * @param fieldPaths if null, not filled
 * @param fieldPathsArgs if null, not filled
 * @param fieldVals if null, not filled
 * @return writeDecr
 */
private Arg unpackStructInitArgs(Out<List<List<String>>> fieldPaths,Out<List<List<Arg>>> fieldPathsArgs,Out<List<Arg>> fieldVals){
  if (fieldPaths != null) {
    fieldPaths.val=new ArrayList<List<String>>();
  }
  if (fieldPathsArgs != null) {
    fieldPathsArgs.val=new ArrayList<List<Arg>>();
  }
  if (fieldVals != null) {
    fieldVals.val=new ArrayList<Arg>();
  }
  int pos=0;
  while (pos < inputs.size() - 1) {
    long pathLength=inputs.get(pos).getIntLit();
    assert(pathLength > 0 && pathLength <= Integer.MAX_VALUE);
    pos++;
    List<String> fieldPath=(fieldPaths == null) ? null : new ArrayList<String>((int)pathLength);
    List<Arg> fieldPathArgs=(fieldPathsArgs == null) ? null : new ArrayList<Arg>((int)pathLength);
    for (int i=0; i < pathLength; i++) {
      if (fieldPath != null) {
        fieldPath.add(inputs.get(pos).getStringLit());
      }
      if (fieldPathArgs != null) {
        fieldPathArgs.add(inputs.get(pos));
      }
      pos++;
    }
    Arg fieldVal=inputs.get(pos);
    pos++;
    if (fieldPaths != null) {
      fieldPaths.val.add(fieldPath);
    }
    if (fieldPathsArgs != null) {
      fieldPathsArgs.val.add(fieldPathArgs);
    }
    if (fieldVals != null) {
      fieldVals.val.add(fieldVal);
    }
  }
  Arg writeDecr=getInput(pos);
  return writeDecr;
}
Program: 132812
Project: 132812
Buggy source:
/** 
 * Lookup subscript in a variable
 * @param var
 * @param subscript
 * @return
 */
public static Expression lookupStruct(Value var,Expression subscript,Expression decrRead){
  return Square.fnCall(STRUCT_LOOKUP,var,subscript,decrRead);
}

Fixed version (ground truth):
/** 
 * Lookup subscript in a variable
 * @param var
 * @param subscript
 * @return
 */
public static Expression lookupStruct(Value var,Expression subscript,Expression decrRead){
  return Square.fnCall(LOOKUP_STRUCT,var,subscript,decrRead);
}
Program: 132813
Project: 132813
Buggy source:
/** 
 * Return base reference count for type, i.e. what it's initialized to by default 
 * @param rcType 
 * @param blockVar
 * @param trackedCountOnly return only refcounts tracked by STC(not auto-decremented on assign)
 * @return
 */
private static long baseRefCount(Type type,DefType defType,RefCountType rcType,boolean trackedCountOnly){
}

Fixed version (ground truth):
/** 
 * Return base reference count for type, i.e. what it's initialized to by default 
 * @param rcType 
 * @param blockVar
 * @param trackedCountOnly return only refcounts tracked by STC(not auto-decremented on assign)
 * @return
 */
private static long baseRefCount(Type type,DefType defType,RefCountType rcType,boolean trackedCountOnly){
  if (Types.isStruct(type)) {
    StructType structT=(StructType)type.type().getImplType();
    long count=0;
    for (    StructField field : structT.getFields()) {
      count+=baseRefCount(field.getType(),defType,rcType,trackedCountOnly);
    }
    return count;
  }
 else   if (Types.isPrimValue(type) || Types.isContainerLocal(type) || Types.isStructLocal(type)) {
    return 0;
  }
 else {
    if (trackedCountOnly) {
      if (trackRefCount(type,defType,rcType)) {
        return 1;
      }
 else {
        return 0;
      }
    }
 else {
      return 1;
    }
  }
}
Program: 132815
Project: 132815
Buggy source:
public void structCreateAlias(Var fieldAlias,Var struct,List<String> fieldPath){
  assert(Types.isStruct(struct));
  assert(Types.isStructField(struct,fieldPath,fieldAlias));
  assert(fieldAlias.storage() == Alloc.ALIAS);
  currBlock().addInstruction(TurbineOp.structCreateAlias(fieldAlias,struct,fieldPath));
}

Fixed version (ground truth):
public void structCreateAlias(Var fieldAlias,Var struct,List<String> fieldPath){
}
Program: 132817
Project: 132817
Buggy source:
private void addInferred(GlobalConstants consts,String errContext,CongruentSets congruent,int stmtIndex,Arg canonLoc,ArgOrCV canonVal) throws OptUnsafeError {
  if (canonVal.isCV()) {
    for (    ArgCV extra : Algebra.tryAlgebra(this,canonVal.cv())) {
      update(consts,errContext,canonLoc,extra,IsAssign.NO,congruent,false,stmtIndex);
    }
  }
}

Fixed version (ground truth):
private void addInferred(GlobalConstants consts,String errContext,CongruentSets congruent,int stmtIndex,Arg canonLoc,ArgOrCV canonVal) throws OptUnsafeError {
  if (canonVal.isCV()) {
    ArgCV cv=canonVal.cv();
    for (    ArgCV extra : Algebra.tryAlgebra(this,cv)) {
      update(consts,errContext,canonLoc,extra,IsAssign.NO,congruent,false,stmtIndex);
    }
    if (cv.isArrayMemberVal() || cv.isArrayMemberRef()) {
      Var arr=cv.getInput(0).getVar();
      Arg ix=cv.getInput(1);
      update(consts,errContext,Arg.TRUE,ComputedValue.arrayContainsCV(arr,ix),IsAssign.NO,congruent,false,stmtIndex);
    }
  }
}
Program: 132818
Project: 132818
Buggy source:
public static Type derefResultType(Typed t){
  if (isScalarFuture(t) || isScalarUpdateable(t)) {
    return new ScalarValueType(t.type().primType());
  }
 else   if (isFile(t)) {
    return new FileValueType(t.type().fileKind());
  }
 else   if (isRef(t)) {
    return t.type().baseType().memberType();
  }
 else   if (isArray(t)) {
    ArrayType at=(ArrayType)t.type().getImplType();
    return new ArrayType(true,at.keyType(),at.memberType());
  }
 else   if (isBag(t)) {
    BagType bt=(BagType)t.type().getImplType();
    return new BagType(true,bt.memberType());
  }
 else {
    throw new STCRuntimeError(t.type() + "String_Node_Str");
  }
}

Fixed version (ground truth):
public static Type derefResultType(Typed t){
  if (isScalarFuture(t) || isScalarUpdateable(t)) {
    return new ScalarValueType(t.type().primType());
  }
 else   if (isFile(t)) {
    return new FileValueType(t.type().fileKind());
  }
 else   if (isRef(t)) {
    return t.type().baseType().memberType();
  }
 else   if (isArray(t)) {
    ArrayType at=(ArrayType)t.type().getImplType();
    return ArrayType.localArray(at.keyType(),at.memberType());
  }
 else   if (isBag(t)) {
    BagType bt=(BagType)t.type().getImplType();
    return BagType.localBag(bt.memberType());
  }
 else {
    throw new STCRuntimeError(t.type() + "String_Node_Str");
  }
}
Program: 132820
Project: 132820
Buggy source:
/** 
 * @param type
 * @param var the name of the variable this is the value of:try and work this into the generated name. Can be left as null
 * @return
 * @throws UserException
 */
@Override public Var createLocalValueVariable(Type type,Var var) throws UserException {
  String varName;
  VarProvenance prov;
  if (var != null) {
    prov=VarProvenance.valueOf(var,getSourceLoc());
    varName=var.name();
  }
 else {
    prov=VarProvenance.exprTmp(getSourceLoc());
    varName=null;
  }
  Alloc storage;
  if (Types.isPrimValue(type)) {
    storage=Alloc.LOCAL;
  }
 else {
    storage=Alloc.ALIAS;
  }
  String name=chooseVariableName(Var.LOCAL_VALUE_VAR_PREFIX,varName,"String_Node_Str");
  return declareVariable(type,name,storage,DefType.LOCAL_COMPILER,prov,null);
}

Fixed version (ground truth):
/** 
 * @param type
 * @param var the name of the variable this is the value of:try and work this into the generated name. Can be left as null
 * @return
 * @throws UserException
 */
@Override public Var createLocalValueVariable(Type type,Var var) throws UserException {
  String varName;
  VarProvenance prov;
  if (var != null) {
    prov=VarProvenance.valueOf(var,getSourceLoc());
    varName=var.name();
  }
 else {
    prov=VarProvenance.exprTmp(getSourceLoc());
    varName=null;
  }
  Alloc storage;
  if (Types.isPrimValue(type) || Types.isContainerLocal(type)) {
    storage=Alloc.LOCAL;
  }
 else {
    storage=Alloc.ALIAS;
  }
  String name=chooseVariableName(Var.LOCAL_VALUE_VAR_PREFIX,varName,"String_Node_Str");
  return declareVariable(type,name,storage,DefType.LOCAL_COMPILER,prov,null);
}
Program: 132821
Project: 132821
Buggy source:
/** 
 * Initialize the context and define the two variables: for array member and (optionally) for the loop count
 * @param context
 * @param rangeLoop where a range loop or container
 * @param includeIndexFuture if true, initialize the count var(getCountVarName()), rather than just loopCountval
 * @return
 * @throws UserException
 */
public Context setupLoopBodyContext(Context context,boolean rangeLoop,boolean includeIndexFuture) throws UserException {
  Type arrayType=findArrayType(context);
  loopBodyContext=new LocalContext(context);
  if (countVarName != null) {
    if (!Types.isArray(arrayType) && !Types.isArrayRef(arrayType)) {
      throw new UserException("String_Node_Str" + "String_Node_Str" + arrayType.typeName());
    }
    keyType=Types.arrayKeyType(arrayType);
    Type keyValType=Types.derefResultType(keyType);
    Var countVar=createCountVar(context);
    loopCountVal=context.createLocalValueVariable(keyValType,countVar);
    if (includeIndexFuture) {
      loopBodyContext.declareVariable(countVar);
    }
  }
 else {
    loopCountVal=null;
  }
  memberVar=loopBodyContext.declareVariable(findElemType(arrayType),getMemberVarName(),Alloc.TEMP,DefType.LOCAL_USER,VarProvenance.userVar(context.getSourceLoc()),null);
  Type memberValType=Types.derefResultType(VarRepr.fieldRepr(memberVar.type()));
  memberVal=loopBodyContext.createLocalValueVariable(memberValType,memberVar);
  return loopBodyContext;
}

Fixed version (ground truth):
/** 
 * Initialize the context and define the two variables: for array member and (optionally) for the loop count
 * @param context
 * @param rangeLoop where a range loop or container
 * @param includeIndexFuture if true, initialize the count var(getCountVarName()), rather than just loopCountval
 * @return
 * @throws UserException
 */
public Context setupLoopBodyContext(Context context,boolean rangeLoop,boolean includeIndexFuture) throws UserException {
  Type arrayType=findArrayType(context);
  loopBodyContext=new LocalContext(context);
  if (countVarName != null) {
    if (!Types.isArray(arrayType) && !Types.isArrayRef(arrayType)) {
      throw new UserException("String_Node_Str" + "String_Node_Str" + arrayType.typeName());
    }
    keyType=Types.arrayKeyType(arrayType);
    Type keyValType=Types.derefResultType(keyType);
    Var countVar=createCountVar(context);
    loopCountVal=context.createLocalValueVariable(keyValType,countVar);
    if (includeIndexFuture) {
      loopBodyContext.declareVariable(countVar);
    }
  }
 else {
    loopCountVal=null;
  }
  memberVar=loopBodyContext.declareVariable(findElemType(arrayType),getMemberVarName(),Alloc.TEMP,DefType.LOCAL_USER,VarProvenance.userVar(context.getSourceLoc()),null);
  Type memberValRepr=VarRepr.fieldRepr(memberVar.type());
  if (Types.isRef(memberValRepr)) {
    memberVal=null;
  }
 else {
    Type memberValType=Types.derefResultType(memberValRepr);
    memberVal=loopBodyContext.createLocalValueVariable(memberValType,memberVar);
  }
  return loopBodyContext;
}
Program: 132822
Project: 132822
Buggy source:
public void assignScalar(Var dst,Arg src){
  assert(Types.isScalarFuture(dst));
  assert(Types.isScalarValue(src));
  assert(src.type().assignableTo(Types.derefResultType(dst)));
  currBlock().addInstruction(TurbineOp.assignScalar(dst,src));
}

Fixed version (ground truth):
public void assignScalar(Var dst,Arg src){
}
Program: 132823
Project: 132823
Buggy source:
public void assignArray(Var target,Arg src){
  assert(Types.isArray(target.type()));
  assert(Types.isArrayLocal(src.type()));
  assert(Types.containerElemType(src.type()).assignableTo(Types.containerElemType(target)));
  currBlock().addInstruction(TurbineOp.assignArray(target,src));
}

Fixed version (ground truth):
public void assignArray(Var target,Arg src){
}
Program: 132825
Project: 132825
Buggy source:
@Override public void arrayRefCopyOutFuture(Var oVar,Var arrayVar,Var indexVar){
  assert(Types.isArrayRef(arrayVar));
  assert(Types.isElemType(arrayVar,oVar));
  assert(Types.isArrayKeyFuture(arrayVar,indexVar));
  Command getRef=Turbine.arrayLookupComputed(varToExpr(oVar),refRepresentationType(oVar.type().memberType(),false),varToExpr(arrayVar),varToExpr(indexVar),true);
  pointAdd(getRef);
}

Fixed version (ground truth):
@Override public void arrayRefCopyOutFuture(Var oVar,Var arrayVar,Var indexVar){
  assert(Types.isArrayRef(arrayVar));
  assert(Types.isElemType(arrayVar,oVar));
  assert(Types.isArrayKeyFuture(arrayVar,indexVar));
  Command getRef=Turbine.arrayLookupComputed(varToExpr(oVar),representationType(oVar.type(),false),varToExpr(arrayVar),varToExpr(indexVar),true);
  pointAdd(getRef);
}