Add C version for comparison