#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*/ fprintf(int /*<<< orphan*/, char *, size_t);
int /*<<< orphan*/ stdout;
size_t syracuse(size_t number) {
  size_t i = 0;
  while (number != 1) {
    i++;
    if (number % 2 == 0)
      number = number / 2;
    else
      number = 3 * number + 1;
    fprintf(stdout, "%zu\n", number);
  }
  return i;
}


x86 assembly (clang, -O0):
<syracuse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x1,-0x8(%rbp)
je     1189 <syracuse+0x79>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    115e <syracuse+0x4e>
mov    -0x8(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    116b <syracuse+0x5b>
imul   $0x3,-0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe81(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1124 <syracuse+0x14>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syracuse>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%rdi
jne    1123 <syracuse+0x13>
xor    %r14d,%r14d
jmp    116b <syracuse+0x5b>
mov    %rdi,%rbx
xor    %r14d,%r14d
mov    0x2eb0(%rip),%r12
lea    0xec9(%rip),%r15
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
mov    %rbx,%rax
shr    %rax
test   $0x1,%bl
lea    0x1(%rbx,%rbx,2),%rbx
cmove  %rax,%rbx
mov    (%r12),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
cmp    $0x1,%rbx
jne    1140 <syracuse+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [5 x i8] c"%zu\0A\00"
define i64 @syracuse(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
store i64 0, i64* %3
br label %4
4: ; preds = %20, %1
%5 = load i64, i64* %2
%6 = icmp ne i64 %5, 1
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = load i64, i64* %3
%9 = add i64 %8, 1
store i64 %9, i64* %3
%10 = load i64, i64* %2
%11 = urem i64 %10, 2
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i64, i64* %2
%15 = udiv i64 %14, 2
store i64 %15, i64* %2
br label %20
16: ; preds = %7
%17 = load i64, i64* %2
%18 = mul i64 3, %17
%19 = add i64 %18, 1
store i64 %19, i64* %2
br label %20
20: ; preds = %16, %13
%21 = load i32, i32* @stdout
%22 = load i64, i64* %2
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %22)
br label %4
24: ; preds = %4
%25 = load i64, i64* %3
ret i64 %25
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [5 x i8] c"%zu\0A\00"
define i64 @syracuse(i64 %0) {
%2 = icmp eq i64 %0, 1
br i1 %2, label %16, label %3
3: ; preds = %1, %3
%4 = phi i64 [ %6, %3 ], [ 0, %1 ]
%5 = phi i64 [ %12, %3 ], [ %0, %1 ]
%6 = add i64 %4, 1
%7 = and i64 %5, 1
%8 = icmp eq i64 %7, 0
%9 = lshr i64 %5, 1
%10 = mul i64 %5, 3
%11 = add i64 %10, 1
%12 = select i1 %8, i64 %9, i64 %11
%13 = load i32, i32* @stdout
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %12)
%15 = icmp eq i64 %12, 1
br i1 %15, label %16, label %3
16: ; preds = %3, %1
%17 = phi i64 [ 0, %1 ], [ %6, %3 ]
ret i64 %17
}