If you're just looking for how a process changes its uid, then look at "man setuid", and the referenced man pages from there.
Otherwise, read "man login" for a description of what happens when a user logs in. There isn't any single "login()" system call or anything like that; instead, there are a whole slew of system calls made by agetty or the like, the login program, and then by the user's shell. If you are interested in a particular part of the login process, then try to be more specific, or use strace to attach to an instance of agetty (you'll need to be root), and watch for yourself.