/*list.c*/
struct list {
struct list *next;
unsigned long val;
};
struct list *reverse(struct list *head) {
if (head == NULL)
return head;
struct list *curr, *prev;
curr = head;
prev = NULL;
while (head->next != NULL) {
curr = head->next;
curr->next = prev;
prev = curr;
head = head->next;
}
curr->next = prev;
return curr;
}