#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int xxx(int);
int main() {
  int n, i;
  while (scanf("%d", &n) != EOF) {
    if (n == 0)
      return 0;
    i = 0;
    while (n != 1) {
      n = xxx(n);
      i++;
    }
    printf("%d\n", i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%rax
je     11b3 <main+0x83>
cmpl   $0x0,-0x8(%rbp)
jne    1175 <main+0x45>
movl   $0x0,-0x4(%rbp)
jmp    11ba <main+0x8a>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     119f <main+0x6f>
mov    -0x8(%rbp),%edi
call   1040 <xxx@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <main+0x4c>
mov    -0xc(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e94(%rip),%r12
cmp    (%r12),%rax
je     11c6 <main+0x96>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11c6 <main+0x96>
lea    0xe9a(%rip),%r14
lea    0xe90(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebp,%ebp
cmp    $0x1,%eax
je     11a3 <main+0x73>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %eax,%edi
call   1040 <xxx@plt>
mov    %eax,0xc(%rsp)
add    $0x1,%ebp
cmp    $0x1,%eax
jne    1190 <main+0x60>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    (%r12),%rax
je     11c6 <main+0x96>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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