tranlsated example 4 to C