rewriting my RWET examples in C