In this case 'as if' indicates that sleeping was the possible (_ if) cause of his groaning, but that the groaning may well have been due to some other cause. Mr X stirred and groaned, as if in sleep, but the meat cleaver embedded in his forehead revealed the real cause of his groaning. He had been given the chop!
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.