TIL about lldiv. I've been rolling this by hand for years...