#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 */
typedef int uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int sqrt(int);
void primeFactor(uint64_t n) {
  uint64_t i, limit = sqrt(n);
  for (i = 2; i <= limit; i++) {
    if (n % i == 0) {
      printf(" %ju", i);
      primeFactor(n / i);
      return;
    }
  }
  printf(" %ju", n);
}


x86 assembly (clang, -O0):
<primeFactor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <sqrt@plt>
mov    %eax,-0xc(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     119e <primeFactor+0x6e>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    118b <primeFactor+0x5b>
mov    -0x8(%rbp),%esi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%edi
call   1050 <primeFactor@plt>
jmp    11ad <primeFactor+0x7d>
jmp    1190 <primeFactor+0x60>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <primeFactor+0x1d>
mov    -0x4(%rbp),%esi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primeFactor>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
call   1040 <sqrt@plt>
cmp    $0x2,%eax
jge    1144 <primeFactor+0x24>
mov    %ebx,%ebp
lea    0xec7(%rip),%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
mov    %eax,%ecx
lea    0xeb3(%rip),%r14
neg    %ecx
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1180 <primeFactor+0x60>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    1160 <primeFactor+0x40>
jmp    1130 <primeFactor+0x10>
nopl   (%rax)
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebp,%edi
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    %ebp,%ebx
cmp    $0x2,%eax
jge    114d <primeFactor+0x2d>
jmp    1132 <primeFactor+0x12>

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

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