IANAL.
There are generally two types of bankruptcy. Voluntary and involuntary. Voluntary is where the company on its own initiative files for bankruptcy protection from its creditors and reorganizes under a plan overseen by the bankruptcy court. During this period creditors cannot do anything to foreclose on assets or anything else to prevent the company from continuing operations. Generally, voluntary bankruptcy will have the effect of rewriting loan agreements, interest rates, principal reductions, and some asset sales or lease-backs to the satisfaction of the court. If Tesla were to file for voluntary bankruptcy, one would believe that some debt would be forgiven by creditors, perhaps Elon Musk would contribute some cash as a loan subordinate to any existing and future debt, Tesla would sell off some of its real estate and perhaps lease back under very favorable terms, and maybe even take on a partner with a strong financial condition in a segment of its operations (like the Gigafactory could easily be spun off to relieve a boatload of debt and ongoing operational expenses.)
Involuntary bankruptcy is when a company's creditors force the company into bankruptcy. This is usually not a good thing. A company's assets are valued at fair market and then are liquidated to pay creditors. (Some creditors are secured, while many more are unsecured.) There is a specific ranking order in the law that determines who gets how much to satisfy the debt owed. Under the court's supervision these asset sales and debt repayments occur. Frequently unsecured creditors get pennies (if anything) on the dollar.
In this hypothetical situation, Tesla has many valuable assets whose tangible values (like real estate, machinery and equipment) can be determined, and there would likely be many interested companies out there who would wish to snap up the real estate or manufacturing equipment for their own uses. The unknown for Tesla would be its intangible assets, from software development to its patents and battery technologies. It is within the realm of possibility that another tech firm, perhaps in partnership with an ICE manufacturer would see enormous value in Tesla's intangible assets and buy them in bankruptcy. In this case, I would posit that while the Tesla brand name might not survive, the technology would. I would further posit that current owners like us would still be able to have our cars serviced and repaired. Supercharging might change--it might be eliminated or become a fee-based model for all, regardless of "free for life." Continued software upgrades might fall victim to this putative bankruptcy, with only the new vehicles manufactured after emerging from bankruptcy being able to have this function.
If this were to occur, say, in 2019, there would be over 400,000 Teslas of various types (Roadster, S, X, 3) on the road. That is a large enough base to interest companies to buy Tesla's intangible assets, in my opinion.
Again, IANAL.