#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 fun(int);
int /*<<< orphan*/ printf(char *, int);
void main() {
  int n, x, i;
  for (n = 1;; n++) {
    x = n;
    for (i = 1; i <= 5; i++) {
      if ((x = fun(x)) == 0)
        break;
    }
    if (i == 6)
      break;
  }
  printf("%d\n", n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jg     1172 <main+0x52>
mov    -0x8(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    115f <main+0x3f>
jmp    1172 <main+0x52>
jmp    1164 <main+0x44>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <main+0x1c>
cmpl   $0x6,-0xc(%rbp)
jne    1181 <main+0x61>
jmp    1194 <main+0x74>
jmp    1186 <main+0x66>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <main+0xf>
mov    -0x4(%rbp),%esi
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%ebx
jmp    1133 <main+0x13>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %ebx,%edi
call   1030 <fun@plt>
test   %eax,%eax
je     1130 <main+0x10>
mov    %eax,%edi
call   1030 <fun@plt>
test   %eax,%eax
je     1130 <main+0x10>
mov    %eax,%edi
call   1030 <fun@plt>
test   %eax,%eax
je     1130 <main+0x10>
mov    %eax,%edi
call   1030 <fun@plt>
test   %eax,%eax
je     1130 <main+0x10>
mov    %eax,%edi
call   1030 <fun@plt>
test   %eax,%eax
je     1130 <main+0x10>
lea    0xe8f(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %1
br label %4
4: ; preds = %23, %0
%5 = load i32, i32* %1
store i32 %5, i32* %2
store i32 1, i32* %3
br label %6
6: ; preds = %15, %4
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 5
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call i32 @fun(i32 %10)
store i32 %11, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %18
14: ; preds = %9
br label %15
15: ; preds = %14
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %6
18: ; preds = %13, %6
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 6
br i1 %20, label %21, label %22
21: ; preds = %18
br label %26
22: ; preds = %18
br label %23
23: ; preds = %22
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
br label %4
26: ; preds = %21
%27 = load i32, i32* %1
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @main() {
br label %1
1: ; preds = %17, %0
%2 = phi i32 [ 1, %0 ], [ %18, %17 ]
%3 = tail call i32 @fun(i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %1
%6 = tail call i32 @fun(i32 %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5
%9 = tail call i32 @fun(i32 %6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = tail call i32 @fun(i32 %9)
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = tail call i32 @fun(i32 %12)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %1, %5, %8, %11, %14
%18 = add nuw nsw i32 %2, 1
br label %1
19: ; preds = %14
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
ret void
}