Reimplemented montecarlo_one_packet and montecarlo_one_packet_loop in C