#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__ isPrime(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long);
int /*<<< orphan*/ scanf(char *, unsigned long *);
int main() {
  unsigned long N, largest, i = 2;
  scanf("%ld", &N);
  while (i <= N) {
    if (N % i == 0 && isPrime(i)) {
      largest = i;
      N /= i;
    } else {
      i++;
    }
  }
  printf("%ld", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x2,-0x20(%rbp)
lea    0xeb2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     11bd <main+0x8d>
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
cmp    $0x0,%rdx
jne    11ac <main+0x7c>
mov    -0x20(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11ac <main+0x7c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
jmp    11b8 <main+0x88>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1157 <main+0x27>
mov    -0x18(%rbp),%rsi
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    $0x2,%ebx
mov    (%rsp),%rcx
jmp    1159 <main+0x29>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rcx,%rbx
ja     11cd <main+0x9d>
mov    %rcx,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1180 <main+0x50>
mov    %rcx,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    1150 <main+0x20>
jmp    118b <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
jne    1150 <main+0x20>
mov    %rbx,%rdi
call   1040 <isPrime@plt>
mov    (%rsp),%rcx
test   %rax,%rax
je     1150 <main+0x20>
mov    %rcx,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11bc <main+0x8c>
mov    %rcx,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%rcx
mov    %rax,(%rsp)
mov    %rbx,%r14
jmp    1154 <main+0x24>
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%ecx
mov    %rcx,(%rsp)
mov    %rbx,%r14
jmp    1154 <main+0x24>
lea    0xe2c(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
store i64 2, i64* %4
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %6
6: ; preds = %27, %0
%7 = load i64, i64* %4
%8 = load i64, i64* %2
%9 = icmp ule i64 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = load i64, i64* %2
%12 = load i64, i64* %4
%13 = urem i64 %11, %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %10
%16 = load i64, i64* %4
%17 = call i64 @isPrime(i64 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i64, i64* %4
store i64 %20, i64* %3
%21 = load i64, i64* %4
%22 = load i64, i64* %2
%23 = udiv i64 %22, %21
store i64 %23, i64* %2
br label %27
24: ; preds = %15, %10
%25 = load i64, i64* %4
%26 = add i64 %25, 1
store i64 %26, i64* %4
br label %27
27: ; preds = %24, %19
br label %6
28: ; preds = %6
%29 = load i64, i64* %3
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* %1
%5 = icmp ugt i64 %4, 1
br label %6
6: ; preds = %0, %21
%7 = phi i64 [ %22, %21 ], [ %4, %0 ]
%8 = phi i64 [ %24, %21 ], [ 2, %0 ]
%9 = phi i64 [ %23, %21 ], [ undef, %0 ]
%10 = urem i64 %7, %8
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %6
%13 = call i64 @isPrime(i64 %8)
%14 = icmp eq i64 %13, 0
%15 = load i64, i64* %1
br i1 %14, label %18, label %16
16: ; preds = %12
%17 = udiv i64 %15, %8
store i64 %17, i64* %1
br label %21
18: ; preds = %12, %6
%19 = phi i64 [ %7, %6 ], [ %15, %12 ]
%20 = add i64 %8, 1
br label %21
21: ; preds = %18, %16
%22 = phi i64 [ %17, %16 ], [ %19, %18 ]
%23 = phi i64 [ %8, %16 ], [ %9, %18 ]
%24 = phi i64 [ %8, %16 ], [ %20, %18 ]
%25 = icmp ugt i64 %24, %22
br i1 %25, label %26, label %6
26: ; preds = %21
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %23)
ret i32 0
}