#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 *, long long *);
int main() {
  long long int n;
  printf("What number do you want to pass trough the Collatz conjecture? ");
  scanf("%lld", &n);
  while (n != 1) {
    if ((n / 2) * 2 == n) {
      n = n / 2;
      printf("%lld\n", n);
    } else {
      n = (n * 3) + 1;
      printf("%lld\n", n);
    }
  }
}


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    0xefc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x1,-0x10(%rbp)
je     11c1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
shl    $0x1,%rax
cmp    -0x10(%rbp),%rax
jne    119d <main+0x7d>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bc <main+0x9c>
imul   $0x3,-0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x2d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
cmp    $0x1,%rax
je     119a <main+0x7a>
lea    0xeef(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rcx
shr    $0x3f,%rcx
add    %rax,%rcx
mov    %rcx,%rdx
sar    %rdx
and    $0xfffffffffffffffe,%rcx
cmp    %rax,%rcx
lea    0x1(%rax,%rax,2),%rsi
cmove  %rdx,%rsi
mov    %rsi,0x8(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
cmp    $0x1,%rax
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [64 x i8] c"What number do you want to pass trough the Collatz conjecture? \00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = load i64, i64* %1
%6 = icmp eq i64 %5, 1
br i1 %6, label %18, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %16, %7 ], [ %5, %0 ]
%9 = sdiv i64 %8, 2
%10 = shl nsw i64 %9, 1
%11 = icmp eq i64 %10, %8
%12 = mul nsw i64 %8, 3
%13 = add nsw i64 %12, 1
%14 = select i1 %11, i64 %9, i64 %13
store i64 %14, i64* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %14)
%16 = load i64, i64* %1
%17 = icmp eq i64 %16, 1
br i1 %17, label %18, label %7
18: ; preds = %7, %0
ret i32 0
}