#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 *, ...);
void factor(unsigned n) {
  unsigned i;
  unsigned power;
  printf("%u: ", n);
  if (n <= 1) {
    printf("%u\n", n);
    return;
  }
  for (i = 2; n > 1; i++) {
    power = 0;
    while ((n % i) == 0) {
      power++;
      n /= i;
    }
    if (power > 1)
      printf(" %u^%u", i, power);
    else if (power == 1)
      printf(" %u", i);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
ja     114c <factor+0x3c>
mov    -0x4(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f4 <factor+0xe4>
movl   $0x2,-0x8(%rbp)
cmpl   $0x1,-0x4(%rbp)
jbe    11e6 <factor+0xd6>
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
cmp    $0x0,%edx
jne    1190 <factor+0x80>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
xor    %edx,%edx
div    %ecx
mov    %eax,-0x4(%rbp)
jmp    1164 <factor+0x54>
cmpl   $0x1,-0xc(%rbp)
jbe    11b3 <factor+0xa3>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d3 <factor+0xc3>
cmpl   $0x1,-0xc(%rbp)
jne    11ce <factor+0xbe>
mov    -0x8(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d3 <factor+0xc3>
jmp    11d8 <factor+0xc8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1153 <factor+0x43>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factor>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xed0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebx
jae    1158 <factor+0x38>
lea    0xec0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
mov    $0x2,%ebp
lea    0xea5(%rip),%r14
lea    0xea5(%rip),%r15
jmp    1188 <factor+0x68>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x1,%ebx
jbe    11cb <factor+0xab>
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
test   %edx,%edx
jne    1180 <factor+0x60>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ecx
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%ebx
xor    %edx,%edx
div    %ebp
test   %edx,%edx
je     11a0 <factor+0x80>
cmp    $0x2,%ecx
jae    116d <factor+0x4d>
cmp    $0x1,%ecx
jne    1180 <factor+0x60>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <factor+0x60>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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