rewrite to C