#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 *);
main() {
  int n;
  int fator;
  int mult;
  printf("Decomponho um numero dado em fatores primos.\n");
  printf("Entre com o numero (> 1) a ser decomposto: ");
  scanf("%d", &n);
  printf("Decomposicao de %d em fatores primos:\n", n);
  fator = 2;
  while (n > 1) {
    mult = 0;
    while (n % fator == 0) {
      mult++;
      n = n / fator;
    }
    if (mult != 0) {
      printf("  fator %d multiplicidade %d\n", fator, mult);
    }
    fator++;
  }
  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    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11d8 <main+0xb8>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11ac <main+0x8c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x64>
cmpl   $0x0,-0x10(%rbp)
je     11ca <main+0xaa>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <main+0x53>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xf35(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x2,%ecx
jl     11d9 <main+0xa9>
mov    $0x2,%ebp
lea    0xecc(%rip),%r14
jmp    1198 <main+0x68>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x1,%ecx
jle    11d9 <main+0xa9>
mov    %ecx,%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    1190 <main+0x60>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebx
mov    %ecx,%eax
cltd
idiv   %ebp
mov    %eax,%ecx
cltd
idiv   %ebp
test   %edx,%edx
je     11b0 <main+0x80>
mov    %ecx,0xc(%rsp)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
jmp    1190 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Decomponho um numero dado em fatores primos.\0A\00"
@.str.1 = [44 x i8] c"Entre com o numero (> 1) a ser decomposto: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [39 x i8] c"Decomposicao de %d em fatores primos:\0A\00"
@.str.4 = [30 x i8] c" fator %d multiplicidade %d\0A\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 ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %8)
store i32 2, i32* %3
br label %10
10: ; preds = %32, %0
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %35
13: ; preds = %10
store i32 0, i32* %4
br label %14
14: ; preds = %19, %13
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = srem i32 %15, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = sdiv i32 %22, %23
store i32 %24, i32* %2
br label %14
25: ; preds = %14
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 %30)
br label %32
32: ; preds = %28, %25
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %10
35: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [44 x i8] c"Entre com o numero (> 1) a ser decomposto: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [39 x i8] c"Decomposicao de %d em fatores primos:\0A\00"
@.str.4 = [30 x i8] c" fator %d multiplicidade %d\0A\00"
@str = [45 x i8] c"Decomponho um numero dado em fatores primos.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %29
10: ; preds = %0, %25
%11 = phi i32 [ %26, %25 ], [ %8, %0 ]
%12 = phi i32 [ %27, %25 ], [ 2, %0 ]
%13 = srem i32 %11, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %10, %15
%16 = phi i32 [ %18, %15 ], [ 0, %10 ]
%17 = phi i32 [ %19, %15 ], [ %11, %10 ]
%18 = add nuw nsw i32 %16, 1
%19 = sdiv i32 %17, %12
%20 = srem i32 %19, %12
%21 = icmp eq i32 %20, 0
br i1 %21, label %15, label %22
22: ; preds = %15
store i32 %19, i32* %1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %12, i32 %18)
%24 = load i32, i32* %1
br label %25
25: ; preds = %10, %22
%26 = phi i32 [ %24, %22 ], [ %11, %10 ]
%27 = add nuw nsw i32 %12, 1
%28 = icmp sgt i32 %26, 1
br i1 %28, label %10, label %29
29: ; preds = %25, %0
ret i32 0
}