#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*/ find_prime_factors(int, int *, int, int *, int *);
int /*<<< orphan*/ find_primes(int /*<<< orphan*/, int *, int *);
int /*<<< orphan*/ *gets(char *);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sqrt(int);
char *strtok(char *, char *);
int strtol(char *, int /*<<< orphan*/ *, int);
int main() {
  int num, base, exp;
  int primes[1 << 10], num_primes;
  int factors[1 << 10], num_factors;
  char line[4096];
  int i, count, prev;
  find_primes(sqrt(32767), primes, &num_primes);
  while (gets(line) != NULL && line[0] != '0') {
    char *tok;
    char *ptr = &line[0];
    num = 1;
    while ((tok = strtok(ptr, " ")) != NULL) {
      base = strtol(tok, NULL, 10);
      tok = strtok(NULL, " ");
      exp = strtol(tok, NULL, 10);
      num *= pow(base, exp);
      ptr = NULL;
    }
    --num;
    find_prime_factors(num, primes, num_primes, factors, &num_factors);
    prev = factors[num_factors - 1];
    count = 1;
    printf("%d", prev);
    for (i = num_factors - 2; i >= 0; i--) {
      if (factors[i] == prev) {
        count++;
      } else {
        printf(" %d", count);
        prev = factors[i];
        printf(" %d", prev);
        count = 1;
      }
    }
    printf(" %d", count);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3060,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x7fff,%edi
call   10a0 <sqrt@plt>
mov    %eax,%edi
lea    -0x1010(%rbp),%rsi
lea    -0x1014(%rbp),%rdx
call   1030 <find_primes@plt>
lea    -0x3030(%rbp),%rdi
call   1060 <gets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x3051(%rbp)
je     11e5 <main+0x65>
movsbl -0x3030(%rbp),%eax
cmp    $0x30,%eax
setne  %al
mov    %al,-0x3051(%rbp)
mov    -0x3051(%rbp),%al
test   $0x1,%al
jne    11f8 <main+0x78>
jmp    13cc <main+0x24c>
lea    -0x3030(%rbp),%rax
mov    %rax,-0x3050(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x3050(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x3048(%rbp)
cmp    $0x0,%rax
je     129a <main+0x11a>
mov    -0x3048(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdac(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x3048(%rbp)
mov    -0x3048(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1080 <pow@plt>
imul   -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movq   $0x0,-0x3050(%rbp)
jmp    120d <main+0x8d>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1010(%rbp),%rsi
mov    -0x1014(%rbp),%edx
lea    -0x2020(%rbp),%rcx
lea    -0x2024(%rbp),%r8
call   1070 <find_prime_factors@plt>
mov    -0x2024(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x2020(%rbp,%rax,4),%eax
mov    %eax,-0x303c(%rbp)
movl   $0x1,-0x3038(%rbp)
mov    -0x303c(%rbp),%esi
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2024(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x3034(%rbp)
cmpl   $0x0,-0x3034(%rbp)
jl     13a5 <main+0x225>
movslq -0x3034(%rbp),%rax
mov    -0x2020(%rbp,%rax,4),%eax
cmp    -0x303c(%rbp),%eax
jne    1346 <main+0x1c6>
mov    -0x3038(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3038(%rbp)
jmp    138c <main+0x20c>
mov    -0x3038(%rbp),%esi
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x3034(%rbp),%rax
mov    -0x2020(%rbp,%rax,4),%eax
mov    %eax,-0x303c(%rbp)
mov    -0x303c(%rbp),%esi
lea    0xc87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x3038(%rbp)
jmp    1391 <main+0x211>
mov    -0x3034(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3034(%rbp)
jmp    130b <main+0x18b>
mov    -0x3038(%rbp),%esi
lea    0xc50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b1 <main+0x31>
xor    %eax,%eax
add    $0x3060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3018,%rsp
mov    $0x7fff,%edi
call   10b0 <sqrt@plt>
lea    0x2010(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %eax,%edi
call   1040 <find_primes@plt>
lea    0x10(%rsp),%rdi
call   1070 <gets@plt>
test   %rax,%rax
je     1333 <main+0x1a3>
cmpb   $0x30,0x10(%rsp)
je     1333 <main+0x1a3>
lea    0xe1c(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe12(%rip),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strtok@plt>
mov    $0x1,%r12d
mov    $0x1,%r13d
test   %rax,%rax
je     1266 <main+0xd6>
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %r14,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1090 <pow@plt>
imul   %eax,%r13d
xor    %edi,%edi
mov    %r14,%rsi
call   10a0 <strtok@plt>
test   %rax,%rax
jne    1220 <main+0x90>
add    $0xffffffff,%r13d
mov    0xc(%rsp),%edx
mov    %r13d,%edi
lea    0x2010(%rsp),%rsi
lea    0x1010(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1080 <find_prime_factors@plt>
movslq 0x8(%rsp),%rax
mov    0x100c(%rsp,%rax,4),%ebp
lea    0xd65(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%ebx
cmp    $0x2,%ebx
jl     12ff <main+0x16f>
add    $0xfffffffe,%ebx
add    $0x1,%rbx
mov    $0x1,%r12d
jmp    12ec <main+0x15c>
nop
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x100c(%rsp,%rbx,4),%ebp
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
add    $0xffffffffffffffff,%rbx
jle    12ff <main+0x16f>
cmp    %ebp,0x100c(%rsp,%rbx,4)
jne    12c0 <main+0x130>
add    $0x1,%r12d
add    $0xffffffffffffffff,%rbx
jg     12ec <main+0x15c>
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
test   %rax,%rax
je     1333 <main+0x1a3>
cmpb   $0x30,0x10(%rsp)
jne    11f0 <main+0x60>
xor    %eax,%eax
add    $0x3018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i32]
%6 = alloca i32
%7 = alloca [1024 x i32]
%8 = alloca i32
%9 = alloca [4096 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %1
%15 = call i32 @sqrt(i32 32767)
%16 = getelementptr inbounds [1024 x i32], [1024 x i32]* %5, i64 0, i64 0
%17 = call i32 @find_primes(i32 %15, i32* %16, i32* %6)
br label %18
18: ; preds = %89, %0
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%20 = call i32* @gets(i8* %19)
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 48
br label %27
27: ; preds = %22, %18
%28 = phi i1 [ false, %18 ], [ %26, %22 ]
br i1 %28, label %29, label %93
29: ; preds = %27
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
store i8* %30, i8** %14
store i32 1, i32* %2
br label %31
31: ; preds = %35, %29
%32 = load i8*, i8** %14
%33 = call i8* @strtok(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %33, i8** %13
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %46
35: ; preds = %31
%36 = load i8*, i8** %13
%37 = call i32 @strtol(i8* %36, i32* null, i32 10)
store i32 %37, i32* %3
%38 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %38, i8** %13
%39 = load i8*, i8** %13
%40 = call i32 @strtol(i8* %39, i32* null, i32 10)
store i32 %40, i32* %4
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = call i32 @pow(i32 %41, i32 %42)
%44 = load i32, i32* %2
%45 = mul nsw i32 %44, %43
store i32 %45, i32* %2
store i8* null, i8** %14
br label %31
46: ; preds = %31
%47 = load i32, i32* %2
%48 = add nsw i32 %47, -1
store i32 %48, i32* %2
%49 = load i32, i32* %2
%50 = getelementptr inbounds [1024 x i32], [1024 x i32]* %5, i64 0, i64 0
%51 = load i32, i32* %6
%52 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 0
%53 = call i32 @find_prime_factors(i32 %49, i32* %50, i32 %51, i32* %52, i32* %8)
%54 = load i32, i32* %8
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 %56
%58 = load i32, i32* %57
store i32 %58, i32* %12
store i32 1, i32* %11
%59 = load i32, i32* %12
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %8
%62 = sub nsw i32 %61, 2
store i32 %62, i32* %10
br label %63
63: ; preds = %86, %46
%64 = load i32, i32* %10
%65 = icmp sge i32 %64, 0
br i1 %65, label %66, label %89
66: ; preds = %63
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = load i32, i32* %12
%72 = icmp eq i32 %70, %71
br i1 %72, label %73, label %76
73: ; preds = %66
%74 = load i32, i32* %11
%75 = add nsw i32 %74, 1
store i32 %75, i32* %11
br label %85
76: ; preds = %66
%77 = load i32, i32* %11
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %77)
%79 = load i32, i32* %10
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 %80
%82 = load i32, i32* %81
store i32 %82, i32* %12
%83 = load i32, i32* %12
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %83)
store i32 1, i32* %11
br label %85
85: ; preds = %76, %73
br label %86
86: ; preds = %85
%87 = load i32, i32* %10
%88 = add nsw i32 %87, -1
store i32 %88, i32* %10
br label %63
89: ; preds = %63
%90 = load i32, i32* %11
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %90)
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %18
93: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" %d\00"
define i32 @main() {
%1 = alloca [1024 x i32]
%2 = alloca i32
%3 = alloca [1024 x i32]
%4 = alloca i32
%5 = alloca [4096 x i8]
%6 = bitcast [1024 x i32]* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast [1024 x i32]* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%11 = tail call i32 @sqrt(i32 32767)
%12 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 0
%13 = call i32 @find_primes(i32 %11, i32* %12, i32* %2)
%14 = call i32* @gets(i8* %10)
%15 = icmp ne i32* %14, null
%16 = load i8, i8* %10
%17 = icmp ne i8 %16, 48
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %19, label %77
19: ; preds = %0
%20 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 0
br label %21
21: ; preds = %19, %68
%22 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %34, label %24
24: ; preds = %21, %24
%25 = phi i8* [ %32, %24 ], [ %22, %21 ]
%26 = phi i32 [ %31, %24 ], [ 1, %21 ]
%27 = call i32 @strtol(i8* nocapture %25, i32* null, i32 10)
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @strtol(i8* nocapture %28, i32* null, i32 10)
%30 = call i32 @pow(i32 %27, i32 %29)
%31 = mul nsw i32 %30, %26
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %24
34: ; preds = %24, %21
%35 = phi i32 [ 1, %21 ], [ %31, %24 ]
%36 = add nsw i32 %35, -1
%37 = load i32, i32* %2
%38 = call i32 @find_prime_factors(i32 %36, i32* %12, i32 %37, i32* %20, i32* %4)
%39 = load i32, i32* %4
%40 = add nsw i32 %39, -1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %4
%46 = icmp sgt i32 %45, 1
br i1 %46, label %47, label %68
47: ; preds = %34
%48 = add nsw i32 %45, -2
%49 = zext i32 %48 to i64
br label %50
50: ; preds = %47, %63
%51 = phi i64 [ %49, %47 ], [ %66, %63 ]
%52 = phi i32 [ %43, %47 ], [ %65, %63 ]
%53 = phi i32 [ 1, %47 ], [ %64, %63 ]
%54 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 %51
%55 = load i32, i32* %54
%56 = icmp eq i32 %55, %52
br i1 %56, label %57, label %59
57: ; preds = %50
%58 = add nsw i32 %53, 1
br label %63
59: ; preds = %50
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %53)
%61 = load i32, i32* %54
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %57, %59
%64 = phi i32 [ %58, %57 ], [ 1, %59 ]
%65 = phi i32 [ %52, %57 ], [ %61, %59 ]
%66 = add nsw i64 %51, -1
%67 = icmp sgt i64 %51, 0
br i1 %67, label %50, label %68
68: ; preds = %63, %34
%69 = phi i32 [ 1, %34 ], [ %64, %63 ]
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %69)
%71 = call i32 @putchar(i32 10)
%72 = call i32* @gets(i8* %10)
%73 = icmp ne i32* %72, null
%74 = load i8, i8* %10
%75 = icmp ne i8 %74, 48
%76 = select i1 %73, i1 %75, i1 false
br i1 %76, label %21, label %77
77: ; preds = %68, %0
ret i32 0
}