#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 main(void) {
  int n, lcv, flag;
  printf("Enter value of N > ");
  scanf("%d", &n);
  for (lcv = 2, flag = 1; lcv <= (n / 2); lcv++) {
    if ((n % lcv) == 0) {
      if (flag)
        printf("The non-trivial factors of %d are: \n", n);
      flag = 0;
      printf("\t%d\n", lcv);
    }
  }
  if (flag)
    printf("%d is prime\n", n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jg     11cf <main+0xaf>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11bc <main+0x9c>
cmpl   $0x0,-0x10(%rbp)
je     11a4 <main+0x84>
mov    -0x8(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c1 <main+0xa1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
cmpl   $0x0,-0x10(%rbp)
je     11ea <main+0xca>
mov    -0x8(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x4,%esi
jl     11af <main+0x8f>
mov    $0x1,%ebx
lea    0xee1(%rip),%r14
lea    0xeb5(%rip),%r15
mov    $0x1,%ebp
jmp    118f <main+0x6f>
nopl   0x0(%rax)
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %esi,%eax
shr    $0x1f,%eax
add    %esi,%eax
sar    %eax
cmp    %eax,%ebx
jge    11ab <main+0x8b>
add    $0x1,%ebx
mov    %esi,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1182 <main+0x62>
test   %ebp,%ebp
je     1170 <main+0x50>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1170 <main+0x50>
test   %ebp,%ebp
je     11bd <main+0x9d>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter value of N > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"The non-trivial factors of %d are: \0A\00"
@.str.3 = [5 x i8] c"\09%d\0A\00"
@.str.4 = [13 x i8] c"%d is prime\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 ([20 x i8], [20 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)
store i32 2, i32* %3
store i32 1, i32* %4
br label %7
7: ; preds = %27, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = sdiv i32 %9, 2
%11 = icmp sle i32 %8, %10
br i1 %11, label %12, label %30
12: ; preds = %7
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = srem i32 %13, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %12
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %17
store i32 0, i32* %4
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %12
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %7
30: ; preds = %7
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %30
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter value of N > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"The non-trivial factors of %d are: \0A\00"
@.str.3 = [5 x i8] c"\09%d\0A\00"
@.str.4 = [13 x i8] c"%d is prime\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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 = icmp slt i32 %5, 4
br i1 %6, label %28, label %7
7: ; preds = %0, %20
%8 = phi i32 [ %21, %20 ], [ %5, %0 ]
%9 = phi i32 [ %22, %20 ], [ 1, %0 ]
%10 = phi i32 [ %23, %20 ], [ 2, %0 ]
%11 = srem i32 %8, %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %7
%14 = icmp eq i32 %9, 0
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %17
17: ; preds = %15, %13
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%19 = load i32, i32* %1
br label %20
20: ; preds = %7, %17
%21 = phi i32 [ %19, %17 ], [ %8, %7 ]
%22 = phi i32 [ 0, %17 ], [ %9, %7 ]
%23 = add nuw nsw i32 %10, 1
%24 = sdiv i32 %21, 2
%25 = icmp slt i32 %10, %24
br i1 %25, label %7, label %26
26: ; preds = %20
%27 = icmp eq i32 %22, 0
br i1 %27, label %31, label %28
28: ; preds = %0, %26
%29 = phi i32 [ %21, %26 ], [ %5, %0 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28, %26
ret i32 0
}