He didn't get an M-16 into the restaurant. He stood outside shooting into the restaurant.
Here's part of an article about the terrorist attack from the Jerusalem Post:
The gunman, standing on a pedestrian footbridge and armed with an M-16 semiautomatic rifle, opened fire first at diners in the "Seafood Market," emptying one magazine at the eatery.
He then changed clips and began firing at the nearby "Mifgash Ha'Steakiya," both located near the intersection of Begin, Lincoln, and Yitzhak Sadeh streets and the offices of the Ma'ariv Hebrew daily.
The terrorist, Ibrahim Mohammed Hasuna, 20, then ran into the second restaurant and began shooting stabbing diners, according to Army Radio.
Hasuna was a resident of the Jabalya refugee camp in the Gaza Strip, and moved to the Ramallah vicinity several years ago.
The Fatah Aksa Brigades took responsibility for the attack in a statement released to the Qatar-based Al-Jazeera network.