BAGHDAD — Human rights groups and diplomats criticized a law that was quietly passed by the Iraqi parliament over the weekend that would impose heavy prison sentences on gay and transgender people. U.S. State Department spokesperson Matthew Miller said in a statement that the law passed Saturday “threatens those most at risk in Iraqi society” and “can be used to hamper free-speech and expression.” He warned that the legislation could drive away foreign investment. “International business coalitions have already indicated that such discrimination in Iraq will harm business and economic growth in the country,” the statement said.