How do I know that I have truly lost interest in research and should drop out of a top CS PhD program?
If available, I would immediately seek out the university counseling services (as mentioned in a comment by @Nate Eldredge ) The things you are mentioning could be symptoms of depression. Or, you may just need some strategies for coping with failure. Often people with your accomplishments haven't experienced much failure in their lives! 

Taking advantage of the (usually low-cost or free, if you are in the U.S.) counselling services at the university will help you sort out which of these things it is. Your counselor can also help you come up with strategies to make well-reasoned life decisions for yourself (or with your committee). Regardless, don't make any rash decisions. 

In the U.S., it is very common for PhD students to deal with these issues and to seek out counseling. An informal straw poll in my PhD cohort revealed that 90% of us had done so, and approximately 60% were on anti-anxiety medication or continued treatment regimes at any given time. The older students even began to organize a yearly workshop to talk about stress and how to get the help you need!  

An update: This 2018 study finds that graduate students are 6x more likely to experience depression and anxiety, compared to the general population.
https://www.insidehighered.com/news/2018/03/06/new-study-says-graduate-students-mental-health-crisis