Tail call optimization is not guaranteed by C, so you are very likely running into a call stack limit as @jimblumberg pointed out.