#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);
int /*<<< orphan*/ printf(char *, int);
void main() {
  int n, x, i;
  for (n = 1;; n++) {
    x = n;
    for (i = 1; i <= 4; i++)
      if ((x = fun(x, i)) == 0)
        break;
    if (i == 5 && x == 11)
      break;
  }
  printf("%3d", 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   $0x4,-0xc(%rbp)
jg     1175 <main+0x55>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <fun@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    1162 <main+0x42>
jmp    1175 <main+0x55>
jmp    1167 <main+0x47>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <main+0x1c>
cmpl   $0x5,-0xc(%rbp)
jne    118e <main+0x6e>
cmpl   $0xb,-0x8(%rbp)
jne    118e <main+0x6e>
jmp    11a1 <main+0x81>
jmp    1193 <main+0x73>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <main+0xf>
mov    -0x4(%rbp),%esi
lea    0xe55(%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
mov    $0x1,%esi
call   1030 <fun@plt>
test   %eax,%eax
je     1130 <main+0x10>
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <fun@plt>
test   %eax,%eax
je     1130 <main+0x10>
mov    %eax,%edi
mov    $0x3,%esi
call   1030 <fun@plt>
test   %eax,%eax
je     1130 <main+0x10>
mov    %eax,%edi
mov    $0x4,%esi
call   1030 <fun@plt>
cmp    $0xb,%eax
jne    1130 <main+0x10>
lea    0xe85(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
jmp    1040 <printf@plt>

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

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