#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() {
  printf("Input the number: ");
  int n;
  scanf("%d", &n);
  int steps = 0;
  while (n != 1) {
    if (n % 2 == 0) {
      n /= 2;
    } else {
      n = n * 3 + 1;
    }
    steps++;
  }
  printf("The conjecture is %d\n", steps);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     119d <main+0x7d>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1185 <main+0x65>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    118f <main+0x6f>
imul   $0x3,-0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <main+0x34>
mov    -0xc(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     1187 <main+0x67>
xor    %ebx,%ebx
jmp    116e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%rax,%rax,2),%eax
add    $0x1,%eax
add    $0x1,%ebx
cmp    $0x1,%eax
je     117f <main+0x5f>
test   $0x1,%al
jne    1160 <main+0x40>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    %ecx,%eax
jmp    1166 <main+0x46>
movl   $0x1,0xc(%rsp)
lea    0xe88(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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