Rewrite of SPMC in C