PALO ALTO — Sullivan & Cromwell and Fenwick & West advised Zynga Inc. and NaturalMotion Ltd., respectively, on the San Francisco gamemaker’s $525 million acquisition of its UK rival. The acquisition for $391 million in cash plus 39.5 million shares of Class A common stock marks Zynga’s largest to date.

The struggling social game developer announced the acquisition Thursday as it disclosed fourth quarter results. The company booked a net loss of $25 million—an improvement over last year’s results—and said it would lay off 15 percent of its workforce. Share prices soared 20 percent on the news, which analysts said showed signs Zynga was not only stabilizing but also improving its mobile prospects and potential user base significantly. Zynga, which went public in 2011, continues to trade at less than $5 a share.