Program: 179116
Project: 179116
Buggy source:
public boolean sellItem(User user,Integer amount){
  Integer amountHas=0;
  Integer amountTaken=0;
  Integer fullAmt=amount;
  HashMap<Integer,? extends ItemStack> matches=user.getHandle().getInventory().all(this.getMaterial());
  for (  ItemStack iStack : matches.values()) {
    amountHas+=iStack.getAmount();
  }
  if (amount > amountHas) {
    return false;
  }
  for (int i=0; i < matches.size(); i++) {
    ItemStack iStack=(ItemStack)matches.values().toArray()[i];
    if (iStack.getDurability() != this.durability) {
      continue;
    }
    Integer slot=(Integer)matches.keySet().toArray()[i];
    if (amountTaken + iStack.getAmount() <= amount) {
      amountTaken+=iStack.getAmount();
      user.getHandle().getInventory().clear(slot);
    }
 else {
      Integer toTake=amount - amountTaken;
      amountTaken+=toTake;
      iStack.setAmount(iStack.getAmount() - toTake);
      user.getHandle().getInventory().setItem(slot,iStack);
    }
    if (amountTaken == amount) {
      break;
    }
  }
  HashMap<Double,Currency> sortedCurrencies=new HashMap<Double,Currency>();
  for (  Currency currencyType : priceFile.getCurrencies()) {
    sortedCurrencies.put(currencyType.getPrice(),currencyType);
  }
  Object[] reversedCurrencies=sortedCurrencies.values().toArray();
  for (int i=0; i < reversedCurrencies.length / 2; i++) {
    Currency temp=(Currency)reversedCurrencies[i];
    reversedCurrencies[i]=reversedCurrencies[reversedCurrencies.length - i - 1];
    reversedCurrencies[reversedCurrencies.length - i - 1]=temp;
  }
  HashMap<Currency,Integer> change=makeChange(amount * cost,reversedCurrencies);
  for (int i=0; i < change.size(); i++) {
    Currency changeCurrency=(Currency)change.keySet().toArray()[i];
    Integer changeAmount=(Integer)change.values().toArray()[i];
    List<Integer> splitamount=new ArrayList<Integer>();
    while (changeAmount > 0) {
      Integer maxAmount=new InventoryBackend(priceFile.plugin).getStackNumber(changeCurrency.getItemId());
      if (changeAmount > maxAmount) {
        splitamount.add(maxAmount);
        changeAmount-=maxAmount;
      }
 else {
        splitamount.add(changeAmount);
        changeAmount=0;
      }
    }
    for (    Integer amt : splitamount) {
      if (user.getHandle().getInventory().firstEmpty() >= 0) {
        user.getHandle().getInventory().addItem(new ItemStack(changeCurrency.getMaterial(),amt));
      }
 else {
        user.getHandle().getWorld().dropItem(user.getHandle().getLocation(),new ItemStack(changeCurrency.getMaterial(),amt));
      }
    }
  }
  supdem-=fullAmt;
  if (supply != -1) {
    supply+=fullAmt;
  }
  return true;
}

Fixed version (ground truth):
public boolean sellItem(User user,Integer amount){
  Integer amountHas=0;
  Integer amountTaken=0;
  Integer fullAmt=amount;
  HashMap<Integer,? extends ItemStack> matches=user.getHandle().getInventory().all(this.getMaterial());
  for (  ItemStack iStack : matches.values()) {
    if (iStack.getDurability() != this.durability) {
      continue;
    }
    amountHas+=iStack.getAmount();
  }
  if (amount > amountHas) {
    return false;
  }
  for (int i=0; i < matches.size(); i++) {
    ItemStack iStack=(ItemStack)matches.values().toArray()[i];
    if (iStack.getDurability() != this.durability) {
      continue;
    }
    Integer slot=(Integer)matches.keySet().toArray()[i];
    if (amountTaken + iStack.getAmount() <= amount) {
      amountTaken+=iStack.getAmount();
      user.getHandle().getInventory().clear(slot);
    }
 else {
      Integer toTake=amount - amountTaken;
      amountTaken+=toTake;
      iStack.setAmount(iStack.getAmount() - toTake);
      user.getHandle().getInventory().setItem(slot,iStack);
    }
    if (amountTaken == amount) {
      break;
    }
  }
  HashMap<Double,Currency> sortedCurrencies=new HashMap<Double,Currency>();
  for (  Currency currencyType : priceFile.getCurrencies()) {
    sortedCurrencies.put(currencyType.getPrice(),currencyType);
  }
  Object[] reversedCurrencies=sortedCurrencies.values().toArray();
  for (int i=0; i < reversedCurrencies.length / 2; i++) {
    Currency temp=(Currency)reversedCurrencies[i];
    reversedCurrencies[i]=reversedCurrencies[reversedCurrencies.length - i - 1];
    reversedCurrencies[reversedCurrencies.length - i - 1]=temp;
  }
  HashMap<Currency,Integer> change=makeChange(amount * cost,reversedCurrencies);
  for (int i=0; i < change.size(); i++) {
    Currency changeCurrency=(Currency)change.keySet().toArray()[i];
    Integer changeAmount=(Integer)change.values().toArray()[i];
    List<Integer> splitamount=new ArrayList<Integer>();
    while (changeAmount > 0) {
      Integer maxAmount=new InventoryBackend(priceFile.plugin).getStackNumber(changeCurrency.getItemId());
      if (changeAmount > maxAmount) {
        splitamount.add(maxAmount);
        changeAmount-=maxAmount;
      }
 else {
        splitamount.add(changeAmount);
        changeAmount=0;
      }
    }
    for (    Integer amt : splitamount) {
      if (user.getHandle().getInventory().firstEmpty() >= 0) {
        user.getHandle().getInventory().addItem(new ItemStack(changeCurrency.getMaterial(),amt));
      }
 else {
        user.getHandle().getWorld().dropItem(user.getHandle().getLocation(),new ItemStack(changeCurrency.getMaterial(),amt));
      }
    }
  }
  supdem-=fullAmt;
  if (supply != -1) {
    supply+=fullAmt;
  }
  return true;
}