as effectively connected with the conduct of such trade or business to the extent such gain or loss does not exceed the amount determined under subparagraph (B). (B) Amount treated as effectively connected The amount determined under this subparagraph with respect to any partnership interest sold or exchanged— (i) in the case of any gain on the sale or exchange of the partnership interest, is— (I) the portion of the partner's distributive share of the amount of gain which would have been effectively connected with the conduct of a trade or business within the United States if the partnership had sold all of its assets at their fair market value as of the date of the sale or exchange of such interest, or (II) zero if no gain on such deemed sale would have been so effectively connected, and (ii) in the case of any loss on the sale or exchange of the partnership interest, is— (I) the portion of the partner's distributive share of the amount of loss on the deemed sale described in clause (i)(I) which would have been so effectively connected, or (II) zero if no loss on such deemed sale would be have been so effectively connected. For purposes of this subparagraph, a partner's distributive share of gain or loss on the deemed sale shall be determined in the same manner as such partner’s distributive share of the non-separately stated taxable income or loss of such partnership. (C) Coordination with United States real property interests If a partnership described in subparagraph (A) holds any United States real property interest (as defined in section 897(c)) at the time of the sale or exchange of the partnership interest, then the gain or loss treated as effectively connected income under subparagraph (A) shall be reduced by the amount so treated with respect to such United States real property interest under section 897. (D) Sale or exchange For purposes of this paragraph, an individual or corporation shall be treated as having sold or exchanged any interest in a partnership if, under any provision of this subtitle,