#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 *, int *);
int main() {
  int n, d;
  printf("Number: ");
  scanf("%d", &n);
  printf("%d = ", n);
  for (d = 2; d <= n;) {
    if ((n % d) == 0) {
      printf("%d", d);
      n /= d;
      if (n > 1)
        printf("*");
    } else
      d++;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c9 <main+0xa9>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11bb <main+0x9b>
mov    -0xc(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11b6 <main+0x96>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c4 <main+0xa4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <main+0x45>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%ecx
cmp    $0x2,%ecx
jge    1182 <main+0x52>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x2,%ebx
lea    0xe7b(%rip),%r14
jmp    1197 <main+0x67>
add    $0x1,%ebx
cmp    %ecx,%ebx
jg     116e <main+0x3e>
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1190 <main+0x60>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
cltd
idiv   %ebx
mov    %eax,0x4(%rsp)
cmp    $0x2,%eax
jl     11cc <main+0x9c>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%ecx
jmp    1193 <main+0x63>
mov    %eax,%ecx
jmp    1193 <main+0x63>

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

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