#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 /*<<< orphan*/ scanf(char *, long long *);
int main() {
  int cnt;
  long long int n, i;
  scanf("%lld", &n);
  while (n) {
    for (i = 2; i * i <= n; ++i) {
      cnt = 0;
      while (n % i == 0) {
        n /= i;
        ++cnt;
      }
      if (cnt) {
        printf("%lld^%d ", i, cnt);
        cnt = 0;
      }
    }
    if (n > 1)
      printf("%lld^%d ", n, 1);
    printf("\n");
    scanf("%lld", &n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1220 <main+0x100>
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
imul   -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     11db <main+0xbb>
movl   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
jne    119f <main+0x7f>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x4c>
cmpl   $0x0,-0x8(%rbp)
je     11c5 <main+0xa5>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
jmp    11ca <main+0xaa>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1152 <main+0x32>
cmpq   $0x1,-0x10(%rbp)
jle    11fd <main+0xdd>
mov    -0x10(%rbp),%rsi
lea    0xe14(%rip),%rdi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdee(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     126c <main+0x13c>
lea    0xeaa(%rip),%r12
lea    0xe9e(%rip),%r14
mov    %rsp,%r15
jmp    1192 <main+0x62>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     126c <main+0x13c>
cmp    $0x4,%rsi
jge    11b0 <main+0x80>
cmp    $0x2,%rsi
jl     1170 <main+0x40>
mov    %r12,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x40>
nop
mov    $0x2,%ebx
jmp    11e7 <main+0xb7>
nopw   0x0(%rax,%rax,1)
mov    %rsi,(%rsp)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rsi
add    $0x1,%rbx
mov    %rbx,%rax
imul   %rbx,%rax
cmp    %rsi,%rax
jg     1198 <main+0x68>
mov    %rsi,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1210 <main+0xe0>
mov    %rsi,%rax
cqto
idiv   %rbx
test   %rdx,%rdx
jne    11d7 <main+0xa7>
jmp    121b <main+0xeb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %esi,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
jne    11d7 <main+0xa7>
xor    %ecx,%ecx
jmp    1230 <main+0x100>
nop
mov    %rsi,%rax
cqto
idiv   %rbx
add    $0x1,%ecx
test   %rdx,%rdx
jne    11c0 <main+0x90>
mov    %rsi,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1250 <main+0x120>
mov    %rsi,%rax
cqto
idiv   %rbx
mov    %rax,%rsi
jmp    1258 <main+0x128>
nopl   0x0(%rax)
mov    %esi,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%esi
mov    %rsi,%rax
or     %rbx,%rax
shr    $0x20,%rax
jne    1220 <main+0xf0>
mov    %esi,%eax
xor    %edx,%edx
div    %ebx
jmp    1228 <main+0xf8>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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