The verse orders its events in time: bi-suḥratin places them before daylight; al-dajāj introduces the cock’s call; and ḥīna habba niyāmuhā marks the sleepers’ awakening.
The purpose-lām in li-aʿalla explains why the speaker goes early: to drink another time. It continues the drinking scene of the preceding verses, not an unrelated reference to quenching ordinary thirst.