int nested_while_and_or_constant(int p) {
  int i = 0;
  int j = 3 * i;
  while (p == 1 || (i < 30 && i >= 0)) {
    while (p == 1 || (j < 5 && j >= 0)) {
      return j;
    }
    i++;
  }
  return j;
}


x86 assembly (clang, -O0):
<nested_while_and_or_constant>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
imul   $0x3,-0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     1143 <nested_while_and_or_constant+0x43>
xor    %eax,%eax
cmpl   $0x1e,-0xc(%rbp)
mov    %al,-0x12(%rbp)
jge    113d <nested_while_and_or_constant+0x3d>
cmpl   $0x0,-0xc(%rbp)
setge  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1153 <nested_while_and_or_constant+0x53>
jmp    11af <nested_while_and_or_constant+0xaf>
jmp    1158 <nested_while_and_or_constant+0x58>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x13(%rbp)
je     1186 <nested_while_and_or_constant+0x86>
xor    %eax,%eax
cmpl   $0x5,-0x10(%rbp)
mov    %al,-0x14(%rbp)
jge    1180 <nested_while_and_or_constant+0x80>
cmpl   $0x0,-0x10(%rbp)
setge  %al
mov    %al,-0x14(%rbp)
mov    -0x14(%rbp),%al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
test   $0x1,%al
jne    1196 <nested_while_and_or_constant+0x96>
jmp    11a1 <nested_while_and_or_constant+0xa1>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <nested_while_and_or_constant+0xb5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1115 <nested_while_and_or_constant+0x15>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nested_while_and_or_constant>:
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @nested_while_and_or_constant(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
%6 = load i32, i32* %4
%7 = mul nsw i32 3, %6
store i32 %7, i32* %5
br label %8
8: ; preds = %37, %1
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %19, label %11
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 30
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 0
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ false, %11 ], [ %16, %14 ]
br label %19
19: ; preds = %17, %8
%20 = phi i1 [ true, %8 ], [ %18, %17 ]
br i1 %20, label %21, label %40
21: ; preds = %19
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 1
br i1 %24, label %33, label %25
25: ; preds = %22
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 5
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp sge i32 %29, 0
br label %31
31: ; preds = %28, %25
%32 = phi i1 [ false, %25 ], [ %30, %28 ]
br label %33
33: ; preds = %31, %22
%34 = phi i1 [ true, %22 ], [ %32, %31 ]
br i1 %34, label %35, label %37
35: ; preds = %33
%36 = load i32, i32* %5
store i32 %36, i32* %2
br label %42
37: ; preds = %33
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %8
40: ; preds = %19
%41 = load i32, i32* %5
store i32 %41, i32* %2
br label %42
42: ; preds = %40, %35
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
define i32 @nested_while_and_or_constant(i32 %0) {
ret i32 0
}