#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 */
double floor(double);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double n;
  scanf("%lf", &n);
  int count = 0;
  while (1) {
    if (n == 1) {
      break;
    }
    double tmp = n / 2;
    if (floor(tmp + 0.5) == tmp) {
      n = tmp;
    } else {
      n = 3 * n + 1;
    }
    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    0xeda(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe9d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1178 <main+0x48>
jp     1178 <main+0x48>
jmp    11f0 <main+0xc0>
movsd  -0x10(%rbp),%xmm0
movsd  0xe8b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe72(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
call   1050 <floor@plt>
ucomisd -0x20(%rbp),%xmm0
jne    11c0 <main+0x90>
jp     11c0 <main+0x90>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11e2 <main+0xb2>
movsd  -0x10(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe27(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <main+0x26>
mov    -0x14(%rbp),%esi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xedc(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
xor    %ebx,%ebx
ucomisd 0xeaa(%rip),%xmm0
jne    115a <main+0x2a>
jnp    11d8 <main+0xa8>
xor    %ebx,%ebx
nopl   0x0(%rax)
movapd %xmm0,0x10(%rsp)
movapd %xmm0,%xmm2
movsd  0xe96(%rip),%xmm1
mulsd  %xmm1,%xmm2
movapd %xmm2,0x20(%rsp)
movapd %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <floor@plt>
movapd 0x10(%rsp),%xmm2
mulsd  0xe79(%rip),%xmm2
movsd  0xe61(%rip),%xmm1
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm3
movapd 0x20(%rsp),%xmm2
cmpeqsd %xmm2,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm3,%xmm0
orpd   %xmm2,%xmm0
add    $0x1,%ebx
ucomisd %xmm1,%xmm0
jne    1160 <main+0x30>
jp     1160 <main+0x30>
movabs $0x3ff0000000000000,%rax
mov    %rax,0x8(%rsp)
lea    0xe3d(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca double
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
store i32 0, i32* %3
br label %6
6: ; preds = %0, %23
%7 = load double, double* %2
%8 = fcmp oeq double %7, 1.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %6
br label %26
10: ; preds = %6
%11 = load double, double* %2
%12 = fdiv double %11, 2.000000e+00
store double %12, double* %4
%13 = load double, double* %4
%14 = fadd double %13, 5.000000e-01
%15 = call double @llvm.floor.f64(double %14)
%16 = load double, double* %4
%17 = fcmp oeq double %15, %16
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = load double, double* %4
store double %19, double* %2
br label %23
20: ; preds = %10
%21 = load double, double* %2
%22 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %21, double 1.000000e+00)
store double %22, double* %2
br label %23
23: ; preds = %20, %18
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %6
26: ; preds = %9
%27 = load i32, i32* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = load double, double* %1
%5 = fcmp oeq double %4, 1.000000e+00
br i1 %5, label %18, label %6
6: ; preds = %0, %6
%7 = phi i32 [ %15, %6 ], [ 0, %0 ]
%8 = phi double [ %14, %6 ], [ %4, %0 ]
%9 = fmul double %8, 5.000000e-01
%10 = fadd double %9, 5.000000e-01
%11 = call double @llvm.floor.f64(double %10)
%12 = fcmp oeq double %11, %9
%13 = call double @llvm.fmuladd.f64(double %8, double 3.000000e+00, double 1.000000e+00)
%14 = select i1 %12, double %9, double %13
%15 = add nuw nsw i32 %7, 1
%16 = fcmp oeq double %14, 1.000000e+00
br i1 %16, label %17, label %6
17: ; preds = %6
store double 1.000000e+00, double* %1
br label %18
18: ; preds = %17, %0
%19 = phi i32 [ %15, %17 ], [ 0, %0 ]
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
ret i32 0
}