Trying to convert Java to C