#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int sqrt(int);
void six() {
  int number, divisor = 2, n;
  printf("enter number (int): ");
  scanf("%d", &number);
  printf("\ngenerated prime factorization: ");
  n = number;
  while (number % divisor == 0) {
    number /= divisor;
    printf("%d * ", divisor);
  }
  for (divisor = 3; divisor <= sqrt(number); divisor += 2)
    while (number % divisor == 0) {
      number /= divisor;
      printf("%d * ", divisor);
    }
  printf("%d\n", number);
  if (number == n)
    printf("note: the number is prime\n");
  getchar();
  printf("\nreturning to menu. press Enter...");
  getchar();
}


x86 assembly (clang, -O0):
<six>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x2,-0x8(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    11b3 <six+0x73>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1181 <six+0x41>
movl   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     121f <six+0xdf>
jmp    11da <six+0x9a>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    120c <six+0xcc>
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11da <six+0x9a>
jmp    1211 <six+0xd1>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    11ba <six+0x7a>
mov    -0x4(%rbp),%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    124a <six+0x10a>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<six>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
test   $0x1,%bpl
jne    11c6 <six+0x76>
lea    0xea1(%rip),%rbx
mov    %ebp,%edi
nopw   0x0(%rax,%rax,1)
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
sar    %eax
mov    %eax,0xc(%rsp)
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
test   $0x1,%dil
je     11a0 <six+0x50>
call   1070 <sqrt@plt>
cmp    $0x3,%eax
jl     120e <six+0xbe>
mov    $0x3,%ebx
lea    0xe5d(%rip),%r14
jmp    11f5 <six+0xa5>
xchg   %ax,%ax
mov    %edi,%eax
cltd
idiv   %ebx
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
mov    %edi,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     11e0 <six+0x90>
add    $0x2,%ebx
call   1070 <sqrt@plt>
cmp    %eax,%ebx
jle    11f5 <six+0xa5>
mov    0xc(%rsp),%esi
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebp,0xc(%rsp)
jne    1232 <six+0xe2>
lea    0xe39(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"enter number (int): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"\0Agenerated prime factorization: \00"
@.str.3 = [6 x i8] c"%d * \00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [27 x i8] c"note: the number is prime\0A\00"
@.str.6 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
define void @six() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 2, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 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* %1)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* %1
store i32 %7, i32* %3
br label %8
8: ; preds = %13, %0
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = srem i32 %9, %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = load i32, i32* %2
%15 = load i32, i32* %1
%16 = sdiv i32 %15, %14
store i32 %16, i32* %1
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %8
19: ; preds = %8
store i32 3, i32* %2
br label %20
20: ; preds = %38, %19
%21 = load i32, i32* %2
%22 = load i32, i32* %1
%23 = call i32 @sqrt(i32 %22)
%24 = icmp sle i32 %21, %23
br i1 %24, label %25, label %41
25: ; preds = %20
br label %26
26: ; preds = %31, %25
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = srem i32 %27, %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = load i32, i32* %2
%33 = load i32, i32* %1
%34 = sdiv i32 %33, %32
store i32 %34, i32* %1
%35 = load i32, i32* %2
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %26
37: ; preds = %26
br label %38
38: ; preds = %37
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 2
store i32 %40, i32* %2
br label %20
41: ; preds = %20
%42 = load i32, i32* %1
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %1
%45 = load i32, i32* %3
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %49
47: ; preds = %41
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %41
%50 = call i32 (...) @getchar()
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%52 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"enter number (int): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"\0Agenerated prime factorization: \00"
@.str.3 = [6 x i8] c"%d * \00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.6 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
@str = [26 x i8] c"note: the number is prime\00"
define void @six() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32, i32* %1
%7 = and i32 %6, 1
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %13, %0
%10 = phi i32 [ %6, %0 ], [ %17, %13 ]
%11 = call i32 @sqrt(i32 %10)
%12 = icmp slt i32 %11, 3
br i1 %12, label %37, label %20
13: ; preds = %0, %13
%14 = phi i32 [ %17, %13 ], [ %6, %0 ]
%15 = sdiv i32 %14, 2
store i32 %15, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 2)
%17 = load i32, i32* %1
%18 = and i32 %17, 1
%19 = icmp eq i32 %18, 0
br i1 %19, label %13, label %9
20: ; preds = %9, %32
%21 = phi i32 [ %34, %32 ], [ 3, %9 ]
%22 = load i32, i32* %1
%23 = srem i32 %22, %21
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %20, %25
%26 = phi i32 [ %29, %25 ], [ %22, %20 ]
%27 = sdiv i32 %26, %21
store i32 %27, i32* %1
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%29 = load i32, i32* %1
%30 = srem i32 %29, %21
%31 = icmp eq i32 %30, 0
br i1 %31, label %25, label %32
32: ; preds = %25, %20
%33 = phi i32 [ %22, %20 ], [ %29, %25 ]
%34 = add nuw nsw i32 %21, 2
%35 = call i32 @sqrt(i32 %33)
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %20
37: ; preds = %32, %9
%38 = load i32, i32* %1
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %1
%41 = icmp eq i32 %40, %6
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %44
44: ; preds = %42, %37
%45 = call i32 (...) @getchar()
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%47 = call i32 (...) @getchar()
ret void
}