#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 */
unsigned int bar();
void foo(void) {
  unsigned i, j, n;
  for (i = 0; i < 100000; i++)
    ;
  n = bar();
  for (i = 0; i < n; i++)
    ;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      ;
  for (i = 0; i < 10000; i++)
    bar();
  for (i = 0; i != n; i += 2)
    ;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x186a0,-0x4(%rbp)
jae    113f <foo+0x2f>
jmp    1131 <foo+0x21>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <foo+0xf>
mov    $0x0,%al
call   1030 <bar@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    116f <foo+0x5f>
jmp    1161 <foo+0x51>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1150 <foo+0x40>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11bb <foo+0xab>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11a8 <foo+0x98>
jmp    119a <foo+0x8a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1189 <foo+0x79>
jmp    11ad <foo+0x9d>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1176 <foo+0x66>
movl   $0x0,-0x4(%rbp)
cmpl   $0x2710,-0x4(%rbp)
jae    11e4 <foo+0xd4>
mov    $0x0,%al
call   1030 <bar@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <foo+0xb2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     120a <foo+0xfa>
jmp    11fc <foo+0xec>
mov    -0x4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    11eb <foo+0xdb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
xor    %eax,%eax
call   1030 <bar@plt>
mov    $0x2710,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1030 <bar@plt>
add    $0xffffffff,%ebx
jne    1120 <foo+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @foo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %8, %0
%5 = load i32, i32* %1
%6 = icmp ult i32 %5, 100000
br i1 %6, label %7, label %11
7: ; preds = %4
br label %8
8: ; preds = %7
%9 = load i32, i32* %1
%10 = add i32 %9, 1
store i32 %10, i32* %1
br label %4
11: ; preds = %4
%12 = call i32 (...) @bar()
store i32 %12, i32* %3
store i32 0, i32* %1
br label %13
13: ; preds = %18, %11
%14 = load i32, i32* %1
%15 = load i32, i32* %3
%16 = icmp ult i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %13
br label %18
18: ; preds = %17
%19 = load i32, i32* %1
%20 = add i32 %19, 1
store i32 %20, i32* %1
br label %13
21: ; preds = %13
store i32 0, i32* %1
br label %22
22: ; preds = %36, %21
%23 = load i32, i32* %1
%24 = load i32, i32* %3
%25 = icmp ult i32 %23, %24
br i1 %25, label %26, label %39
26: ; preds = %22
store i32 0, i32* %2
br label %27
27: ; preds = %32, %26
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = icmp ult i32 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27
br label %32
32: ; preds = %31
%33 = load i32, i32* %2
%34 = add i32 %33, 1
store i32 %34, i32* %2
br label %27
35: ; preds = %27
br label %36
36: ; preds = %35
%37 = load i32, i32* %1
%38 = add i32 %37, 1
store i32 %38, i32* %1
br label %22
39: ; preds = %22
store i32 0, i32* %1
br label %40
40: ; preds = %45, %39
%41 = load i32, i32* %1
%42 = icmp ult i32 %41, 10000
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = call i32 (...) @bar()
br label %45
45: ; preds = %43
%46 = load i32, i32* %1
%47 = add i32 %46, 1
store i32 %47, i32* %1
br label %40
48: ; preds = %40
store i32 0, i32* %1
br label %49
49: ; preds = %54, %48
%50 = load i32, i32* %1
%51 = load i32, i32* %3
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %57
53: ; preds = %49
br label %54
54: ; preds = %53
%55 = load i32, i32* %1
%56 = add i32 %55, 2
store i32 %56, i32* %1
br label %49
57: ; preds = %49
ret void
}

LLVM IR (-O2):
define void @foo() {
%1 = tail call i32 (...) @bar()
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %5, %2 ]
%4 = tail call i32 (...) @bar()
%5 = add nuw nsw i32 %3, 1
%6 = icmp eq i32 %5, 10000
br i1 %6, label %7, label %2
7: ; preds = %2
ret void
}