Actually, the non-recursive solution DOES work if you pass in the head of the list as the function argument. A good way to visualize it is to draw some arrows between some numbered nodes and keep track of which node each node pointer is currently pointing to. As you iterate through the loop, your arrows will change direction, hence reversing your list. When the loop is done, ptr and temp will both point to null, and previous will point to the start(head) of your reversed list.

I haven’t worked through the recursive solution yet, so no comment on that.

I didn’t know that gcc could perform TCO; that’s pretty cool. I’d still go for the iterative approach, though, since TCO is not part of any C standard (and there aren’t any serious benefits to the recursive version that warrant it being non-portable).

While the recursive solution is something of an interesting novelty, it seems like it is a disaster waiting to happen. If I was the user of the recursive reverse function, I certainly would be very surprised to find out the hard way that it could reverse one linked list, but another (slightly larger) linked list caused a stack overflow.