A complete answer to your questions is beyond the scope of this question & answer forum. The best I can do is give you a general overview --
In general, transfers of assets to corporations by shareholders
in exchange for stock are not taxable. However, there are several circumstances under which such transfers may be taxable, and you've mentioned a couple of them in your first sentence: where the transferred asset has appreciated in value since the shareholder acquired it and where the asset is subject to debt in excess of its basis. Without knowing the details, it's impossible to say how the shareholder could reduce the tax liability
Section 351 of the Tax
Code deals with transfers to corporations. You can find it online here:
In case this link doesn't work, do a search on U.S. CODE, TITLE 26, Subtitle A, CHAPTER 1, Subchapter C, PART III, Subpart A, Sec. 351.
(even though this is part of Subchapter C, it also applies to S Corporations)
Since this is a fairly complex area of tax law
, the shareholder would be wise to buy a couple of hours of consultation time from a good tax lawyer or CPA.