#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);
void Sequence(int n) {
  while (n != 1) {
    printf("%i\n", n);
    if (n % 2 == 0) {
      n = n / 2;
    } else {
      n = n * 3 + 1;
    }
    if (n > 1e+7) {
      break;
    }
  }
}


x86 assembly (clang, -O0):
<Sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     1186 <Sequence+0x76>
mov    -0x4(%rbp),%esi
lea    0xed9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115b <Sequence+0x4b>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1165 <Sequence+0x55>
imul   $0x3,-0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1181 <Sequence+0x71>
jmp    1186 <Sequence+0x76>
jmp    111b <Sequence+0xb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sequence>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
je     1173 <Sequence+0x63>
mov    %edi,%ebx
lea    0xede(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
test   $0x1,%bl
jne    1160 <Sequence+0x50>
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
mov    %eax,%ebx
cmp    $0x989680,%ebx
jle    116e <Sequence+0x5e>
jmp    1173 <Sequence+0x63>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rbx,%rbx,2),%ebx
add    $0x1,%ebx
cmp    $0x989680,%ebx
jg     1173 <Sequence+0x63>
cmp    $0x1,%ebx
jne    1130 <Sequence+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%i\0A\00"
define void @Sequence(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
br label %3
3: ; preds = %24, %1
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 1
br i1 %5, label %6, label %25
6: ; preds = %3
%7 = load i32, i32* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
%10 = srem i32 %9, 2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 2
store i32 %14, i32* %2
br label %19
15: ; preds = %6
%16 = load i32, i32* %2
%17 = mul nsw i32 %16, 3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %19
19: ; preds = %15, %12
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = fcmp ogt double %21, 1.000000e+07
br i1 %22, label %23, label %24
23: ; preds = %19
br label %25
24: ; preds = %19
br label %3
25: ; preds = %23, %3
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%i\0A\00"
define void @Sequence(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %18, label %3
3: ; preds = %1, %13
%4 = phi i32 [ %14, %13 ], [ %0, %1 ]
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = and i32 %4, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = sdiv i32 %4, 2
br label %13
10: ; preds = %3
%11 = mul nsw i32 %4, 3
%12 = add nsw i32 %11, 1
br label %13
13: ; preds = %10, %8
%14 = phi i32 [ %9, %8 ], [ %12, %10 ]
%15 = icmp slt i32 %14, 10000001
%16 = icmp ne i32 %14, 1
%17 = and i1 %15, %16
br i1 %17, label %3, label %18
18: ; preds = %13, %1
ret void
}