#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 check_prime_brute(unsigned long);
int /*<<< orphan*/ printf(char *, ...);
void print_prime_factors(unsigned long n) {
  unsigned long div;
  if (n == 0)
    return;
  printf(" 1");
  for (div = 2; n > 1; div += 2) {
    if (check_prime_brute(div) == false)
      continue;
    while (n % div == 0) {
      printf(", %lu", div);
      n /= div;
    }
    if (div == 2)
      div = 1;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_prime_factors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113c <print_prime_factors+0x1c>
jmp    11ee <print_prime_factors+0xce>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x2,-0x10(%rbp)
cmpq   $0x1,-0x8(%rbp)
jbe    11e0 <print_prime_factors+0xc0>
mov    -0x10(%rbp),%rdi
call   1040 <check_prime_brute@plt>
cmp    $0x0,%eax
jne    1174 <print_prime_factors+0x54>
jmp    11cf <print_prime_factors+0xaf>
jmp    1179 <print_prime_factors+0x59>
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
cmp    $0x0,%rdx
jne    11b7 <print_prime_factors+0x97>
mov    -0x10(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
jmp    1179 <print_prime_factors+0x59>
cmpq   $0x2,-0x10(%rbp)
jne    11ca <print_prime_factors+0xaa>
movq   $0x1,-0x10(%rbp)
jmp    11cf <print_prime_factors+0xaf>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    1152 <print_prime_factors+0x32>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_prime_factors>:
test   %rdi,%rdi
je     1169 <print_prime_factors+0x39>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r14
jne    116a <print_prime_factors+0x3a>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>
ret
mov    $0x2,%ebx
lea    0xe8d(%rip),%r15
mov    $0x1,%r12d
jmp    1192 <print_prime_factors+0x62>
xchg   %ax,%ax
cmp    $0x2,%rbx
cmove  %r12,%rbx
add    $0x2,%rbx
cmp    $0x1,%r14
jbe    1154 <print_prime_factors+0x24>
mov    %rbx,%rdi
call   1050 <check_prime_brute@plt>
test   %eax,%eax
jne    11ab <print_prime_factors+0x7b>
jmp    1188 <print_prime_factors+0x58>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%r14
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11d0 <print_prime_factors+0xa0>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
je     11dc <print_prime_factors+0xac>
jmp    1180 <print_prime_factors+0x50>
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
jne    1180 <print_prime_factors+0x50>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
jne    11a0 <print_prime_factors+0x70>
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%r14d
jmp    11ab <print_prime_factors+0x7b>

LLVM IR (-O0):
@.str = [3 x i8] c" 1\00"
@.str.1 = [6 x i8] c", %lu\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_prime_factors(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %39
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i64 2, i64* %3
br label %9
9: ; preds = %34, %7
%10 = load i64, i64* %2
%11 = icmp ugt i64 %10, 1
br i1 %11, label %12, label %37
12: ; preds = %9
%13 = load i64, i64* %3
%14 = call i32 @check_prime_brute(i64 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %34
17: ; preds = %12
br label %18
18: ; preds = %23, %17
%19 = load i64, i64* %2
%20 = load i64, i64* %3
%21 = urem i64 %19, %20
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = load i64, i64* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %24)
%26 = load i64, i64* %3
%27 = load i64, i64* %2
%28 = udiv i64 %27, %26
store i64 %28, i64* %2
br label %18
29: ; preds = %18
%30 = load i64, i64* %3
%31 = icmp eq i64 %30, 2
br i1 %31, label %32, label %33
32: ; preds = %29
store i64 1, i64* %3
br label %33
33: ; preds = %32, %29
br label %34
34: ; preds = %33, %16
%35 = load i64, i64* %3
%36 = add i64 %35, 2
store i64 %36, i64* %3
br label %9
37: ; preds = %9
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %6
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c" 1\00"
@.str.1 = [6 x i8] c", %lu\00"
define void @print_prime_factors(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %31, label %3
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %0, 1
br i1 %5, label %29, label %6
6: ; preds = %3, %24
%7 = phi i64 [ %27, %24 ], [ 2, %3 ]
%8 = phi i64 [ %25, %24 ], [ %0, %3 ]
%9 = tail call i32 @check_prime_brute(i64 %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %6
%12 = urem i64 %8, %7
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11, %14
%15 = phi i64 [ %17, %14 ], [ %8, %11 ]
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%17 = udiv i64 %15, %7
%18 = urem i64 %17, %7
%19 = icmp eq i64 %18, 0
br i1 %19, label %14, label %20
20: ; preds = %14, %11
%21 = phi i64 [ %8, %11 ], [ %17, %14 ]
%22 = icmp eq i64 %7, 2
%23 = select i1 %22, i64 1, i64 %7
br label %24
24: ; preds = %6, %20
%25 = phi i64 [ %8, %6 ], [ %21, %20 ]
%26 = phi i64 [ %7, %6 ], [ %23, %20 ]
%27 = add i64 %26, 2
%28 = icmp ugt i64 %25, 1
br i1 %28, label %6, label %29
29: ; preds = %24, %3
%30 = tail call i32 @putchar(i32 10)
br label %31
31: ; preds = %1, %29
ret void
}