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


x86 assembly (clang, -O0):
<test3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
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>
cmpl   $0x64,-0x8(%rbp)
jae    114c <test3+0x3c>
jmp    112d <test3+0x1d>
movl   $0x0,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jae    116b <test3+0x5b>
jmp    112d <test3+0x1d>
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x64,-0x4(%rbp)
jne    118a <test3+0x7a>
jmp    118f <test3+0x7f>
jmp    112d <test3+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

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

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

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