#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);
int prime_factor(int nb) {
  int i;
  i = 2;
  while (i < nb) {
    if (nb % i == 0) {
      printf("%d*", i);
      nb /= i;
    } else {
      i++;
    }
    printf("%d", nb);
  }
  return (nb);
}


x86 assembly (clang, -O0):
<prime_factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117b <prime_factor+0x6b>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    115e <prime_factor+0x4e>
mov    -0x8(%rbp),%esi
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1167 <prime_factor+0x57>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    1122 <prime_factor+0x12>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prime_factor>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebx
cmp    $0x3,%edi
jl     116c <prime_factor+0x5c>
mov    $0x2,%ebp
lea    0xed5(%rip),%r14
lea    0xed2(%rip),%r15
jmp    1151 <prime_factor+0x41>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmp    %ebx,%ebp
jge    116c <prime_factor+0x5c>
mov    %ebx,%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    1140 <prime_factor+0x30>
mov    %eax,%r12d
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r12d,%ebx
jmp    1143 <prime_factor+0x33>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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