#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 next(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int count;
  int i;
  for (count = 0, i = 1; i < 10000000; ++i) {
    int num = i;
    while (num != 1 && num != 89) {
      num = next(num);
    }
    if (num == 89)
      count++;
  }
  printf("%d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x989680,-0x18(%rbp)
jge    11b6 <main+0x96>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
je     1170 <main+0x50>
cmpl   $0x59,-0x1c(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1180 <main+0x60>
jmp    1190 <main+0x70>
mov    -0x1c(%rbp),%edi
call   1040 <next@plt>
mov    %eax,-0x1c(%rbp)
jmp    1157 <main+0x37>
cmpl   $0x59,-0x1c(%rbp)
jne    11a3 <main+0x83>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a8 <main+0x88>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x24>
mov    -0x14(%rbp),%esi
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
mov    $0x1,%ebp
jmp    113e <main+0x1e>
nopl   0x0(%rax)
add    $0x1,%ebx
add    $0x1,%ebp
cmp    $0x989680,%ebp
je     1163 <main+0x43>
mov    %ebp,%eax
cmp    $0x1,%eax
je     1133 <main+0x13>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x59,%eax
je     1130 <main+0x10>
mov    %eax,%edi
call   1040 <next@plt>
cmp    $0x1,%eax
jne    1150 <main+0x30>
jmp    1133 <main+0x13>
lea    0xe96(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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