It should be noted that performing your comparisons using multiple Boolean variables means that you cannot take advantage of short-circuit evaluation.
VS2012, compiled with default release mode settings:
#include <random>
#include <chrono>
#include <iostream>
int main() {
std::srand(time(NULL));
int val = rand(); //prevent compiler from just generating the result at compile time
bool a = val < 10;
bool b = val > 100;
bool c = val > 50;
bool d = val < 60;
bool result = a || b || (c && d);
std::cout << result << std::endl; //prevent compiler from skipping process due to unused result
return 0;
}
Resulting disassembly:
#include <random>
#include <chrono>
#include <iostream>
int main() {
002F1270 push ebp
002F1271 mov ebp,esp
002F1273 push ecx
std::srand(time(NULL));
002F1274 push 0
std::srand(time(NULL));
002F1276 call dword ptr ds:[2F30BCh]
002F127C push eax
002F127D call dword ptr ds:[2F30C8h]
002F1283 add esp,8
int val = rand();
002F1286 call dword ptr ds:[2F30CCh]
bool a = val < 10;
002F128C lea ecx,[eax-0Ah]
002F128F cmp ecx,5Ah
bool result = a || b || (c && d);
002F1292 ja main+34h (02F12A4h)
bool b = val > 100;
bool c = val > 50;
002F1294 cmp eax,32h
bool result = a || b || (c && d);
002F1297 jle main+2Eh (02F129Eh)
bool d = val < 60;
002F1299 cmp eax,3Ch
bool result = a || b || (c && d);
002F129C jl main+34h (02F12A4h)
002F129E mov byte ptr [result],0
002F12A2 jmp main+38h (02F12A8h)
002F12A4 mov byte ptr [result],1
std::cout << result << std::endl;
002F12A8 push dword ptr ds:[2F3024h]
002F12AE mov ecx,dword ptr ds:[2F303Ch]
002F12B4 push dword ptr [result]
002F12B7 call dword ptr ds:[2F302Ch]
002F12BD mov ecx,eax
002F12BF call dword ptr ds:[2F3028h]
return 0;
002F12C5 xor eax,eax
}
002F12C7 mov esp,ebp
002F12C9 pop ebp
002F12CA ret
Compilers are very, very smart.