Yeesh, rough situation. However, in all my knowledge, I would say count the bucket. This is, of course, assuming you had more than a few seconds remaining on the game clock.
As for the clock, you can only take time off the clock if you're aware of exactly how much ticked off, which you should be able to do by using the shot clock and some subtraction.
Of course, the best way to handle this is always peek at the clock as soon as the ball becomes live to make sure it's a runnin'.