#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 *, ...);
void hail(long n) {
  printf("%ld ", n);
  if (n == 1) {
    printf("\n");
    return;
  } else if (n % 2 == 0) {
    n /= 2;
    hail(n);
  } else {
    n *= 3;
    ++n;
    hail(n);
  }
  return;
}


x86 assembly (clang, -O0):
<hail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x1,-0x8(%rbp)
jne    115c <hail+0x3c>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bc <hail+0x9c>
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1194 <hail+0x74>
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <hail@plt>
jmp    11b2 <hail+0x92>
imul   $0x3,-0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <hail@plt>
jmp    11b7 <hail+0x97>
jmp    11bc <hail+0x9c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hail>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%rbx
jne    114f <hail+0x2f>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>
lea    0xeaa(%rip),%r14
jmp    1183 <hail+0x63>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
shr    $0x3f,%rax
add    %rbx,%rax
sar    %rax
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%rbx
je     113e <hail+0x1e>
test   $0x1,%bl
je     1160 <hail+0x40>
lea    (%rbx,%rbx,2),%rbx
add    $0x1,%rbx
jmp    1170 <hail+0x50>

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

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