#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 *, unsigned long);
scalar_t__ scanf(char *, unsigned long *);
int main() {
  unsigned long val;
  unsigned long cou;
  while (EOF != scanf("%ld", &val)) {
    cou = 0;
    while (val != 1) {
      if (val % 2 == 0)
        val = val / 2;
      else
        val = 3 * val + 1;
      cou++;
    }
    printf("%ld\n", cou);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11c6 <main+0xa6>
movq   $0x0,-0x18(%rbp)
cmpq   $0x1,-0x10(%rbp)
je     11b1 <main+0x91>
mov    -0x10(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    1193 <main+0x73>
mov    -0x10(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11a0 <main+0x80>
imul   $0x3,-0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1165 <main+0x45>
mov    -0x18(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2eb4(%rip),%r12
mov    (%r12),%rbx
lea    0xec1(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
cmp    %rax,%rbx
jne    115e <main+0x3e>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe9f(%rip),%r14
lea    0xe94(%rip),%r15
lea    0x8(%rsp),%r13
jmp    119c <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12),%rbx
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
cmp    %rax,%rbx
je     114e <main+0x2e>
mov    0x8(%rsp),%rax
xor    %esi,%esi
cmp    $0x1,%rax
je     1180 <main+0x60>
nopl   0x0(%rax)
mov    %rax,%rcx
shr    %rcx
test   $0x1,%al
lea    0x1(%rax,%rax,2),%rax
cmove  %rcx,%rax
add    $0x1,%rsi
cmp    $0x1,%rax
jne    11b0 <main+0x90>
movq   $0x1,0x8(%rsp)
jmp    1180 <main+0x60>

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

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