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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
je     119e <main+0x7e>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117e <main+0x5e>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1190 <main+0x70>
imul   $0x3,-0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x2d>
mov    -0xc(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
xor    %esi,%esi
cmp    $0x1,%eax
je     1171 <main+0x51>
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
test   $0x1,%al
lea    0x1(%rax,%rax,2),%ecx
cmove  %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
add    $0x1,%esi
and    $0xfffffffe,%ecx
cmp    $0x2,%ecx
jne    1150 <main+0x30>
mov    %eax,0x4(%rsp)
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.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
store i32 0, i32* %2
store i32 0, i32* %3
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %5
5: ; preds = %20, %0
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i32, i32* %2
%10 = srem i32 %9, 2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 2
store i32 %14, i32* %2
br label %20
15: ; preds = %8
%16 = load i32, i32* %2
%17 = mul nsw i32 3, %16
%18 = add nsw i32 %17, 1
%19 = sdiv i32 %18, 2
store i32 %19, i32* %2
br label %20
20: ; preds = %15, %12
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %5
23: ; preds = %5
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
ret i32 0
}

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