#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);
int sqrt(int);
void primeFactors(int n) {
  while (n % 2 == 0) {
    printf("%d ", 2);
    n = n / 2;
  }
  int i;
  for (i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      printf("%d ", i);
      n = n / i;
    }
  }
  if (n > 2)
    printf("%d ", n);
}


x86 assembly (clang, -O0):
<primeFactors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1163 <primeFactors+0x43>
lea    0xeba(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    112b <primeFactors+0xb>
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jg     11cb <primeFactors+0xab>
jmp    118a <primeFactors+0x6a>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    11b8 <primeFactors+0x98>
mov    -0x8(%rbp),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x4(%rbp)
jmp    118a <primeFactors+0x6a>
jmp    11bd <primeFactors+0x9d>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <primeFactors+0x4a>
cmpl   $0x2,-0x4(%rbp)
jle    11e4 <primeFactors+0xc4>
mov    -0x4(%rbp),%esi
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primeFactors>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
test   $0x1,%bpl
jne    115d <primeFactors+0x3d>
lea    0xecd(%rip),%r14
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
shr    $0x1f,%ebx
add    %ebp,%ebx
sar    %ebx
mov    %ebx,%ebp
test   $0x1,%bl
je     1140 <primeFactors+0x20>
jmp    115f <primeFactors+0x3f>
mov    %ebp,%ebx
mov    %ebx,%edi
call   1040 <sqrt@plt>
cmp    $0x3,%eax
jge    1182 <primeFactors+0x62>
cmp    $0x3,%ebx
jl     11ba <primeFactors+0x9a>
lea    0xe89(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
mov    $0x3,%ebp
lea    0xe72(%rip),%r14
jmp    119e <primeFactors+0x7e>
add    $0x2,%ebp
mov    %ebx,%edi
call   1040 <sqrt@plt>
cmp    %eax,%ebp
jg     116b <primeFactors+0x4b>
mov    %ebx,%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    1190 <primeFactors+0x70>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
cltd
idiv   %ebp
mov    %eax,%ebx
jmp    11a0 <primeFactors+0x80>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @primeFactors(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %8, %1
%5 = phi i32 [ %0, %1 ], [ %11, %8 ]
%6 = tail call i32 @sqrt(i32 %5)
%7 = icmp slt i32 %6, 3
br i1 %7, label %30, label %14
8: ; preds = %1, %8
%9 = phi i32 [ %11, %8 ], [ %0, %1 ]
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%11 = sdiv i32 %9, 2
%12 = and i32 %11, 1
%13 = icmp eq i32 %12, 0
br i1 %13, label %8, label %4
14: ; preds = %4, %25
%15 = phi i32 [ %27, %25 ], [ 3, %4 ]
%16 = phi i32 [ %26, %25 ], [ %5, %4 ]
%17 = srem i32 %16, %15
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %14, %19
%20 = phi i32 [ %22, %19 ], [ %16, %14 ]
%21 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%22 = sdiv i32 %20, %15
%23 = srem i32 %22, %15
%24 = icmp eq i32 %23, 0
br i1 %24, label %19, label %25
25: ; preds = %19, %14
%26 = phi i32 [ %16, %14 ], [ %22, %19 ]
%27 = add nuw nsw i32 %15, 2
%28 = tail call i32 @sqrt(i32 %26)
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %14
30: ; preds = %25, %4
%31 = phi i32 [ %5, %4 ], [ %26, %25 ]
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
br label %35
35: ; preds = %33, %30
ret void
}