#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 /*<<< orphan*/ system(char *);
int main() {
  int num, fatt, cont;
  printf("\nInserisci un numero intero \n");
  scanf("%d", &num);
  printf("\n i fattori primi di %d sono:", num);
  for (fatt = num; fatt > 1; fatt--) {
    if (num % fatt == 0) {
      cont = fatt - 1;
      while ((cont > 1) && (fatt % cont != 0))
        cont--;
      if (cont == 1)
        printf(" %d ", fatt);
    }
  }
  printf("\n");
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    1207 <main+0xd7>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11f4 <main+0xc4>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jle    11b6 <main+0x86>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11c6 <main+0x96>
jmp    11d4 <main+0xa4>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1197 <main+0x67>
cmpl   $0x1,-0x10(%rbp)
jne    11ef <main+0xbf>
mov    -0xc(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f4 <main+0xc4>
jmp    11f9 <main+0xc9>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <main+0x44>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe28(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jl     11ef <main+0x9f>
lea    0xe8f(%rip),%rbx
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltd
idiv   %ebp
test   %edx,%edx
jne    11d0 <main+0x80>
mov    %ebp,%ecx
nopl   0x0(%rax)
cmp    $0x3,%ecx
jb     11de <main+0x8e>
add    $0xffffffff,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
test   %edx,%edx
jne    11b0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x3,%ebp
jl     11ef <main+0x9f>
add    $0xffffffff,%ebp
mov    0x4(%rsp),%eax
jmp    11a0 <main+0x50>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x3,%ebp
jge    11d5 <main+0x85>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe26(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0AInserisci un numero intero \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"\0A i fattori primi di %d sono:\00"
@.str.3 = [5 x i8] c" %d \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
store i32 %9, i32* %3
br label %10
10: ; preds = %42, %0
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %45
13: ; preds = %10
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = srem i32 %14, %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %41
18: ; preds = %13
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %4
br label %21
21: ; preds = %31, %18
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 1
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = srem i32 %25, %26
%28 = icmp ne i32 %27, 0
br label %29
29: ; preds = %24, %21
%30 = phi i1 [ false, %21 ], [ %28, %24 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i32, i32* %4
%33 = add nsw i32 %32, -1
store i32 %33, i32* %4
br label %21
34: ; preds = %29
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %34
br label %41
41: ; preds = %40, %13
br label %42
42: ; preds = %41
%43 = load i32, i32* %3
%44 = add nsw i32 %43, -1
store i32 %44, i32* %3
br label %10
45: ; preds = %10
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%47 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"\0A i fattori primi di %d sono:\00"
@.str.3 = [5 x i8] c" %d \00"
@.str.5 = [6 x i8] c"pause\00"
@str = [29 x i8] c"\0AInserisci un numero intero \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 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 ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %28
9: ; preds = %0, %25
%10 = phi i32 [ %27, %25 ], [ %7, %0 ]
%11 = phi i32 [ %26, %25 ], [ %7, %0 ]
%12 = srem i32 %10, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %9, %18
%15 = phi i32 [ %16, %18 ], [ %11, %9 ]
%16 = add nsw i32 %15, -1
%17 = icmp ugt i32 %15, 2
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = srem i32 %11, %16
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %14
21: ; preds = %14
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %11)
br label %23
23: ; preds = %18, %9, %21
%24 = icmp sgt i32 %11, 2
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = add nsw i32 %11, -1
%27 = load i32, i32* %1
br label %9
28: ; preds = %23, %0
%29 = call i32 @putchar(i32 10)
%30 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}