C - code for SAR calculation