#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 prime(int number) {
  int i;
  for (i = 2; i <= number; i++) {
    int count = 0;
    while (number % i == 0) {
      number /= i;
      count++;
    }
    if (count > 0) {
      printf("%d", i);
      if (count >= 2)
        printf(" ^ %d", count);
      if (number > 1)
        printf(" * ");
    }
  }
}


x86 assembly (clang, -O0):
<prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11c5 <prime+0xb5>
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    115f <prime+0x4f>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <prime+0x25>
cmpl   $0x0,-0xc(%rbp)
jle    11b2 <prime+0xa2>
mov    -0x8(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0xc(%rbp)
jl     1195 <prime+0x85>
mov    -0xc(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jle    11ad <prime+0x9d>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b2 <prime+0xa2>
jmp    11b7 <prime+0xa7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <prime+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    112f <prime+0x1f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%ebp
mov    $0x2,%r13d
lea    0xec5(%rip),%r14
lea    0xec1(%rip),%r15
lea    0xeb4(%rip),%r12
jmp    115c <prime+0x4c>
xchg   %ax,%ax
lea    0x1(%r13),%eax
cmp    %ebp,%r13d
mov    %eax,%r13d
jge    1120 <prime+0x10>
mov    %ebp,%eax
cltd
idiv   %r13d
test   %edx,%edx
jne    1150 <prime+0x40>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
cltd
idiv   %r13d
add    $0x1,%ebx
mov    %eax,%ebp
cltd
idiv   %r13d
test   %edx,%edx
je     1170 <prime+0x60>
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%ebx
je     11a1 <prime+0x91>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x2,%ebp
jl     1150 <prime+0x40>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1150 <prime+0x40>

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

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