Loss Function Problem In C