26 USC 1011 - Adjusted basis for determining gain or loss

(a) General rule 
The adjusted basis for determining the gain or loss from the sale or other disposition of property, whenever acquired, shall be the basis (determined under section 1012 or other applicable sections of this subchapter and subchapters C (relating to corporate distributions and adjustments), K (relating to partners and partnerships), and P (relating to capital gains and losses)), adjusted as provided in section 1016.
(b) Bargain sale to a charitable organization 
If a deduction is allowable under section 170 (relating to charitable contributions) by reason of a sale, then the adjusted basis for determining the gain from such sale shall be that portion of the adjusted basis which bears the same ratio to the adjusted basis as the amount realized bears to the fair market value of the property.