#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 */
int /*<<< orphan*/ foo();
void test4(void) {
  unsigned i, j, k;
  i = j = 0;
  while (1) {
    j++;
    foo();
    for (k = 0; k < 100; k++)
      foo();
    if (j < 100)
      continue;
    i++;
    j = 0;
    if (i == 100)
      break;
  }
}


x86 assembly (clang, -O0):
<test4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <foo@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jae    115c <test4+0x4c>
mov    $0x0,%al
call   1030 <foo@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <test4+0x2d>
cmpl   $0x64,-0x8(%rbp)
jae    116b <test4+0x5b>
jmp    1126 <test4+0x16>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x4(%rbp)
jne    118a <test4+0x7a>
jmp    118f <test4+0x7f>
jmp    1126 <test4+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test4>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <foo@plt>
mov    $0x64,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <foo@plt>
add    $0xffffffff,%ebx
jne    1140 <test4+0x30>
add    $0x1,%ebp
cmp    $0x64,%ebp
jne    1130 <test4+0x20>
add    $0x1,%r14d
cmp    $0x64,%r14d
jne    1120 <test4+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @test4() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %1
br label %4
4: ; preds = %0, %19, %26
%5 = load i32, i32* %2
%6 = add i32 %5, 1
store i32 %6, i32* %2
%7 = call i32 (...) @foo()
store i32 0, i32* %3
br label %8
8: ; preds = %13, %4
%9 = load i32, i32* %3
%10 = icmp ult i32 %9, 100
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = call i32 (...) @foo()
br label %13
13: ; preds = %11
%14 = load i32, i32* %3
%15 = add i32 %14, 1
store i32 %15, i32* %3
br label %8
16: ; preds = %8
%17 = load i32, i32* %2
%18 = icmp ult i32 %17, 100
br i1 %18, label %19, label %20
19: ; preds = %16
br label %4
20: ; preds = %16
%21 = load i32, i32* %1
%22 = add i32 %21, 1
store i32 %22, i32* %1
store i32 0, i32* %2
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, 100
br i1 %24, label %25, label %26
25: ; preds = %20
br label %27
26: ; preds = %20
br label %4
27: ; preds = %25
ret void
}

LLVM IR (-O2):
define void @test4() {
br label %1
1: ; preds = %14, %0
%2 = phi i32 [ %15, %14 ], [ 0, %0 ]
br label %3
3: ; preds = %1, %11
%4 = phi i32 [ %12, %11 ], [ 0, %1 ]
%5 = tail call i32 (...) @foo()
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 0, %3 ], [ %9, %6 ]
%8 = tail call i32 (...) @foo()
%9 = add nuw nsw i32 %7, 1
%10 = icmp eq i32 %9, 100
br i1 %10, label %11, label %6
11: ; preds = %6
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, 100
br i1 %13, label %14, label %3
14: ; preds = %11
%15 = add nuw nsw i32 %2, 1
%16 = icmp eq i32 %15, 100
br i1 %16, label %17, label %1
17: ; preds = %14
ret void
}