#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);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int n;
  scanf("%d", &n);
  while (n != 1) {
    if (n % 2) {
      printf("%d", n);
      printf("*3+1=%d\n", n = n * 3 + 1);
    } else {
      printf("%d", n);
      printf("/2=%d\n", n /= 2);
    }
  }
  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)
lea    0xec3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
je     11be <main+0x9e>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118e <main+0x6e>
mov    -0x14(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
imul   $0x3,-0x14(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <main+0x99>
mov    -0x14(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    %esi,-0x14(%rbp)
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
jmp    1146 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebp
cmp    $0x1,%ebp
jne    114e <main+0x2e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeab(%rip),%rbx
lea    0xeb0(%rip),%r14
lea    0xea0(%rip),%r15
jmp    118e <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %esi,0x4(%rsp)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%ebp
cmp    $0x1,%ebp
je     1141 <main+0x21>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
test   $0x1,%bpl
je     1170 <main+0x50>
lea    (%rax,%rax,2),%esi
add    $0x1,%esi
mov    %esi,0x4(%rsp)
mov    %r15,%rdi
jmp    1180 <main+0x60>

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

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