void testCastOps(int y) {
  printf("y = %d, (y == 2 || y == 0) == %d\n", y,
         ((_Bool)(y == 2)) || ((_Bool)(y == 0)));
  printf("y = %d, (y > 2 || y < 5) == %d\n", y,
         ((_Bool)(y < 2)) && ((_Bool)(y > -10)));
  printf("y = %d, (y ^ 2 ^ ~y) == %d\n", y, (_Bool)(y ^ 2 ^ ~5));
}


x86 assembly (clang, -O0):
<testCastOps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x2,-0x4(%rbp)
mov    %al,-0x5(%rbp)
je     113a <testCastOps+0x2a>
cmpl   $0x0,-0x4(%rbp)
sete   %al
mov    %al,-0x5(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%edx
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x2,-0x4(%rbp)
mov    %al,-0xd(%rbp)
jge    1172 <testCastOps+0x62>
cmpl   $0xfffffff6,-0x4(%rbp)
setg   %al
mov    %al,-0xd(%rbp)
mov    -0x14(%rbp),%esi
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%eax
xor    $0x2,%eax
xor    $0xfffffffa,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testCastOps>:
push   %rbx
mov    %edi,%ebx
xor    %edx,%edx
test   $0xfffffffd,%edi
sete   %dl
lea    0xedb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x9(%rbx),%eax
xor    %edx,%edx
cmp    $0xb,%eax
setb   %dl
lea    0xee2(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %edx,%edx
cmp    $0xfffffff8,%ebx
setne  %dl
lea    0xeea(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"y = %d, (y == 2 || y == 0) == %d\0A\00"
@.str.1 = [32 x i8] c"y = %d, (y > 2 || y < 5) == %d\0A\00"
@.str.2 = [28 x i8] c"y = %d, (y ^ 2 ^ ~y) == %d\0A\00"
define void @testCastOps(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 2
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br label %9
9: ; preds = %6, %1
%10 = phi i1 [ true, %1 ], [ %8, %6 ]
%11 = zext i1 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %11)
%13 = load i32, i32* %2
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, -10
br label %19
19: ; preds = %16, %9
%20 = phi i1 [ false, %9 ], [ %18, %16 ]
%21 = zext i1 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %21)
%23 = load i32, i32* %2
%24 = load i32, i32* %2
%25 = xor i32 %24, 2
%26 = xor i32 %25, -6
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"y = %d, (y == 2 || y == 0) == %d\0A\00"
@.str.1 = [32 x i8] c"y = %d, (y > 2 || y < 5) == %d\0A\00"
@.str.2 = [28 x i8] c"y = %d, (y ^ 2 ^ ~y) == %d\0A\00"
define void @testCastOps(i32 %0) {
%2 = and i32 %0, -3
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %4)
%6 = add i32 %0, 9
%7 = icmp ult i32 %6, 11
%8 = zext i1 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %8)
%10 = icmp ne i32 %0, -8
%11 = zext i1 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %11)
ret void
}