#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 */
scalar_t__ is_prime(unsigned long);
int /*<<< orphan*/ print_repetition(unsigned long, unsigned long,
                                    unsigned long *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned long *);
int main(void) {
  unsigned long int number, index, rep;
  short int two_flag = 0;
  printf("Please, enter a positive number to factorize:  ");
  scanf("%lu", &number);
  printf("\n\n%lu: ", number);
  index = 2;
  do {
    if (index == 3)
      two_flag = 1;
    if (is_prime(index)) {
      print_repetition(number, index, &rep);
    }
    if (two_flag == 0) {
      index++;
    } else {
      index += 2;
    }
  } while ((index <= (number / 2)) || !two_flag);
  if (is_prime(number)) {
    print_repetition(number, number, &rep);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x0,-0x22(%rbp)
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x2,-0x18(%rbp)
cmpq   $0x3,-0x18(%rbp)
jne    119e <main+0x5e>
movw   $0x1,-0x22(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     11c2 <main+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <print_repetition@plt>
movswl -0x22(%rbp),%eax
cmp    $0x0,%eax
jne    11e0 <main+0xa0>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11ec <main+0xac>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    11f1 <main+0xb1>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rdx
shr    $0x1,%rdx
mov    $0x1,%al
cmp    %rdx,%rcx
mov    %al,-0x23(%rbp)
jbe    1218 <main+0xd8>
cmpw   $0x0,-0x22(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%al
test   $0x1,%al
jne    118d <main+0x4d>
mov    -0x10(%rbp),%rdi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     1247 <main+0x107>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <print_repetition@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe9f(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%rsi
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebx
mov    $0x1,%r15d
lea    0x10(%rsp),%r14
xchg   %ax,%ax
cmp    $0x3,%rbx
cmove  %r15d,%ebp
mov    %rbx,%rdi
call   1050 <is_prime@plt>
test   %rax,%rax
je     11c5 <main+0x75>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <print_repetition@plt>
cmp    $0x1,%bp
sbb    $0x0,%rbx
add    $0x2,%rbx
mov    0x8(%rsp),%rdi
mov    %rdi,%rax
shr    %rax
cmp    %rax,%rbx
jbe    11a0 <main+0x50>
test   %bp,%bp
je     11a0 <main+0x50>
call   1050 <is_prime@plt>
test   %rax,%rax
je     1202 <main+0xb2>
mov    0x8(%rsp),%rdi
lea    0x10(%rsp),%rdx
mov    %rdi,%rsi
call   1070 <print_repetition@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Please, enter a positive number to factorize: \00"
@.str.1 = [4 x i8] c"%lu\00"
@.str.2 = [8 x i8] c"\0A\0A%lu: \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i16
store i32 0, i32* %1
store i16 0, i16* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%8 = load i64, i64* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %8)
store i64 2, i64* %3
br label %10
10: ; preds = %42, %0
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 3
br i1 %12, label %13, label %14
13: ; preds = %10
store i16 1, i16* %5
br label %14
14: ; preds = %13, %10
%15 = load i64, i64* %3
%16 = call i64 @is_prime(i64 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i64, i64* %2
%20 = load i64, i64* %3
%21 = call i32 @print_repetition(i64 %19, i64 %20, i64* %4)
br label %22
22: ; preds = %18, %14
%23 = load i16, i16* %5
%24 = sext i16 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i64, i64* %3
%28 = add i64 %27, 1
store i64 %28, i64* %3
br label %32
29: ; preds = %22
%30 = load i64, i64* %3
%31 = add i64 %30, 2
store i64 %31, i64* %3
br label %32
32: ; preds = %29, %26
br label %33
33: ; preds = %32
%34 = load i64, i64* %3
%35 = load i64, i64* %2
%36 = udiv i64 %35, 2
%37 = icmp ule i64 %34, %36
br i1 %37, label %42, label %38
38: ; preds = %33
%39 = load i16, i16* %5
%40 = icmp ne i16 %39, 0
%41 = xor i1 %40, true
br label %42
42: ; preds = %38, %33
%43 = phi i1 [ true, %33 ], [ %41, %38 ]
br i1 %43, label %10, label %44
44: ; preds = %42
%45 = load i64, i64* %2
%46 = call i64 @is_prime(i64 %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = load i64, i64* %2
%50 = load i64, i64* %2
%51 = call i32 @print_repetition(i64 %49, i64 %50, i64* %4)
br label %52
52: ; preds = %48, %44
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [48 x i8] c"Please, enter a positive number to factorize: \00"
@.str.1 = [4 x i8] c"%lu\00"
@.str.2 = [8 x i8] c"\0A\0A%lu: \00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%7 = load i64, i64* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %7)
br label %9
9: ; preds = %19, %0
%10 = phi i64 [ 2, %0 ], [ %22, %19 ]
%11 = phi i16 [ 0, %0 ], [ %13, %19 ]
%12 = icmp eq i64 %10, 3
%13 = select i1 %12, i16 1, i16 %11
%14 = call i64 @is_prime(i64 %10)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = load i64, i64* %1
%18 = call i32 @print_repetition(i64 %17, i64 %10, i64* %2)
br label %19
19: ; preds = %16, %9
%20 = icmp eq i16 %13, 0
%21 = select i1 %20, i64 1, i64 2
%22 = add i64 %21, %10
%23 = load i64, i64* %1
%24 = lshr i64 %23, 1
%25 = icmp ule i64 %22, %24
%26 = select i1 %25, i1 true, i1 %20
br i1 %26, label %9, label %27
27: ; preds = %19
%28 = call i64 @is_prime(i64 %23)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i64, i64* %1
%32 = call i32 @print_repetition(i64 %31, i64 %31, i64* %2)
br label %33
33: ; preds = %30, %27
%34 = call i32 @putchar(i32 10)
ret i32 0
}