Factory output shrank for the first time in three months in December as a decline in machinery production outweighed a small rise in autos, casting a cloud over the economic recovery.