c code that implements the Gillespie algorithm