#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 /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int c = -1;
  int steps = 0;
  while (c <= 1) {
    printf("Input the number greater than 1\n");
    scanf("%d", &c);
    if (c <= 1) {
      printf("Number smaller or equal to 1\n");
      continue;
    }
    while (c != 1) {
      if (c % 2 == 0) {
        c /= 2;
      } else {
        c *= 3;
        c++;
      }
      steps++;
    }
    break;
  }
  printf("Number of steps: %d\n", steps);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x14(%rbp)
jg     11e2 <main+0xc2>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jg     1189 <main+0x69>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1144 <main+0x24>
jmp    118e <main+0x6e>
cmpl   $0x1,-0x14(%rbp)
je     11dd <main+0xbd>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11bf <main+0x9f>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    11cf <main+0xaf>
imul   $0x3,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118e <main+0x6e>
jmp    11e2 <main+0xc2>
mov    -0x18(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xed1(%rip),%r14
lea    0xeb2(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xede(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jge    118f <main+0x5f>
mov    %r12,%rdi
call   1030 <puts@plt>
cmpl   $0x2,0x4(%rsp)
jl     1160 <main+0x30>
xor    %esi,%esi
jmp    11c7 <main+0x97>
xor    %esi,%esi
jmp    11ae <main+0x7e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%rax,%rax,2),%eax
add    $0x1,%eax
add    $0x1,%esi
cmp    $0x1,%eax
je     11bf <main+0x8f>
test   $0x1,%al
jne    11a0 <main+0x70>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    %ecx,%eax
jmp    11a6 <main+0x76>
movl   $0x1,0x4(%rsp)
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Input the number greater than 1\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Number smaller or equal to 1\0A\00"
@.str.3 = [21 x i8] c"Number of steps: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %6
%10 = icmp sle i32 %9, 1
br i1 %10, label %11, label %38
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%14 = load i32, i32* %6
%15 = icmp sle i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %8
18: ; preds = %11
br label %19
19: ; preds = %34, %18
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %37
22: ; preds = %19
%23 = load i32, i32* %6
%24 = srem i32 %23, 2
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %6
%28 = sdiv i32 %27, 2
store i32 %28, i32* %6
br label %34
29: ; preds = %22
%30 = load i32, i32* %6
%31 = mul nsw i32 %30, 3
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %34
34: ; preds = %29, %26
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %19
37: ; preds = %19
br label %38
38: ; preds = %37, %8
%39 = load i32, i32* %7
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"Number of steps: %d\0A\00"
@str = [32 x i8] c"Input the number greater than 1\00"
@str.4 = [29 x i8] c"Number smaller or equal to 1\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
br label %5
5: ; preds = %2, %10
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 2
br i1 %13, label %5, label %29
14: ; preds = %5, %24
%15 = phi i32 [ %26, %24 ], [ 0, %5 ]
%16 = phi i32 [ %25, %24 ], [ %8, %5 ]
%17 = and i32 %16, 1
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = sdiv i32 %16, 2
br label %24
21: ; preds = %14
%22 = mul nsw i32 %16, 3
%23 = add nsw i32 %22, 1
br label %24
24: ; preds = %21, %19
%25 = phi i32 [ %23, %21 ], [ %20, %19 ]
%26 = add nuw nsw i32 %15, 1
%27 = icmp eq i32 %25, 1
br i1 %27, label %28, label %14
28: ; preds = %24
store i32 1, i32* %3
br label %29
29: ; preds = %10, %28
%30 = phi i32 [ %26, %28 ], [ 0, %10 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %30)
ret i32 0
}