#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 getSmallestFactor(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int in, fact;
  printf("Type in a number: ");
  scanf("%d", &in);
  while (in > 0) {
    if (in == 1) {
      printf("1 is not a prime number.\n");
      return 0;
    }
    fact = getSmallestFactor(in);
    if (fact == 0) {
      break;
    }
    printf("%d*", fact);
    in /= fact;
  }
  if (in == 0) {
    printf("\n");
  } else {
    printf("%d\n", in);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11c7 <main+0x97>
cmpl   $0x1,-0x8(%rbp)
jne    118b <main+0x5b>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f5 <main+0xc5>
mov    -0x8(%rbp),%edi
call   1050 <getSmallestFactor@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11a5 <main+0x75>
jmp    11c7 <main+0x97>
mov    -0xc(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x2d>
cmpl   $0x0,-0x8(%rbp)
jne    11e4 <main+0xb4>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <main+0xc5>
mov    -0x8(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeab(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11bd <main+0x6d>
lea    0xe95(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%eax
je     11d3 <main+0x83>
mov    %eax,%edi
call   1070 <getSmallestFactor@plt>
test   %eax,%eax
je     11e1 <main+0x91>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
cltd
idiv   %ebp
mov    %eax,0x4(%rsp)
test   %eax,%eax
jg     1190 <main+0x40>
test   %eax,%eax
je     11e9 <main+0x99>
lea    0xe52(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11f3 <main+0xa3>
lea    0xe44(%rip),%rdi
call   1040 <puts@plt>
jmp    11f3 <main+0xa3>
mov    0x4(%rsp),%eax
test   %eax,%eax
jne    11c1 <main+0x71>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Type in a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"1 is not a prime number.\0A\00"
@.str.3 = [4 x i8] c"%d*\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [4 x i8] c"%d\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 ([19 x i8], [19 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)
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %34
14: ; preds = %9
%15 = load i32, i32* %2
%16 = call i32 @getSmallestFactor(i32 %15)
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %26
20: ; preds = %14
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = sdiv i32 %24, %23
store i32 %25, i32* %2
br label %6
26: ; preds = %19, %6
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %34
31: ; preds = %26
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %12, %31, %29
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [19 x i8] c"Type in a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d*\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@str = [25 x i8] c"1 is not a prime number.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %0, %17
%8 = phi i32 [ %20, %17 ], [ %5, %0 ]
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %29
12: ; preds = %7
%13 = call i32 @getSmallestFactor(i32 %8)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i32, i32* %1
br label %22
17: ; preds = %12
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%19 = load i32, i32* %1
%20 = sdiv i32 %19, %13
store i32 %20, i32* %1
%21 = icmp sgt i32 %20, 0
br i1 %21, label %7, label %22
22: ; preds = %17, %15, %0
%23 = phi i32 [ %5, %0 ], [ %16, %15 ], [ %20, %17 ]
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @putchar(i32 10)
br label %29
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %23)
br label %29
29: ; preds = %25, %27, %10
ret i32 0
}