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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movslq -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x1,-0x10(%rbp)
je     11a3 <main+0x83>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     1183 <main+0x63>
imul   $0x3,-0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1195 <main+0x75>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <main+0x2e>
mov    -0x14(%rbp),%esi
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rax
xor    %esi,%esi
cmp    $0x1,%rax
jne    114f <main+0x2f>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
xor    %esi,%esi
jmp    1179 <main+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%rcx
shr    $0x3f,%rcx
add    %rax,%rcx
sar    %rcx
mov    %rcx,%rax
add    $0x1,%esi
cmp    $0x1,%rax
je     113f <main+0x1f>
test   $0x1,%al
je     1160 <main+0x40>
lea    (%rax,%rax,2),%rax
add    $0x1,%rax
jmp    1170 <main+0x50>

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