#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char **argv) {
  int num, divisor;
  num = 1;
  while (num < 2) {
    printf("Introdueix un numero enter positiu: ");
    scanf("%d", &num);
  }
  divisor = 2;
  printf("%d = ", num);
  while (num != 1) {
    if (num % divisor == 0) {
      printf("%d x ", divisor);
      num = num / divisor;
    } else
      divisor++;
  }
  printf("1\n");
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    116a <main+0x4a>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
jmp    113d <main+0x1d>
movl   $0x2,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
je     11ca <main+0xaa>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x0,%edx
jne    11bc <main+0x9c>
mov    -0x18(%rbp),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x14(%rbp)
jmp    11c5 <main+0xa5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1182 <main+0x62>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
lea    0xeb8(%rip),%r14
lea    0xed6(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0x2,%esi
jl     1160 <main+0x30>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x1,%ecx
je     11df <main+0xaf>
mov    $0x2,%ebx
lea    0xe8d(%rip),%r14
jmp    11b8 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebx
cmp    $0x1,%ecx
je     11df <main+0xaf>
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    11b0 <main+0x80>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cltd
idiv   %ebx
mov    %eax,%ecx
mov    %eax,0xc(%rsp)
cmp    $0x1,%ecx
jne    11b8 <main+0x88>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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