#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() {
  long long int i, n, j, temp;
  int count1 = 0, count2 = 0;
  printf("Problem 3: Given an input n, the program will print out its prime "
         "factorization.\n");
  printf("Please enter input n: ");
  scanf("%lld", &n);
  temp = 2;
  printf("The output is: %lld = ", n);
  for (i = 2; (i < 100000); i++) {
    for (j = 2; j <= (i / j); j++) {
      if (!(i % j)) {
        break;
      }
    }
    if (j > (i / j)) {
      while (n > 0) {
        if (n % i != 0) {
          break;
        } else {
          if (temp == i) {
            while (n % i == 0) {
              count1++;
              n = n / i;
            }
            if (count2 == 0) {
              printf("%lld", i);
              count2++;
            }
            if (count1 > 1) {
              printf("^%d", count1);
            }
          } else {
            count1 = 0;
            temp = i;
            count2 = 0;
            printf(" x ");
            continue;
          }
        }
      }
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movq   $0x2,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x2,-0x10(%rbp)
cmpq   $0x186a0,-0x10(%rbp)
jge    1313 <main+0x1f3>
movq   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jg     11f2 <main+0xd2>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x20(%rbp)
cmp    $0x0,%rdx
jne    11dc <main+0xbc>
jmp    11f2 <main+0xd2>
jmp    11e1 <main+0xc1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a1 <main+0x81>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jle    12fd <main+0x1dd>
jmp    1219 <main+0xf9>
cmpq   $0x0,-0x18(%rbp)
jle    12f8 <main+0x1d8>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
cmp    $0x0,%rdx
je     123d <main+0x11d>
jmp    12f8 <main+0x1d8>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    12c5 <main+0x1a5>
jmp    1250 <main+0x130>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
cmp    $0x0,%rdx
jne    1280 <main+0x160>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rax,-0x18(%rbp)
jmp    1250 <main+0x130>
cmpl   $0x0,-0x30(%rbp)
jne    12a5 <main+0x185>
mov    -0x10(%rbp),%rsi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x1,-0x2c(%rbp)
jle    12c0 <main+0x1a0>
mov    -0x2c(%rbp),%esi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ee <main+0x1ce>
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1219 <main+0xf9>
jmp    12f3 <main+0x1d3>
jmp    1219 <main+0xf9>
jmp    12fd <main+0x1dd>
jmp    1302 <main+0x1e2>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118b <main+0x6b>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee9(%rip),%rdi
call   1040 <puts@plt>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeab(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%rsi
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2,%esi
lea    0xea1(%rip),%r15
lea    0xe9e(%rip),%r12
xor    %ebp,%ebp
xor    %ebx,%ebx
mov    $0x2,%r13d
jmp    11c4 <main+0x84>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rsi
add    $0x1,%r13
cmp    $0x186a0,%r13
je     1341 <main+0x201>
mov    $0x1,%ecx
cmp    $0x4,%r13
jae    1310 <main+0x1d0>
mov    (%rsp),%rcx
test   %rcx,%rcx
jg     11ec <main+0xac>
jmp    11b3 <main+0x73>
xchg   %ax,%ax
mov    (%rsp),%rcx
mov    %r13,%rsi
test   %rcx,%rcx
jle    11b0 <main+0x70>
mov    %rcx,%rax
or     %r13,%rax
shr    $0x20,%rax
je     1210 <main+0xd0>
mov    %rcx,%rax
cqto
idiv   %r13
test   %rdx,%rdx
je     121c <main+0xdc>
jmp    11b3 <main+0x73>
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %r13d
test   %rdx,%rdx
jne    11b3 <main+0x73>
cmp    %r13,%rsi
je     1250 <main+0x110>
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %ebp,%ebp
jmp    11e0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rax
cqto
idiv   %r13
add    $0x1,%ebx
test   %rdx,%rdx
jne    1290 <main+0x150>
mov    %rcx,%rax
or     %r13,%rax
shr    $0x20,%rax
je     1270 <main+0x130>
mov    %rcx,%rax
cqto
idiv   %r13
mov    %rax,%rcx
jmp    1279 <main+0x139>
nopl   0x0(%rax)
mov    %ecx,%eax
xor    %edx,%edx
div    %r13d
mov    %eax,%ecx
mov    %rcx,%rax
or     %r13,%rax
shr    $0x20,%rax
jne    1240 <main+0x100>
mov    %ecx,%eax
xor    %edx,%edx
div    %r13d
jmp    1248 <main+0x108>
xchg   %ax,%ax
mov    %rcx,(%rsp)
lea    -0x1(%rbx),%r14d
test   %ebp,%ebp
jne    12ad <main+0x16d>
lea    0xd74(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebp
test   %r14d,%r14d
jle    11e0 <main+0xa0>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e0 <main+0xa0>
nopl   0x0(%rax)
mov    %r13,%rax
xor    %edx,%edx
div    %rdi
cmp    %rax,%rcx
jb     1310 <main+0x1d0>
jmp    11d3 <main+0x93>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x2,%rdi
mov    %r13,%rax
or     %rdi,%rax
shr    $0x20,%rax
jne    12d0 <main+0x190>
mov    %r13d,%eax
xor    %edx,%edx
div    %edi
cmp    %rax,%rcx
jae    11d3 <main+0x93>
mov    %rcx,%rdi
add    $0x1,%rcx
mov    %r13,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1330 <main+0x1f0>
mov    %r13,%rax
xor    %edx,%edx
div    %rcx
jmp    1337 <main+0x1f7>
nopl   (%rax)
mov    %r13d,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
jne    12f0 <main+0x1b0>
jmp    11b3 <main+0x73>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [82 x i8] c"Problem 3: Given an input n, the program will print out its prime factorization.\0A\00"
@.str.1 = [23 x i8] c"Please enter input n: \00"
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [23 x i8] c"The output is: %lld = \00"
@.str.4 = [4 x i8] c"^%d\00"
@.str.5 = [4 x i8] c" x \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %3)
store i64 2, i64* %5
%11 = load i64, i64* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i64 %11)
store i64 2, i64* %2
br label %13
13: ; preds = %87, %0
%14 = load i64, i64* %2
%15 = icmp slt i64 %14, 100000
br i1 %15, label %16, label %90
16: ; preds = %13
store i64 2, i64* %4
br label %17
17: ; preds = %30, %16
%18 = load i64, i64* %4
%19 = load i64, i64* %2
%20 = load i64, i64* %4
%21 = sdiv i64 %19, %20
%22 = icmp sle i64 %18, %21
br i1 %22, label %23, label %33
23: ; preds = %17
%24 = load i64, i64* %2
%25 = load i64, i64* %4
%26 = srem i64 %24, %25
%27 = icmp ne i64 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %23
br label %33
29: ; preds = %23
br label %30
30: ; preds = %29
%31 = load i64, i64* %4
%32 = add nsw i64 %31, 1
store i64 %32, i64* %4
br label %17
33: ; preds = %28, %17
%34 = load i64, i64* %4
%35 = load i64, i64* %2
%36 = load i64, i64* %4
%37 = sdiv i64 %35, %36
%38 = icmp sgt i64 %34, %37
br i1 %38, label %39, label %86
39: ; preds = %33
br label %40
40: ; preds = %84, %80, %39
%41 = load i64, i64* %3
%42 = icmp sgt i64 %41, 0
br i1 %42, label %43, label %85
43: ; preds = %40
%44 = load i64, i64* %3
%45 = load i64, i64* %2
%46 = srem i64 %44, %45
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %43
br label %85
49: ; preds = %43
%50 = load i64, i64* %5
%51 = load i64, i64* %2
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %80
53: ; preds = %49
br label %54
54: ; preds = %59, %53
%55 = load i64, i64* %3
%56 = load i64, i64* %2
%57 = srem i64 %55, %56
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %65
59: ; preds = %54
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
%62 = load i64, i64* %3
%63 = load i64, i64* %2
%64 = sdiv i64 %62, %63
store i64 %64, i64* %3
br label %54
65: ; preds = %54
%66 = load i32, i32* %7
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %73
68: ; preds = %65
%69 = load i64, i64* %2
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %69)
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %73
73: ; preds = %68, %65
%74 = load i32, i32* %6
%75 = icmp sgt i32 %74, 1
br i1 %75, label %76, label %79
76: ; preds = %73
%77 = load i32, i32* %6
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %76, %73
br label %83
80: ; preds = %49
store i32 0, i32* %6
%81 = load i64, i64* %2
store i64 %81, i64* %5
store i32 0, i32* %7
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %40
83: ; preds = %79
br label %84
84: ; preds = %83
br label %40
85: ; preds = %48, %40
br label %86
86: ; preds = %85, %33
br label %87
87: ; preds = %86
%88 = load i64, i64* %2
%89 = add nsw i64 %88, 1
store i64 %89, i64* %2
br label %13
90: ; preds = %13
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%92 = load i32, i32* %1
ret i32 %92
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"Please enter input n: \00"
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [23 x i8] c"The output is: %lld = \00"
@.str.4 = [4 x i8] c"^%d\00"
@.str.5 = [4 x i8] c" x \00"
@str = [81 x i8] c"Problem 3: Given an input n, the program will print out its prime factorization.\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i64 %6)
br label %8
8: ; preds = %0, %56
%9 = phi i32 [ 0, %0 ], [ %59, %56 ]
%10 = phi i32 [ 0, %0 ], [ %58, %56 ]
%11 = phi i64 [ 2, %0 ], [ %57, %56 ]
%12 = phi i64 [ 2, %0 ], [ %60, %56 ]
%13 = icmp ult i64 %12, 4
br i1 %13, label %22, label %17
14: ; preds = %17
%15 = udiv i64 %12, %21
%16 = icmp ult i64 %18, %15
br i1 %16, label %17, label %22
17: ; preds = %8, %14
%18 = phi i64 [ %21, %14 ], [ 2, %8 ]
%19 = urem i64 %12, %18
%20 = icmp eq i64 %19, 0
%21 = add nuw nsw i64 %18, 1
br i1 %20, label %56, label %14
22: ; preds = %14, %8
%23 = load i64, i64* %1
%24 = icmp sgt i64 %23, 0
br i1 %24, label %30, label %56
25: ; preds = %50, %52, %54
%26 = phi i32 [ 0, %54 ], [ %42, %52 ], [ %42, %50 ]
%27 = phi i32 [ 0, %54 ], [ 1, %52 ], [ 1, %50 ]
%28 = load i64, i64* %1
%29 = icmp sgt i64 %28, 0
br i1 %29, label %30, label %56
30: ; preds = %22, %25
%31 = phi i64 [ %28, %25 ], [ %23, %22 ]
%32 = phi i64 [ %12, %25 ], [ %11, %22 ]
%33 = phi i32 [ %26, %25 ], [ %10, %22 ]
%34 = phi i32 [ %27, %25 ], [ %9, %22 ]
%35 = srem i64 %31, %12
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %56
37: ; preds = %30
%38 = icmp eq i64 %32, %12
br i1 %38, label %39, label %54
39: ; preds = %37, %39
%40 = phi i32 [ %42, %39 ], [ %33, %37 ]
%41 = phi i64 [ %43, %39 ], [ %31, %37 ]
%42 = add nsw i32 %40, 1
%43 = sdiv i64 %41, %12
%44 = srem i64 %43, %12
%45 = icmp eq i64 %44, 0
br i1 %45, label %39, label %46
46: ; preds = %39
store i64 %43, i64* %1
%47 = icmp eq i32 %34, 0
br i1 %47, label %48, label %50
48: ; preds = %46
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %12)
br label %50
50: ; preds = %48, %46
%51 = icmp sgt i32 %40, 0
br i1 %51, label %52, label %25
52: ; preds = %50
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %42)
br label %25
54: ; preds = %37
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %25
56: ; preds = %17, %30, %25, %22
%57 = phi i64 [ %11, %22 ], [ %12, %25 ], [ %32, %30 ], [ %11, %17 ]
%58 = phi i32 [ %10, %22 ], [ %26, %25 ], [ %33, %30 ], [ %10, %17 ]
%59 = phi i32 [ %9, %22 ], [ %27, %25 ], [ %34, %30 ], [ %9, %17 ]
%60 = add nuw nsw i64 %12, 1
%61 = icmp eq i64 %60, 100000
br i1 %61, label %62, label %8
62: ; preds = %56
%63 = call i32 @putchar(i32 10)
ret i32 0
}