Show 'log in' in user menu when not logged in
You can add a menu link to user/login, the access callback of that verifies that it is only shown to anonymous users. Just like user/logout is only visible for logged in users.

The definition of these callbacks() are, as mentioned in the other answer, in user_menu()