The star formation main sequence and stellar mass assembly of galaxies in the Illustris simulation