#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num;
  printf("Insira o número para fatorizar: ");
  scanf("%d", &num);
  for (int i = 2; i <= num;) {
    if (num % i == 0) {
      printf("%d ", i);
      num /= i;
      if (num == 1) {
        break;
      }
    } else {
      ++i;
    }
  }
  puts("");
  return 0;
}


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   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11bf <main+0x8f>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11b1 <main+0x81>
mov    -0xc(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ac <main+0x7c>
jmp    11bf <main+0x8f>
jmp    11ba <main+0x8a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x34>
lea    0xe5b(%rip),%rdi
call   1030 <puts@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    0xed9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
cmp    $0x2,%ecx
jl     119e <main+0x6e>
mov    $0x2,%ebx
lea    0xebd(%rip),%r14
jmp    1177 <main+0x47>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ecx,%ebx
jg     119e <main+0x6e>
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1170 <main+0x40>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
cltd
idiv   %ebx
mov    %eax,%ecx
mov    %eax,0x4(%rsp)
cmp    $0x1,%eax
jne    1173 <main+0x43>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Insira o n\C3\BAmero para fatorizar: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [1 x i8] zeroinitializer
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 ([34 x i8], [34 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)
store i32 2, i32* %3
br label %6
6: ; preds = %28, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %6
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = srem i32 %11, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %10
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = sdiv i32 %19, %18
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %24
23: ; preds = %15
br label %29
24: ; preds = %15
br label %28
25: ; preds = %10
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %28
28: ; preds = %25, %24
br label %6
29: ; preds = %23, %6
%30 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Insira o n\C3\BAmero para fatorizar: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 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 ([34 x i8], [34 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 slt i32 %5, 2
br i1 %6, label %23, label %7
7: ; preds = %0, %19
%8 = phi i32 [ %20, %19 ], [ %5, %0 ]
%9 = phi i32 [ %21, %19 ], [ 2, %0 ]
%10 = srem i32 %8, %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%14 = load i32, i32* %1
%15 = sdiv i32 %14, %9
store i32 %15, i32* %1
%16 = icmp eq i32 %15, 1
br i1 %16, label %23, label %19
17: ; preds = %7
%18 = add nsw i32 %9, 1
br label %19
19: ; preds = %12, %17
%20 = phi i32 [ %15, %12 ], [ %8, %17 ]
%21 = phi i32 [ %9, %12 ], [ %18, %17 ]
%22 = icmp sgt i32 %21, %20
br i1 %22, label %23, label %7
23: ; preds = %19, %12, %0
%24 = call i32 @putchar(i32 10)
ret i32 0
}