#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 pattern(int start) {
  printf("%d ", start);
  if (start == 1)
    return;
  else if (start % 2) {
    start = 3 * start + 1;
    pattern(start);
  } else
    pattern(start / 2);
}


x86 assembly (clang, -O0):
<pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1149 <pattern+0x29>
jmp    118b <pattern+0x6b>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1174 <pattern+0x54>
imul   $0x3,-0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <pattern@plt>
jmp    1186 <pattern+0x66>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <pattern@plt>
jmp    118b <pattern+0x6b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pattern>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xee3(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmp    $0x1,%ebx
jne    1131 <pattern+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xec8(%rip),%r14
jmp    1155 <pattern+0x45>
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%rbx,2),%ebx
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmp    $0x1,%ebx
je     1129 <pattern+0x19>
test   $0x1,%bl
jne    1140 <pattern+0x30>
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
mov    %eax,%ebx
jmp    1146 <pattern+0x36>

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

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