#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ foo(int);
int main() {
  int il;
  for (il = 0; foo(il) && il < 10; ++il) {
  }
  for (il = 0; il < 10 && foo(il); ++il) {
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <foo@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x9(%rbp)
je     114a <main+0x3a>
cmpl   $0xa,-0x8(%rbp)
setl   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    115a <main+0x4a>
jmp    116d <main+0x5d>
jmp    115f <main+0x4f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x8(%rbp)
mov    %al,-0xa(%rbp)
jge    1195 <main+0x85>
mov    -0x8(%rbp),%edi
call   1030 <foo@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    11a5 <main+0x95>
jmp    11b8 <main+0xa8>
jmp    11aa <main+0x9a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x64>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1030 <foo@plt>
cmp    $0x9,%ebx
ja     1134 <main+0x24>
add    $0x1,%ebx
test   %rax,%rax
jne    1120 <main+0x10>
xor    %edi,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x1,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x2,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x3,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x4,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x5,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x6,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x7,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x8,%edi
call   1030 <foo@plt>
test   %rax,%rax
je     11c6 <main+0xb6>
mov    $0x9,%edi
call   1030 <foo@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %2
%5 = call i64 @foo(i32 %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 10
br label %10
10: ; preds = %7, %3
%11 = phi i1 [ false, %3 ], [ %9, %7 ]
br i1 %11, label %12, label %16
12: ; preds = %10
br label %13
13: ; preds = %12
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %3
16: ; preds = %10
store i32 0, i32* %2
br label %17
17: ; preds = %27, %16
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 10
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %2
%22 = call i64 @foo(i32 %21)
%23 = icmp ne i64 %22, 0
br label %24
24: ; preds = %20, %17
%25 = phi i1 [ false, %17 ], [ %23, %20 ]
br i1 %25, label %26, label %30
26: ; preds = %24
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %17
30: ; preds = %24
ret i32 1
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %7, %1 ]
%3 = tail call i64 @foo(i32 %2)
%4 = icmp ne i64 %3, 0
%5 = icmp ult i32 %2, 10
%6 = and i1 %5, %4
%7 = add nuw nsw i32 %2, 1
br i1 %6, label %1, label %8
8: ; preds = %1
%9 = tail call i64 @foo(i32 0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %37, label %11
11: ; preds = %8
%12 = tail call i64 @foo(i32 1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %37, label %14
14: ; preds = %11
%15 = tail call i64 @foo(i32 2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %37, label %17
17: ; preds = %14
%18 = tail call i64 @foo(i32 3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %37, label %20
20: ; preds = %17
%21 = tail call i64 @foo(i32 4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %20
%24 = tail call i64 @foo(i32 5)
%25 = icmp eq i64 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %23
%27 = tail call i64 @foo(i32 6)
%28 = icmp eq i64 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %26
%30 = tail call i64 @foo(i32 7)
%31 = icmp eq i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = tail call i64 @foo(i32 8)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i64 @foo(i32 9)
br label %37
37: ; preds = %35, %32, %29, %26, %23, %20, %17, %14, %11, %8
ret i32 1
}