The function has a useless declaration of variable "res". Also useless is the initial "result := 0;" assignment.
Here is the content of the function.
function CompareStr(const S1, S2: string): Integer;
var res,count, count1, count2: SizeInt;
begin
result := 0;
Count1 := Length(S1);
Count2 := Length(S2);
if Count1>Count2 then
Count:=Count2
else
Count:=Count1;
result := CompareMemRange(Pointer(S1),Pointer(S2), Count);
if result=0 then
// CAPSIZEINT is no-op if Sizeof(Sizeint)<=SizeOF(Integer)
result:=CAPSIZEINT(Count1-Count2);
end;