The condition changes depending on if A < B or A > B. As I put it before:
bool a = A<=X;
bool b = X<=B;
return (a && b) || (A>B && (a || b));
which means (is equivalent to):
bool a = A<=X;
bool b = X<=B;
if(A<=B) {
return a && b;
}else{
return a || b;
}