These comments are made for educational purposes only and do not constitute legal advice. No attorney-client relationship exists between us.
You may not be able to do anything if you bought the "as is." If you were given a warranty, then the dealer must fix the car enough to pass the emissions test. You could ask the dealer to exchange the car, but under the contract, he really doesn't have to do it.
There could be a way to get it fix, even if you bought it as is, if the dealer knew of the defect and failed to disclose it to you, but that is hard to prove.