#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 printWondrous(int start) {
  int count = 1;
  int number = start;
  while (number != 1) {
    printf("%d ", number);
    if ((number % 2) == 0) {
      number = number / 2;
    } else {
      number = (number * 3 + 1);
    }
    count++;
  }
  printf("%d\n", number);
  return count;
}


x86 assembly (clang, -O0):
<printWondrous>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     1180 <printWondrous+0x70>
mov    -0xc(%rbp),%esi
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1168 <printWondrous+0x58>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1172 <printWondrous+0x62>
imul   $0x3,-0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1128 <printWondrous+0x18>
mov    -0xc(%rbp),%esi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printWondrous>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebp
cmp    $0x1,%edi
jne    1136 <printWondrous+0x26>
lea    0xedf(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %edi,%ebx
mov    $0x1,%ebp
lea    0xebc(%rip),%r14
jmp    115e <printWondrous+0x4e>
cs nopw 0x0(%rax,%rax,1)
lea    (%rbx,%rbx,2),%ebx
add    $0x1,%ebx
add    $0x1,%ebp
cmp    $0x1,%ebx
je     111e <printWondrous+0xe>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
test   $0x1,%bl
jne    1150 <printWondrous+0x40>
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
mov    %eax,%ebx
jmp    1156 <printWondrous+0x46>

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

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