translated example 8 to C