HeartRate Calculation C-code