The Snuggie – the fluffy blanket with sleeves that is designed not to slip off no matter how aggressively you reach for the potato chips – received a big win recently.

A U.S. trade court ruled that the product, a breakaway star of TV shopping that has appeared on “Late Night With Jimmy Fallon,” “The Today Show” and “Oprah,” should be classified as a blanket, rather than clothing, as government lawyers had been trying to claim.

The case might seem strange – why does the government care about classifying Snuggies anyway? But because of variations in tariffs – the taxes that governments place on imports to make foreign products more expensive, and help make domestic manufacturers more competitive – the decision is likely to end up costing the government big and saving the company a bundle.

Every item that moves across the border has a set tariff. That includes the Snuggie, which is made in China.

These tariffs have been hammered out through decades of negotiation between governments and industry lobbies, and often vary for each product category. In the United States, the tariff on imported blankets is 8.5 percent, whereas the tariff on imported “pullover apparel” is significantly higher at 14.9 percent.

That was enough to convince the Hawthorne, N.Y.-based Allstar Marketing Group, which makes the Snuggie, to take the U.S. government to the United States Court of International Trade for categorizing the Snuggie as apparel, similar to a “priestly garment.” The judge sided with Snuggie last month, saying that the product was a blanket, not clothing, in part because its lack of closures in the back. Allstar Marketing declined to comment on the case.

The Snuggie case and others like it show how companies may go to great lengths to avoid the barriers that governments impose on imported products. President Trump has argued for even stiffer tariffs on products from countries that refuse to negotiate better terms of trade with the United States, such as Mexico and China. He also has backed away from free-trade deals that would slash tariffs among many countries, and expressed a desire for negotiating deals with countries one-on-one.

Besides tariffs, the Commerce Department sometimes imposes temporary duties on products as punishment when companies or countries do something that violates international trade laws.

Republicans are also weighing something called a “border adjustment tax,” which would tax imports and subsidize exports. This is not the same as a tariff – it’s a different way of taxing companies that could replace the corporate income tax.

Companies have to grapple with this patchwork of tariff and tax systems as they ship their products around the world. Typically, they try everything in their power to avoid them. If the Trump administration chooses to introduce more tariffs and duties on imported products, it might give U.S. companies an edge in their domestic market. But as other examples show, it’s also likely to encourage firms around the world to engage in wasteful spending that doesn’t end up helping consumers or the economy.

Bryan Riley, a senior policy analyst and advocate for free trade at the Heritage Foundation, says trade barriers have a few less obvious costs. They make Americans pay more for imported goods, and they encourage companies to invest in lobbying the government for special protection from competition. They can encourage companies to revamp their supply chains to, for example, buy a part from Vietnam rather than from China.

Sometimes, the potential savings from avoiding a tariff can encourage companies to redesign their products to get around them, a practice known as “tariff engineering.”

“Companies will employ tariff engineers to make sure products come in at a lower tariff rate, and you can’t tell me there is not a better use for their talent,” said Riley. “It would be a lot easier if companies could just focus on producing what American consumers want, instead of trying to design products to get around the most harmful aspects of U.S. trade barriers.”

For example, America’s high tariffs on sugar have encouraged companies to shift to importing cake mixes and other sugar-rich products instead, says Doug Irwin, an economist at Dartmouth. And when the U.S. imposed a tariff on motorcycles with 700-cc engines and larger in the early 1980s in a bid to protect motorcycle company Harley Davidson, Japanese competitors simply started making a 699-cc version instead, Irwin says.

Halloween costumes walk a similarly thin line, as NPR’s Planet Money has reported. By using a Velcro closure instead of a zipper or button, some products are more likely to be counted as “festive articles” rather than clothing, which is subject to much higher tariffs.

“Firms are very clever at doing this,” Irwin says. “If you put a tariff on a particular product category, they can with a small adjustment get classified as a different product and get around the tariff.”

Friedman says he has tracked the practice of tariff engineering as far back as 1882, when the Supreme Court ruled on a case involving a sugar importer. Duties on sugar were based on the product’s color, so an enterprising company colored its sugar with molasses to get around the tax.

The Supreme Court ruled that the company had the right to do so, as long as it was properly disclosing to customs what its merchandise was and not trying to deceive border agents, Friedman says. Yet the line between redesigning your product and fraudulently misrepresenting it has sometimes proved to be a tricky one, for both companies and courts.

In one 1991 case, a court ruled against a company that had circumvented high duties on feathers by importing them as feather dusters instead. After the dusters arrived in the country, the company took them apart to make them into boas or put them on hats. Because the articles weren’t sold in the condition they were imported, the court decided this was “artifice.”

Another controversial case involving Ford is working its way through the Court of International Trade.

For years, Ford has imported its Transit Connect van as a passenger van – imports that the U.S. taxes at a rate of only 2.5 percent. But once the vehicles enter the United States, Ford sends some of the vehicles to a nearby facility, where workers rip out the rear bench seats and replace the rear windows with solid panels to make the vehicle into a cargo van. In the process, Ford circumvents a hefty tariff of 25 percent on imported cargo vans.

The court is still deciding whether this constitutes “artifice.” But Ford is hardly the first carmaker to employ these kinds of tactics. In the late 1970s, Subaru tried to get around high tariffs on imported pickup trucks by installing plastic seats in truck beds. Other companies have gone so far as to assemble cars abroad, disassemble them into parts to be shipped across the U.S. border, and then reassemble them again once they’re inside the country.

Even when these policies are legal, for economists they can still be troubling. They mean that companies are spending valuable time and money on circumventing trade policy that they could be spending on more useful activities, like innovating or improving customer service.

Trade barriers “definitely force companies to think about undertaking actions that they wouldn’t have otherwise done,” says Chad Bown, a senior fellow at the Peterson Institute of International Economics. “And the question is, well, is that beneficial for the country in some way? I suppose there are instances where it’s possible, but in most instances, no.”