#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;
  if (n < 2)
    return;
  printf("Prime factors of '%d': ", n);
  while (d < n) {
    if (n % d == 0) {
      printf("%d x ", d);
      n /= d;
    } else {
      if (d == 2)
        d = 3;
      else
        d += 2;
    }
  }
  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)
cmpl   $0x2,-0x4(%rbp)
jge    1131 <factorize+0x21>
jmp    11b4 <factorize+0xa4>
mov    -0x4(%rbp),%esi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a5 <factorize+0x95>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    117c <factorize+0x6c>
mov    -0x8(%rbp),%esi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11a0 <factorize+0x90>
cmpl   $0x2,-0x8(%rbp)
jne    1192 <factorize+0x82>
movl   $0x3,-0x8(%rbp)
jmp    119b <factorize+0x8b>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    11a0 <factorize+0x90>
jmp    1140 <factorize+0x30>
mov    -0x8(%rbp),%esi
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factorize>:
cmp    $0x2,%edi
jge    1116 <factorize+0x6>
ret
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
lea    0xed8(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    $0x2,%ebx
cmp    $0x2,%r15d
je     117f <factorize+0x6f>
mov    $0x2,%ebx
lea    0xed1(%rip),%r14
mov    $0x3,%r12d
jmp    1161 <factorize+0x51>
nop
cmp    $0x2,%ebx
lea    0x2(%rbx),%eax
cmove  %r12d,%eax
mov    %eax,%ebx
cmp    %r15d,%ebx
jge    117f <factorize+0x6f>
mov    %r15d,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1150 <factorize+0x40>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebp,%r15d
cmp    %r15d,%ebx
jl     1161 <factorize+0x51>
lea    0xe98(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

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

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