#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 _mod(long, int);
int /*<<< orphan*/ printf(char *, long);
void _hailstone(long EV_n) {
  while (1) {
    printf("%ld ", (long)EV_n);
    if ((_mod(EV_n, 2) == 1)) {
      EV_n = ((3 * EV_n) + 1);
    } else {
      EV_n = (EV_n / 2);
    }
    if ((EV_n <= 1)) {
      printf("%ld\n", (long)EV_n);
      return;
    }
  }
}


x86 assembly (clang, -O0):
<_hailstone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1040 <_mod@plt>
cmp    $0x1,%eax
jne    1165 <_hailstone+0x45>
imul   $0x3,-0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1177 <_hailstone+0x57>
mov    -0x8(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
cmpq   $0x1,-0x8(%rbp)
jg     1198 <_hailstone+0x78>
mov    -0x8(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret
jmp    112c <_hailstone+0xc>

x86 assembly (clang, -O2):
<_hailstone>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed2(%rip),%r14
jmp    1146 <_hailstone+0x26>
mov    %rbx,%rax
shr    $0x3f,%rax
add    %rbx,%rax
sar    %rax
mov    %rax,%rbx
cmp    $0x1,%rbx
jle    1171 <_hailstone+0x51>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <_mod@plt>
cmp    $0x1,%eax
jne    1130 <_hailstone+0x10>
lea    (%rbx,%rbx,2),%rbx
add    $0x1,%rbx
cmp    $0x1,%rbx
jg     1146 <_hailstone+0x26>
lea    0xe8d(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

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

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