void boolop_loops() {
  int i = 100;
  while (i && i > 50)
    i--;
  while ((i % 2) || (i > 0))
    i--;
  for (i = 100; i && i > 50; --i)
    ;
  for (; (i % 2) || (i > 0); --i)
    ;
}


x86 assembly (clang, -O0):
<boolop_loops>:
push   %rbp
mov    %rsp,%rbp
movl   $0x64,-0x4(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x5(%rbp)
je     1124 <boolop_loops+0x24>
cmpl   $0x32,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    1134 <boolop_loops+0x34>
jmp    1142 <boolop_loops+0x42>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    110b <boolop_loops+0xb>
jmp    1147 <boolop_loops+0x47>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x6(%rbp)
jne    116a <boolop_loops+0x6a>
cmpl   $0x0,-0x4(%rbp)
setg   %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    117a <boolop_loops+0x7a>
jmp    1188 <boolop_loops+0x88>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1147 <boolop_loops+0x47>
movl   $0x64,-0x4(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x7(%rbp)
je     11a8 <boolop_loops+0xa8>
cmpl   $0x32,-0x4(%rbp)
setg   %al
mov    %al,-0x7(%rbp)
mov    -0x7(%rbp),%al
test   $0x1,%al
jne    11b8 <boolop_loops+0xb8>
jmp    11cb <boolop_loops+0xcb>
jmp    11bd <boolop_loops+0xbd>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    118f <boolop_loops+0x8f>
jmp    11d0 <boolop_loops+0xd0>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x8(%rbp)
jne    11f3 <boolop_loops+0xf3>
cmpl   $0x0,-0x4(%rbp)
setg   %al
mov    %al,-0x8(%rbp)
mov    -0x8(%rbp),%al
test   $0x1,%al
jne    1203 <boolop_loops+0x103>
jmp    1216 <boolop_loops+0x116>
jmp    1208 <boolop_loops+0x108>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    11d0 <boolop_loops+0xd0>
pop    %rbp
ret

x86 assembly (clang, -O2):
<boolop_loops>:
ret

LLVM IR (-O0):
define void @boolop_loops() {
%1 = alloca i32
store i32 100, i32* %1
br label %2
2: ; preds = %10, %0
%3 = load i32, i32* %1
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 50
br label %8
8: ; preds = %5, %2
%9 = phi i1 [ false, %2 ], [ %7, %5 ]
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = load i32, i32* %1
%12 = add nsw i32 %11, -1
store i32 %12, i32* %1
br label %2
13: ; preds = %8
br label %14
14: ; preds = %23, %13
%15 = load i32, i32* %1
%16 = srem i32 %15, 2
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, 0
br label %21
21: ; preds = %18, %14
%22 = phi i1 [ true, %14 ], [ %20, %18 ]
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = load i32, i32* %1
%25 = add nsw i32 %24, -1
store i32 %25, i32* %1
br label %14
26: ; preds = %21
store i32 100, i32* %1
br label %27
27: ; preds = %36, %26
%28 = load i32, i32* %1
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %1
%32 = icmp sgt i32 %31, 50
br label %33
33: ; preds = %30, %27
%34 = phi i1 [ false, %27 ], [ %32, %30 ]
br i1 %34, label %35, label %39
35: ; preds = %33
br label %36
36: ; preds = %35
%37 = load i32, i32* %1
%38 = add nsw i32 %37, -1
store i32 %38, i32* %1
br label %27
39: ; preds = %33
br label %40
40: ; preds = %50, %39
%41 = load i32, i32* %1
%42 = srem i32 %41, 2
%43 = icmp ne i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %40
%45 = load i32, i32* %1
%46 = icmp sgt i32 %45, 0
br label %47
47: ; preds = %44, %40
%48 = phi i1 [ true, %40 ], [ %46, %44 ]
br i1 %48, label %49, label %53
49: ; preds = %47
br label %50
50: ; preds = %49
%51 = load i32, i32* %1
%52 = add nsw i32 %51, -1
store i32 %52, i32* %1
br label %40
53: ; preds = %47
ret void
}

LLVM IR (-O2):
define void @boolop_loops() {
ret void
}