Actually, comparative advantage - the notion that countries should specialize in producing what they can do cheapest - came from David Ricardo, an advocate of "free trade", but NOT, as the astute Mr. Head points out, of free markets. It's basic flaw is that ignores the profit motive.
Ricardo, incidentally, greatly influenced Marx and his ideas formed much of the bases of Marxism / Socialism.
Actually, it optimizes profits for the ruling elite.
It's flaw is that it treats labor as a mere commodity, with all the rights, privileges and political self-interest of a damn sugar-beet.