Program: 78266
Project: 78266
Buggy source:
private void compileFunction(Function function){
  if (!function.isUserFunc())   return;
  Set<Var> vars=function.getVars();
  for (  BasicBlock block : function.getBasicBlocks()) {
    for (Instruction inst=block.front(); inst != null; inst=inst.next) {
      for (      Var var : inst.usedVar()) {
        if (!var.isCompareTmp()) {
          var.addUseTime();
          vars.add(var);
        }
      }
      for (      Var var : inst.dstVar()) {
        if (!var.isCompareTmp()) {
          var.addUseTime();
          vars.add(var);
        }
      }
    }
  }
  List<Var> usageRank=new ArrayList<>(vars);
  usageRank.sort(Comparator.comparingInt(Var::useTime).reversed());
  List<PhysicalRegister> allocateRegs=new ArrayList<>(Arrays.asList(RBX,R12,R13,R14,R15));
  for (int index=0, allocateIndex=0; index < usageRank.size() && allocateIndex < allocateRegs.size(); ++index) {
    if (!usageRank.get(index).isGlobal() && !usageRank.get(index).isCompareTmp()) {
      usageRank.get(index).setPhysicalRegister(allocateRegs.get(allocateIndex));
      function.addUsedPReg(allocateRegs.get(allocateIndex));
      ++allocateIndex;
    }
  }
  int paramStackTop=options.PTR_SIZE * 2;
  List<Var> params=function.paramVars();
  for (int index=0; index < params.size(); ++index) {
    if (index >= PhysicalRegister.paramRegs.size()) {
      params.get(index).setStackPos(new Memory(RBP,null,0,paramStackTop));
      paramStackTop+=options.PTR_SIZE;
    }
  }
  int localVarStackTop=function.usedPRegs().size() * options.PTR_SIZE;
  localVarStackTop=locateLocalVariables(function.getSymbolTable(),localVarStackTop);
  int tmpVarStackTop=localVarStackTop;
  for (  Var var : function.getVars()) {
    if (var.isTmp()) {
      tmpVarStackTop+=options.PTR_SIZE;
      var.setStackPos(new Memory(RBP,null,0,-tmpVarStackTop));
    }
  }
  function.setVarStackSize(tmpVarStackTop);
}

Fixed version (ground truth):
private void compileFunction(Function function){
  if (!function.isUserFunc())   return;
  Set<Var> vars=function.getVars();
  for (  BasicBlock block : function.basicBlocks()) {
    for (Instruction inst=block.front(); inst != null; inst=inst.next) {
      for (      Var var : inst.usedVar()) {
        if (!var.isCompareTmp()) {
          var.addUseTime();
          vars.add(var);
        }
      }
      for (      Var var : inst.dstVar()) {
        if (!var.isCompareTmp()) {
          var.addUseTime();
          vars.add(var);
        }
      }
    }
  }
  List<Var> usageRank=new ArrayList<>(vars);
  usageRank.sort(Comparator.comparingInt(Var::useTime).reversed());
  List<PhysicalRegister> allocateRegs=new ArrayList<>(Arrays.asList(RBX,R12,R13,R14,R15));
  function.addUsedPReg(RBP);
  for (int index=0, allocateIndex=0; index < usageRank.size() && allocateIndex < allocateRegs.size(); ++index) {
    if (!usageRank.get(index).isGlobal() && !usageRank.get(index).isCompareTmp()) {
      usageRank.get(index).setPhysicalRegister(allocateRegs.get(allocateIndex));
      function.addUsedPReg(allocateRegs.get(allocateIndex));
      ++allocateIndex;
    }
  }
  int paramStackTop=function.usedPRegs().size() * options.PTR_SIZE + options.PTR_SIZE;
  List<Var> params=function.paramVars();
  for (int index=0; index < params.size(); ++index) {
    if (index >= PhysicalRegister.paramRegs.size()) {
      params.get(index).setStackPos(new Memory(RBP,null,0,paramStackTop));
      paramStackTop+=options.PTR_SIZE;
    }
  }
  int localVarStackTop=options.PTR_SIZE;
  localVarStackTop=locateLocalVariables(function.getSymbolTable(),localVarStackTop);
  int tmpVarStackTop=localVarStackTop;
  for (  Var var : function.getVars()) {
    if (var.isTmp()) {
      tmpVarStackTop+=options.PTR_SIZE;
      var.setStackPos(new Memory(RBP,null,0,-tmpVarStackTop));
    }
  }
  function.setVarStackSize(tmpVarStackTop);
}