Buy one xyz @ 10 (average cost 10) Buy 99 xyz @ 3 (average cost 3.07) Sell everything at 5 (193 profit)
Assuming you are subject to U.S. tax laws, the $5.00 loss on the one share bought for $10 would be considered a wash sale. That loss would not be allowed and would instead be added to the basis of one of the 100 shares bought within 30 days of the sale. If this was done in a single account, the broker will probably account for this when reporting information to the IRS. If you were hoping to be able to avoid the wash sale using an average cost basis, that is not allowed for individual stocks.
Like I was wondering what would happen. Occasionally I buy stock, and then it changes against me, and I buy more, and when selling for a net profit, some of the shares might be a loss.