identical C and go code for testing purposes