#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);
void factorize(int n) {
  int d = 2;
  int i;
  int quotient = 0;
  printf("%d's prime factors are: ", n);
  while (n > 1) {
    if (n % d == 0) {
      n /= d;
      quotient++;
    } else {
      if (quotient != 0) {
        printf("%d ", d);
      }
      quotient = 0;
      d++;
    }
  }
  printf("%d\n", d);
}


x86 assembly (clang, -O0):
<factorize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%esi
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jle    119a <factorize+0x8a>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    116c <factorize+0x5c>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1195 <factorize+0x85>
cmpl   $0x0,-0x10(%rbp)
je     1185 <factorize+0x75>
mov    -0x8(%rbp),%esi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1138 <factorize+0x28>
mov    -0x8(%rbp),%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factorize>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
lea    0xee3(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    $0x2,%ebx
cmp    $0x2,%ebp
jl     116b <factorize+0x5b>
mov    $0x2,%ebx
xor    %ecx,%ecx
lea    0xedd(%rip),%r14
jmp    114a <factorize+0x3a>
xchg   %ax,%ax
add    $0x1,%ecx
mov    %eax,%ebp
cmp    $0x1,%ebp
jle    116b <factorize+0x5b>
mov    %ebp,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     1140 <factorize+0x30>
test   %ecx,%ecx
je     1161 <factorize+0x51>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
xor    %ecx,%ecx
cmp    $0x1,%ebp
jg     114a <factorize+0x3a>
lea    0xeab(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

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

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